Skip to content

Commit f30f1f1

Browse files
committed
Run github actions only for affected apps/pacakges
1 parent 3cfb91f commit f30f1f1

File tree

4 files changed

+53
-4
lines changed

4 files changed

+53
-4
lines changed

.github/workflows/ci-test.yml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ jobs:
2020
steps:
2121
- name: Checkout code
2222
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
2325

2426
- name: Set up Node.js ${{ matrix.node-version }}
2527
uses: actions/setup-node@v4
@@ -31,18 +33,33 @@ jobs:
3133
# --frozen-lockfile ensures yarn.lock is respected exactly
3234
run: yarn install --frozen-lockfile
3335

36+
- name: Derive Nx SHAs
37+
uses: nrwl/nx-set-shas@v4
38+
39+
- name: Detect if library is affected
40+
id: affected
41+
run: |
42+
AFFECTED=$(npx nx print-affected --select=projects)
43+
if echo "$AFFECTED" | tr ',' ' ' | tr ' ' '\n' | grep -xq "sequelize-guard"; then
44+
echo "library=true" >> $GITHUB_OUTPUT
45+
else
46+
echo "library=false" >> $GITHUB_OUTPUT
47+
fi
48+
3449
- name: Run lint
3550
# This runs lint with eslint
36-
run: yarn lint
51+
run: npx nx affected -t lint --parallel=3
3752

3853
- name: Run tests and generate coverage
54+
if: steps.affected.outputs.library == 'true'
3955
# This runs vitest with coverage enabled
40-
run: yarn test:coverage
56+
run: npx nx affected -t test:coverage --parallel=3
4157

4258
- name: Upload coverage to Coveralls
59+
if: steps.affected.outputs.library == 'true'
4360
uses: coverallsapp/github-action@v2
4461
with:
4562
base-path: packages/sequelize-guard
4663

4764
- name: Build the library
48-
run: yarn build
65+
run: npx nx affected -t build --parallel=3

.github/workflows/release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ jobs:
2222
steps:
2323
- name: Checkout code
2424
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
2527

2628
- name: Set up Node.js ${{ matrix.node-version }}
2729
uses: actions/setup-node@v4

apps/sequelize-guard-docs/project.json

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,32 @@
55
"projectType": "application",
66
"tags": [],
77
"// targets": "to see all targets run: nx show project sequelize-guard-docs --web",
8-
"targets": {}
8+
"targets": {
9+
"build": {
10+
"executor": "nx:run-commands",
11+
"options": {
12+
"cwd": "apps/sequelize-guard-docs",
13+
"command": "yarn build"
14+
}
15+
},
16+
"lint": {
17+
"executor": "nx:run-commands",
18+
"options": {
19+
"cwd": "apps/sequelize-guard-docs",
20+
"command": "yarn lint"
21+
}
22+
},
23+
"test": {
24+
"executor": "nx:run-commands",
25+
"options": {
26+
"command": "echo 'No tests configured for sequelize-guard-docs'"
27+
}
28+
},
29+
"test:coverage": {
30+
"executor": "nx:run-commands",
31+
"options": {
32+
"command": "echo 'No coverage tests configured for sequelize-guard-docs'"
33+
}
34+
}
35+
}
936
}

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
"lint:staged": "eslint --fix --max-warnings 0",
3535
"lint:staged:js": "eslint --fix",
3636
"pre-commit": "yarn lint-staged && tsc --noEmit",
37+
"affected:lint": "nx affected -t lint",
38+
"affected:test": "nx affected -t test",
39+
"affected:build": "nx affected -t build",
3740
"docs:generate": "node scripts/generate-api-docs.mjs"
3841
},
3942
"devDependencies": {

0 commit comments

Comments
 (0)