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

Make parallel: true work with priorities #846

Open
scop opened this issue Oct 16, 2024 · 3 comments
Open

Make parallel: true work with priorities #846

scop opened this issue Oct 16, 2024 · 3 comments
Labels
feature request A new lefthook feature description

Comments

@scop
Copy link
Contributor

scop commented Oct 16, 2024

⚡ Summary

Would good to have parallel: true work with priorities.

Value

Faster runs containing priorities (~ dependencies).

Behavior and configuration changes

For example:

foo:
  parallel: true
  commands:
    cmd-a:
      priority: 1
    cmd-b:
      priority: 2
    cmd-c:
      priority: 3
    cmd-d:
      # no priority set
    cmd-e:
      priority: 1
    cmd-f:
      priority: 3

...and lefthook run foo would result in the commands to be run in parallel within groups determined by priority.

So the order of execution would go in sequence

  1. priority 1: cmd-a and cmd-e in parallel
  2. priority 2 (after prio 1 jobs complete): cmd-b alone
  3. priority 3 (after prio 2 jobs complete): cmd-c and cmd-f in parallel
  4. priority +Infinity (after prio 3 jobs complete): cmd-d alone
@scop scop added the feature request A new lefthook feature description label Oct 16, 2024
@mrexox
Copy link
Member

mrexox commented Dec 19, 2024

@scop, please, try new jobs feature released with 1.10.0, check the docs but for your order definition the config can look like this:

# lefthook.yml
foo:
  jobs:
    - group:
        parallel: true
        jobs:
          - run: cmd-a
          - run: cmd-e
    - run: cmd-b
    - group:
      parallel: true
      jobs:
        - run: cmd-c
        - run: cmd-f
    - run: cmd-d

@scop
Copy link
Contributor Author

scop commented Dec 20, 2024

That looks otherwise nice and useful, but I suppose with the jobs config above, it would no longer be possible to run specific commands only?

With commands one could do lefthook run pre-commit --commands COMMANDNAME but there's no corresponding option to run only some job or group names?


Anyway for purposes of the actual topic in this issue, jobs and groups seem to fill the need fine, thanks!

@mrexox
Copy link
Member

mrexox commented Dec 21, 2024

Hmm, nice note. I think it should be possible to add the same --jobs argument. But if you have jobs with the same name – all of them will be run. Do you find this useful? I think I can add it in future releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request A new lefthook feature description
Projects
None yet
Development

No branches or pull requests

2 participants