nx affected filtered by tag #8292
Closed
gschuager
started this conversation in
Feature Requests
Replies: 3 comments
-
Same wish for e2e target, where I need different CI jobs with different docker image |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hopefully we can obtain some traction in #10085 ! |
Beta Was this translation helpful? Give feedback.
0 replies
-
// // @ts-check
const { Workspaces } = require('@nrwl/devkit');
const { execSync } = require('child_process');
const { join } = require('path');
const [tag = null] = process.argv.slice(2);
if (!tag) {
console.error(`Missing tag`);
process.exit(1);
}
const workspace = new Workspaces(
join(__dirname, '..')
).readWorkspaceConfiguration();
const projects = execSync('yarn -s nx print-affected --select projects')
.toString('utf-8')
.trim()
.split(', ')
.filter((project) => !!project);
const affected = projects.filter((project) =>
workspace.projects[project].tags?.includes(tag)
);
const affectedMatrix = JSON.stringify(affected);
const hasAffected = affected.length > 0;
console.log(JSON.stringify({ affectedMatrix, hasAffected })); This is the utility script that I've been using in my CI: name: E2E
on:
pull_request:
workflow_dispatch:
push:
branches:
- master
jobs:
affected:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup node
uses: ./.github/actions/setup-node
with:
node-auth-token: ${{ secrets.ORG_GITHUB_PACKAGES_READER }}
- name: Find affected
id: find-affected
run: echo "::set-output name=affected::$(node ./tools/find-affected.js type:nx-plugin-e2e)"
- name: Print Affected
run: echo ${{ fromJSON(steps.find-affected.outputs.affected).affectedMatrix }}
outputs:
affected: ${{ fromJSON(steps.find-affected.outputs.affected).affectedMatrix }}
has-affected: ${{ fromJSON(steps.find-affected.outputs.affected).hasAffected }}
e2e:
needs: affected
runs-on: ubuntu-latest
if: ${{ fromJSON(needs.affected.outputs.has-affected) }}
strategy:
matrix:
app: ${{ fromJSON(needs.affected.outputs.affected) }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup node
uses: ./.github/actions/setup-node
with:
node-auth-token: ${{ secrets.ORG_GITHUB_PACKAGES_READER }}
- run: yarn nx e2e ${{ matrix.app }} Having it built-in would be very nice indeed |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is there any way to get a list of affected projects (as in nx affected:apps or libs) which have a certain tag?
The use case is that I'm trying to mix angular apps with .NET apps in a single monorepo. In my CI config, I intend to have separate jobs to lint (or test) typescript projects and .NET projects: each of these tasks require a different base docker image (node vs .NET sdk) and I'd like to have a way to run some target on the corresponding subset of affected projects.
Beta Was this translation helpful? Give feedback.
All reactions