Escape-Technologies / mookme

A pre-commit tool designed for monorepos.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue with hooks running in parallel

tiagodj opened this issue · comments

Mookme is triggering the below hooks in parallel, and because lint-staged application relies on a local config file for each run, one of them always fails when I have code changes in both projects.

I have two pre-commit.json that looks just like this, one for each project client and apiserver:

{
  "steps": [
    {
      "name": "Lint & Format staged files",
      "command": "yarn lint-staged",
      "serial": true
    }
  ]
}

Sample output:

 Hooks : services/apiserver Error × 
→ Lint & Format staged files > yarn lint-staged 
❌ Error. 

 Hooks : services/client  Done ✓ 
→ Lint & Format staged files > yarn lint-staged 
✅ Done. 

Hook of package services/apiserver failed at step Lint & Format staged files 

[FAILED] lint-staged automatic backup is missing!

So is there a way to tell mookme to run hooks in series?

Hello Tiago, we also experience this issue with Mookme + lint-staged at my work, and we did not find any workaround for concurrency other than having the lint+format hooks executed at the very top of the monorepo (so, all of our packages are now linted and formatted at once, in a single commit hook).

Definitely not ideal.

On the other side, workspace hooks are designed as independant jobs, so as soon as this predicate is not valid anymore, many things will go weird within Mookme.

If you need an execution order, per-workspace, I would suggest that you declare the serial steps one folder above (or at the root of the monorepo). Not ideal as well, but it will surely do the job in your specific case.

Let me know if that worked for you :)

Thanks for the reply!

I moved the config one level up to mitigate this issue, so that is fine for now.

There is one change that I'd recommend, though:

When running a hook, if the onlyOn clause doesn't match anything and the command will not be executed, then it would be better if nothing was printed to the console.

This is because I have other projects in the same folder, that has nothing to do with the ones I have the hooks for, and they still see the name of all hooks being printed, together with "Skipped" under it.

This will for sure cause some complaints from colleagues that work in other projects under the same folder and are seeing this message every time they commit.

And more importantly, if there are many hooks configured, this will clutter the output with several messages being printed even though nothing is being done because nothing matched the onlyOn clause.