evilmartians / lefthook

Fast and powerful Git hooks manager for any type of projects.
MIT License
5.02k stars 218 forks source link

Make `parallel: true` work with priorities #846

Open scop opened 1 month ago

scop commented 1 month ago

:zap: 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