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

Issue with hooks running in parallel #100

Open
tiagodj opened this issue Nov 29, 2022 · 2 comments
Open

Issue with hooks running in parallel #100

tiagodj opened this issue Nov 29, 2022 · 2 comments
Labels
bug Something isn't working documentation Improvements or additions to documentation question Further information is requested

Comments

@tiagodj
Copy link

tiagodj commented Nov 29, 2022

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?

@LMaxence
Copy link
Member

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

@LMaxence LMaxence added bug Something isn't working documentation Improvements or additions to documentation question Further information is requested labels Jan 29, 2023
@tiagodj
Copy link
Author

tiagodj commented Jan 30, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants