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

Bolt workspaces command to only run on modified workspaces #303

Open
robertmassaioli opened this issue Sep 5, 2021 · 1 comment
Open

Comments

@robertmassaioli
Copy link

It would be great, for CI/CD and pre-commit hooks, if I could run bolt ws --only-modified such that, only if there were changes in the workspaces subdirectory, would the command run on that particular workspaces.

This would be useful especially for doing things like running a lint command only on the packages that need it.

@steve-taylor
Copy link

If you want to have a crack at doing this yourself, you can use the getChangedPackagesSinceRef function exported from @changesets/git, which gives you the parsed package.json of every directly changed package since the specified git ref.

This won't get you very far, though. You need to resolve your internal dependencies before you can build, lint or test your changed packages. The only way you can do this is by building them. Fortunately, Bolt comes with a function called getDependencyGraph which does exactly as its name implies. You'll need to build your upstream packages in dependency order, which you can do by recursively walking the graph.

If you think you're done at this point, you're wrong. Your green build can easily be a false negative if you don't also build, test and lint your monorepo's downstream packages. Remember that the build status (green or red) is the status of the entire monorepo. You can use Bolt's getDependentsGraph function to get these dependencies.

But what about the dependents' other upstream packages? They'll also need to be built!

I think you can see where this is going. You might as well just build, test and lint everything.

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

No branches or pull requests

2 participants