Context
Currently I am in the process of setting up a polyglot NX monorepo as part of a POC.
Problem overview
I want to re-use existing GitHub actions and workflows, but these act on a sourcecode directory.
In our case this is mostly Node (js/ts) and Go apps.
However using nx affected
will only give me the name of the affected project, not the path to the project (which the workflows could be run on).
Problem details
If we were to have a directory structure like this:
apps/
foo # node
bar # go
libs/
spam # ts
eggs # go
then we could solve this by using tags in each respective project.json
for the different apps and libs, and filter on that when running nx affected ...
.
However if you have a more nested folder structure, such as
apps/
go/
bar
node/
foo
libs/
go/
eggs
ts/
spam
Now with this structure, we cannot assume that we can prepend any affected app with apps/
etc.
So what does one do in this case? Either we can use tags that have to be in sync with all of the project.json
files in each of the projects. However it’s not the most robust solution exactly, since any mistake by moving a directory, changing tags without adjusting the other parts will end up with a mismatch.
Solution wishlist
Preferably I want to be able to use some sort of nx command to get the paths to the affected projects.
Using these I want to set up outputs to be used in a GitHub workflow matrix to to use with other reusable workflows.
Useful links
- https://nx.dev/nx-api/nx/documents/affected
- https://nx.dev/recipes/enforce-module-boundaries/tag-multiple-dimensions#tag-in-multiple-dimensions
- https://nx.dev/features/enforce-module-boundaries#tags
- https://blog.nrwl.io/mastering-the-project-boundaries-in-nx-f095852f5bf4