nx
nx copied to clipboard
feat(core): add support for tags with `(print-)affected(:*)` and `run-many`
Current Behavior
When running the (print-)affected(:*)
command you get all affected projects for a target.
With the run-many
command filtering is only possible with --projects
.
Both accept a --all
, it being warned for in affected
.
Expected Behavior
We would expect to be able to select projects by tags
.
This PR
This could be seen as a first step only acting to select projects in the same way --projects
does it for run-many
. Tags are not applied in compound but rather as OR
statement in comma separated fashion.
That is in the example below the command would select projects that either contain the tag sdk
or the tag app
, not necessarily projects containing both tags.
nx affected --tags=sdk,app --target=test
Related Issue(s)
This relates to very long standing #1621, #2675 or #8292 and a Nx v14 compatible treatment while being different from #8364 which attempts to support globs but does not address run-many
.
Closes #1621 Closes #2675
☁️ Nx Cloud Report
CI is running/has finished running commands for commit 3410cfc0430b138e5e6b151d419e1dc9b8a3bce0. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.
📂 See all runs for this branch
✅ Successfully ran 11 targets
-
nx affected --target=e2e --base=3653e5944da44dd9df50488f33ff818c2832d161 --head=3410cfc0430b138e5e6b151d419e1dc9b8a3bce0 --exclude=e2e-storybook,e2e-storybook-angular,e2e-react-native,e2e-detox --parallel=1
-
nx affected --target=test --base=3653e5944da44dd9df50488f33ff818c2832d161 --head=3410cfc0430b138e5e6b151d419e1dc9b8a3bce0 --parallel=1
-
nx affected --target=build --base=3653e5944da44dd9df50488f33ff818c2832d161 --head=3410cfc0430b138e5e6b151d419e1dc9b8a3bce0 --parallel=3
-
nx depcheck --no-dte
-
nx affected --target=lint --base=3653e5944da44dd9df50488f33ff818c2832d161 --head=3410cfc0430b138e5e6b151d419e1dc9b8a3bce0 --parallel=3
-
nx lint --no-dte
-
nx check-lock-files --no-dte
-
nx check-commit --no-dte
-
nx-cloud record -- nx format:check --base=3653e5944da44dd9df50488f33ff818c2832d161 --head=3410cfc0430b138e5e6b151d419e1dc9b8a3bce0
-
nx check-imports --no-dte
-
nx documentation --no-dte
Sent with 💌 from NxCloud.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
nx-dev | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Apr 6, 2023 6:30pm |
Hello @vsavkin ! I know you had interest in looking at this over the past few years. It is the second PR opened for this feature but it addressed things slightly differently. I am happy to bring any changes required, any feedback/direction is most welcome We have a lot of need for this in our company.
Thank you for your help and valuable time 🙏🏼 !
Any update on this? I would love to use it 😁 Also, I thought it might be worth adding this to print-affected
as well
I thought it might be worth adding this to
print-affected
as well
Hello ! The print-affected
command should already work out of the box with the changes proposed at it is considered a special branch of the affected
command and the project filtering gets done upstream of that.
https://github.com/nrwl/nx/blob/7f5137da84e5d0f1b31f9011c57fc0e3bfaa9252/packages/nx/src/command-line/affected.ts#L37
https://github.com/nrwl/nx/blob/7f5137da84e5d0f1b31f9011c57fc0e3bfaa9252/packages/nx/src/command-line/affected.ts#L79-L113
I can imagine there is latent question with regard to the use/semantic of --exclude
which only applies to project names. I do not necessarily have a set opinion on this. In effect a tag filtering can very much replace the use of --exclude
.
Would love to see this merged into Nx and my PR closed.
This would be a big QoL feature for us, would love to see this in the next release! Any indications when that might be?
Can't wait for this to be merged :smile:
pls
This would be a great QoL feature for our team 👍
@gioragutt
@gioragutt
Can you add some context to why you tagged me? 😅
My team and I are so excited about this feature please release it in next version :)
Would really like this!
Use-case: only publish to the public npm registry packages tagged with open-source
.
Also interested in this. I want to be able to get a list of affected projects filtered by tag. Use case is for use with the nx dotnet plugin. When I generate a dotnet app it actually generates 2 app. One is the main dotnet app. The other is a test app. I want to get a list of affected apps excluding the test apps.
☁️ Nx Cloud Report
CI is running/has finished running commands for commit d2ffdb6ca361841c6117eed0df2cd7d59b0d3bca. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.
📂 See all runs for this branch
✅ Successfully ran 1 target
Sent with 💌 from NxCloud.
When this feature will be published? I'm wating for it. Use case: create separate ci/cd pipelines for projects in different technologies, like js and dotnet (with nx dotnet plugin)
@fguitton thank you for keeping this up to date for when they finally merge this 🙏🏻 I'm amused every time I get a notification about a rebase 😂
I'm amused every time I get a notification about a rebase
Haha ! You're most welcome. I guess I'm being a bit overzealous on this one 😅 . It's almost going to be the oldest non-merged (or closed) pull-request now ! 😄
Is there anything specific that is blocking this from being merged?
@gioragutt
for when they finally merge this
We are now officially the oldest open pull request at sea. Hehe. Perhaps this means we're next ! 😃
@gioragutt
for when they finally merge this
We are now officially the older open pull request at sea. Hehe. Perhaps this means we're next ! 😃
That's actually funny 😄 and again, kudos to you for keeping it up all this time 🙏🏻
@fguitton Actually, after discussing this with @vsavkin a bit more today there is a bit more involved change that we'd like to make to properly support this and open some more doors in the future. Have you joined our community slack? I'd love to connect there and offer some more insight.
Here's the link if you aren't there yet, just dm me 😄: https://go.nrwl.io/join-slack
@AgentEnder, So I found a bit of time to explore the direction you indicated and I have updated the PR to use this new approach.
The findMatchingProjects
function has been modified to a operated on the following pattern: [tag:]filter[,...]
.
I have also removed the Set(...)
performance bailout but making sure the performance test on CI were satisfied.
The principle stays the same and the change still covers (print-)affected(:*)
and run-many
but everything now happens through --projects
argument. I have also made sure to permit a similar logic for the --exclude
commutator as well, making sure is it backward compatible.
Negative filtering is supported and the syntax is flexible; either !tag:ui
or tag:!ui
indifferently.
Mix of project name and tag filters are also supported with an non-chained, negation-takes-all behaviour. Meaning the order of filters has no impact and we prefer to exclude in all cases.
I took the liberty to remove the mentions that tags only served for linting as well as added a couple of unit tests to insure that things behaved properly.
Feedback is obviously welcome, looking forward to this being merged in !
Best wishes 🌴
Awesome! Thanks for the updates @fguitton. I'll look over this either today or tomorrow.
Thank you @AgentEnder ! Extending to the whole Nx team of course ! Thrilled to see this merged 🎉
Congrats @fguitton, you've put a lot of work on this and it shows! Thank you for all your effort, I'm sure it'll bring immense value to a lot of people 🙏🏻🙏🏻🙏🏻
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.