Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DebugCommand to display task execution order #1491

Merged
merged 17 commits into from
Feb 27, 2018

Conversation

skarnl
Copy link
Contributor

@skarnl skarnl commented Jan 3, 2018

Q A
Bug fix? No
New feature? Yes
BC breaks? No
Deprecations? No
Fixed tickets #1488

Not sure if this was the correct route, to create a command for it. I noticed (after creating the command) that some other utilities (like the config/hosts.php) were just written as tasks.
If I need to rewrite this - let me know.

@staabm
Copy link
Contributor

staabm commented Jan 3, 2018

could you create a screen/send a textual representation of the output one can expect for a non trivial command?

@antonmedv antonmedv self-requested a review January 4, 2018 08:20
@skarnl
Copy link
Contributor Author

skarnl commented Jan 4, 2018

@staabm it will output as follows:

~  php ~/projects/deployer/bin/dep debug:task deploy staging

The task-tree for deploy:
+-------+----------------------+-------------+----------------+
| Index | Task                 | Before      | After          |
+-------+----------------------+-------------+----------------+
| 0     | other_custom_task    | deploy:info |                |
| 1     | custom_task          | deploy:info |                |
| 2     | deploy:info          |             |                |
| 3     | confirmDeploy        |             | deploy:info    |
| 4     | frontend:build       |             | deploy:info    |
| 5     | deploy:prepare       |             |                |
| 6     | deploy:lock          |             |                |
| 7     | deploy:release       |             |                |
| 8     | deploy:update_code   |             |                |
| 9     | deploy:shared        |             |                |
| 10    | deploy:vendors       |             |                |
| 11    | deploy:copy_dirs     |             | deploy:vendors |
| 12    | deploy:writable      |             |                |
| 13    | artisan:storage:link |             |                |
| 14    | artisan:view:clear   |             |                |
| 15    | artisan:cache:clear  |             |                |
| 16    | artisan:config:cache |             |                |
| 17    | artisan:optimize     |             |                |
| 18    | deploy:symlink       |             |                |
| 19    | deploy:unlock        |             |                |
| 20    | cleanup              |             |                |
| 21    | success              |             |                |
+-------+----------------------+-------------+----------------+

Or:

~  php ~/projects/deployer/bin/dep debug:task deploy:vendors  staging

The task-tree for deploy:vendors:
+-------+------------------+--------+----------------+
| Index | Task             | Before | After          |
+-------+------------------+--------+----------------+
| 0     | deploy:vendors   |        |                |
| 1     | deploy:copy_dirs |        | deploy:vendors |
+-------+------------------+--------+----------------+

@antonmedv
Copy link
Member

What about digging it into dep help output?

No need for extra command. Also description can be displayed.

$ dep help deploy
Deploy laravel app
Flow:
   deploy
   |- deploy:prepare
   |- deploy:release
   ...
   |- success

Also I think tree view will be much more informative.

@staabm
Copy link
Contributor

staabm commented Jan 4, 2018

random idea: would it make sense to have a separate column with fail() tasks (the tasks which get fired when another tasks fails)?

is the "index" column actual useful?

A tree view indeed could make it more readale

@skarnl
Copy link
Contributor Author

skarnl commented Jan 4, 2018

imo a tree view would be weird for before tasks, how would you display them?

I thought about it, before I made it into the table display. But I wasn't sure if the tree-view would actually provide more information

And in the end the whole task tree/hierarchy is pretty flat. If I viewed it correctly in the ScriptManager::getTasks, tasks which are inserted by an before or after are just flat injected in between the other task, they are not nested / subtasks or something like that - right?

@staabm index might be not needed, correct. For me it gave me a little more explicit indication of the order

As a side step, I did notice that the befores are stacked, so:

before('task1', 'subtask1')
before('task1', 'subtask2')

would result in:

subtask2
subtask1
task1

but after is a queue, so the order is like you called them:

after('task1', 'subtask1')
after('task1', 'subtask2')

would result in:

task1
subtask1
subtask2

Not sure this is intended behavior, but it was something I noticed and kinda felt a little inconsistent
</end of sidestep>

(this was why I introduced the index, to make the order of execution even more explicit)

@antonmedv
Copy link
Member

imo a tree view would be weird for before tasks, how would you display them?

Flatten.

Result is always flat: Task[] to execute. but we loose group task information. Will be cool to see it as tree.

In case of deploy there is only one root deploy and lots of subtasks. But everithing goes tricky then you add more group tasks.

@antonmedv
Copy link
Member

deploy
  deploy:starting
    [before]
      deploy:ensure_stage
      deploy:set_shared_assets
    deploy:check
  deploy:started
  deploy:updating
    git:create_release
    deploy:symlink:shared
  deploy:updated
    [before]
      deploy:bundle
    [after]
      deploy:migrate
      deploy:compile_assets
      deploy:normalize_assets
  deploy:publishing
    deploy:symlink:release
  deploy:published
  deploy:finishing
    deploy:cleanup
  deploy:finished
    deploy:log_revision

@skarnl
Copy link
Contributor Author

skarnl commented Jan 5, 2018

I understand what you are trying to display, @antonmedv
But the tree displayed as your example is a little confusion for me what the order of execution is.
Do you want to display what tasks are executed before/after some other task? Or do you want to display the actual task which is executed before/after a task?
Honestly, I'm not trying to nitpick here ^^

But for instance the following:

deploy:starting
    [before]
      deploy:ensure_stage
      deploy:set_shared_assets
    deploy:check
  deploy:started

What is the order of execution?
Is it:

deploy:starting
deploy:ensure_stage
deploy:set_shared_assets
deploy:check
deploy:started

So it's as shown, but that would mean the [before] is a before of deploy:check

But then this bit isn't the same:

deploy:updated
    [before]
      deploy:bundle
    [after]
      deploy:migrate
      deploy:compile_assets
      deploy:normalize_assets

That would suggest the before is the before of it's parent.
So the order of the first bit would be:

deploy:ensure_stage
deploy:set_shared_assets
deploy:starting
deploy:check
deploy:started

And if that's the case, I don't think this tree view works as intended.
I understand there is a need for the tree view, but I think the rendering should be non-ambiguous

Maybe something more like this:

deploy
  deploy:ensure_stage [before: deploy:starting]
  deploy:set_shared_assets [before: deploy:starting]
  deploy:starting      
    deploy:check
  deploy:started
  deploy:updating
    git:create_release
    deploy:symlink:shared
  deploy:bundle [before: deploy:updated]
  deploy:updated 
  deploy:migrate [after: deploy:updated]
  deploy:compile_assets [after: deploy:updated]
  deploy:normalize_assets [after: deploy:updated]
  deploy:publishing
    deploy:symlink:release
  deploy:published
  deploy:finishing
    deploy:cleanup
  deploy:finished
    deploy:log_revision

So you keep the order of execution (just top to bottom) and you have the tree view of what tasks are subtasks of other parents. And you see whats added from what before.

We could also just make it twofold. Normally it will just print:

deploy
  deploy:ensure_stage [before]
  deploy:set_shared_assets [before]
  deploy:starting      
    deploy:check
  deploy:started
  deploy:updating
    git:create_release
    deploy:symlink:shared
  deploy:bundle [before]
  deploy:updated 
  deploy:migrate [after]
  deploy:compile_assets [after]
  deploy:normalize_assets [after]
  deploy:publishing
    deploy:symlink:release
  deploy:published
  deploy:finishing
    deploy:cleanup
  deploy:finished
    deploy:log_revision

and if you add --vvv it will also add the task it was before/after: [before: deploy:starting]


btw, in my initial commit (dd29e8) I kinda did this [before: <taskname>] already, but figured it was prettier to display it as a table 😏

@antonmedv
Copy link
Member

I like this:

deploy
  deploy:ensure_stage [before]
  deploy:set_shared_assets [before]
  deploy:starting      
    deploy:check
  deploy:started
  deploy:updating
    git:create_release
    deploy:symlink:shared
  deploy:bundle [before]
  deploy:updated 
  deploy:migrate [after]
  deploy:compile_assets [after]
  deploy:normalize_assets [after]
  deploy:publishing
    deploy:symlink:release
  deploy:published
  deploy:finishing
    deploy:cleanup
  deploy:finished
    deploy:log_revision

@skarnl
Copy link
Contributor Author

skarnl commented Jan 17, 2018

It now renders as follows:

The task-tree for deploy:
└── deploy
    ├── deploy:info
    ├── confirmDeploy
    ├── build
    ├── release
    │   ├── deploy:prepare
    │   ├── deploy:lock
    │   ├── deploy:release
    │   ├── deploy:copy_dirs [before:upload]
    │   ├── upload
    │   ├── add-deploy-info [after:upload]
    │   ├── upload-deploy-info [after:add-deploy-info]
    │   ├── deploy:shared
    │   ├── deploy:writable
    │   ├── artisan:storage:link
    │   ├── artisan:view:clear
    │   ├── artisan:cache:clear
    │   ├── grouped-after-task [after:artisan:cache:clear]
    │   │   ├── grouped-after-task-1
    │   │   ├── grouped-after-task-2
    │   │   └── grouped-after-task-3
    │   ├── artisan:config:cache
    │   ├── artisan:optimize
    │   ├── deploy:symlink
    │   └── deploy:unlock
    ├── grouped-task [after:release]
    │   ├── task1
    │   ├── task2
    │   ├── subtask-after-task2-1 [after:task2]
    │   ├── subtask-after-task2-2 [after:task2]
    │   ├── subtask-before-task3 [before:task3]
    │   ├── task3
    │   │   ├── task3-1
    │   │   ├── task3-2
    │   │   │   ├── task3-2-1
    │   │   │   ├── task3-2-2
    │   │   │   └── task3-2-3
    │   │   ├── task3-3
    │   │   └── task3-4
    │   │       ├── task3-4-1
    │   │       ├── task3-4-2
    │   │       └── task3-4-3
    │   ├── task4
    │   └── task5
    ├── cleanup
    └── success

@antonmedv antonmedv merged commit b336184 into deployphp:master Feb 27, 2018
@antonmedv
Copy link
Member

Got merged! Hurray!

antonmedv pushed a commit that referenced this pull request Apr 18, 2018
* Add DebugCommand

* Adjust display of debug to table layout

* Update changelog

* Update CHANGELOG.md

* Fix StyleCI error

* Revert "Adjust display of debug to table layout" and setup new tree structure

This reverts commit db97551.

* Render tree view (the basic)

* Tweak rendering of tree

* Add depth for groups and pipe symbol

* Fix rendering of last element

* Display postfix for groups

* Fix issue with display of after-task after last grouped task

* Fix CS

* Fix StyleCI issues

* Add doc-comments

* Update CHANGELOG.md

Fix issue order (by request of Scrutinizer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants