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

feat: add command to print task dependency tree #1440

Merged
merged 12 commits into from
Jan 13, 2024
Merged

Conversation

roele
Copy link
Contributor

@roele roele commented Jan 12, 2024

First rough draft to visualize task depencies (#1272).

Changes

  • moved Deps to tasks/deps.rs and made crate/struct public
  • added new task command deps [--dot] [TASKS]...
  • uses crate ptree to render a tree directly from a petgraph::Graph
  • uses crate petgraph to render a DOT representation which can be piped via | dot -Tpng > ./graph.png

Open issues

  • [tree] ptree does not seem to allow customization of output and simply uses fmt::Display which currently has the format [TASK] CMD...
  • [tree] sub-tasks seem to be in wrong order
  • [dot] only renders nodes with incoming edges

Looking forward to some comments, as a Rust newby i feel there is a lot of room for improvement in that first rough draft.

src/cli/task/deps.rs Outdated Show resolved Hide resolved
@jdx
Copy link
Owner

jdx commented Jan 12, 2024

moved Deps to tasks/deps.rs and made crate/struct public

I wonder if we should reconsider the term depends used on task definitions to also be "deps".

[tree] ptree does not seem to allow customization of output and simply uses fmt::Display which currently has the format [TASK] CMD...

we could fork it (no update in 2 years), or change the way we use fmt::Display in other places, or you could use a different data structure maybe

I think it's definitely on the right track though, mostly the fmt::Display issue makes it not look great but I think when that is fixed it will look incredible. DIdn't test the dot stuff, I'll wait a bit till you get the last thing fixed.

Definitely a good start though, especially as a rust newbie. That petgraph stuff definitely isn't easy to work with.

@roele
Copy link
Contributor Author

roele commented Jan 12, 2024

  • moved Deps to task.rs
  • removed crate ptree and re-implemented rendering of the Graph as tree

TODO

  • move generic tree rendition structs and code to ui/tree.rs
  • clean up and simplify code where possible
  • revisit DOT format because of missing tasks without edges
  • add tests

src/cli/task/deps.rs Outdated Show resolved Hide resolved
src/cli/task/deps.rs Outdated Show resolved Hide resolved
src/cli/task/deps.rs Outdated Show resolved Hide resolved
@roele
Copy link
Contributor Author

roele commented Jan 13, 2024

I revisited the DOT format export but it seems there is no way to show tasks which do not have any edges (dependencies). Also the export has almost no configuration options.

Also EndBug/add-and-commit@v9 fails the unit test step currently and might require a smarter condition to prevent trying to update my repository to which it has no access to.

@roele roele marked this pull request as ready for review January 13, 2024 18:01
@jdx
Copy link
Owner

jdx commented Jan 13, 2024

nice work!

@jdx jdx merged commit ef2cc0c into jdx:main Jan 13, 2024
7 checks passed
@jdx jdx linked an issue Jan 17, 2024 that may be closed by this pull request
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.

visualize task dependency tree
2 participants