Skip to content

Commit c65405e

Browse files
chore(ci): skip expensive jobs on non-source changes
Add dorny/paths-filter gate so lint, build-check, and both test jobs only run when source-affecting files change (src/, test/, package.json, tsconfigs, Dockerfiles, etc.). Metadata checks (commit-lint, changeset-check) remain unconditional. Also restrict commit-lint to PRs/workflow_dispatch to avoid false positives on squash-merge commits pushed to main, fix post-tests Coveralls parallel-finished to not fire on skipped test runs, and bump actions/checkout + actions/setup-node from v3 to v4.
1 parent 9645553 commit c65405e

1 file changed

Lines changed: 73 additions & 20 deletions

File tree

.github/workflows/checks.yml

Lines changed: 73 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,59 @@ concurrency:
1212
cancel-in-progress: true
1313

1414
jobs:
15+
changes:
16+
name: Detect changed paths
17+
runs-on: ubuntu-latest
18+
permissions:
19+
pull-requests: read
20+
outputs:
21+
src: ${{ steps.filter.outputs.src }}
22+
steps:
23+
- uses: actions/checkout@v4
24+
- id: filter
25+
uses: dorny/paths-filter@v3
26+
with:
27+
filters: |
28+
src:
29+
- 'src/**'
30+
- 'test/**'
31+
- 'package.json'
32+
- 'package-lock.json'
33+
- 'tsconfig*.json'
34+
- 'biome.json'
35+
- '.knip.json'
36+
- 'Dockerfile*'
37+
- 'docker-compose*.yml'
38+
- '.nvmrc'
39+
- '.github/workflows/checks.yml'
40+
1541
commit-lint:
1642
name: Lint commits
1743
runs-on: ubuntu-latest
44+
if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
1845
steps:
1946
- name: Checkout
20-
uses: actions/checkout@v3
47+
uses: actions/checkout@v4
2148
with:
2249
fetch-depth: 0
23-
- uses: actions/setup-node@v3
50+
- uses: actions/setup-node@v4
2451
with:
2552
node-version-file: .nvmrc
2653
cache: npm
2754
- name: Install package dependencies
2855
run: npm ci
2956
- name: Run commitlint
3057
uses: wagoid/commitlint-github-action@v5
58+
3159
lint:
3260
name: Lint code
3361
runs-on: ubuntu-latest
62+
needs: changes
63+
if: needs.changes.outputs.src == 'true'
3464
steps:
3565
- name: Checkout
36-
uses: actions/checkout@v3
37-
- uses: actions/setup-node@v3
66+
uses: actions/checkout@v4
67+
- uses: actions/setup-node@v4
3868
with:
3969
node-version-file: .nvmrc
4070
cache: npm
@@ -44,31 +74,40 @@ jobs:
4474
run: npm run lint
4575
- name: Run Knip
4676
run: npm run knip
77+
4778
build-check:
4879
name: Build check
4980
runs-on: ubuntu-latest
81+
needs: changes
82+
if: needs.changes.outputs.src == 'true'
5083
steps:
5184
- name: Checkout
52-
uses: actions/checkout@v3
53-
- uses: actions/setup-node@v3
85+
uses: actions/checkout@v4
86+
- uses: actions/setup-node@v4
5487
with:
5588
node-version-file: .nvmrc
5689
cache: npm
5790
- name: Install package dependencies
5891
run: npm ci
5992
- name: Run build check
6093
run: npm run build:check
94+
6195
test-units-and-cover:
6296
name: Unit Tests And Coverage
6397
runs-on: ubuntu-latest
6498
needs:
65-
- commit-lint
99+
- changes
66100
- lint
67101
- build-check
102+
if: |
103+
always() &&
104+
needs.changes.outputs.src == 'true' &&
105+
needs.lint.result != 'failure' &&
106+
needs.build-check.result != 'failure'
68107
steps:
69108
- name: Checkout
70-
uses: actions/checkout@v3
71-
- uses: actions/setup-node@v3
109+
uses: actions/checkout@v4
110+
- uses: actions/setup-node@v4
72111
with:
73112
node-version-file: .nvmrc
74113
cache: npm
@@ -93,17 +132,23 @@ jobs:
93132
flag-name: Unit
94133
github-token: ${{ secrets.GITHUB_TOKEN }}
95134
parallel: true
135+
96136
test-integrations-and-cover:
97137
name: Integration Tests and Coverage
98138
runs-on: ubuntu-latest
99139
needs:
100-
- commit-lint
140+
- changes
101141
- lint
102142
- build-check
143+
if: |
144+
always() &&
145+
needs.changes.outputs.src == 'true' &&
146+
needs.lint.result != 'failure' &&
147+
needs.build-check.result != 'failure'
103148
steps:
104149
- name: Checkout
105-
uses: actions/checkout@v3
106-
- uses: actions/setup-node@v3
150+
uses: actions/checkout@v4
151+
- uses: actions/setup-node@v4
107152
with:
108153
node-version-file: .nvmrc
109154
- name: Run integration tests
@@ -131,27 +176,35 @@ jobs:
131176
with:
132177
name: integration-coverage-lcov
133178
path: .coverage/integration/lcov.info
179+
134180
post-tests:
135181
name: Post Tests
136-
needs: [test-units-and-cover, test-integrations-and-cover]
137182
runs-on: ubuntu-latest
183+
needs:
184+
- changes
185+
- test-units-and-cover
186+
- test-integrations-and-cover
138187
if: ${{ always() }}
139188
steps:
140-
- name: Coveralls Finished
141-
uses: coverallsapp/github-action@master
142-
with:
143-
github-token: ${{ secrets.GITHUB_TOKEN }}
144-
parallel-finished: true
189+
- name: Coveralls Finished
190+
uses: coverallsapp/github-action@master
191+
if: |
192+
needs.test-units-and-cover.result != 'skipped' ||
193+
needs.test-integrations-and-cover.result != 'skipped'
194+
with:
195+
github-token: ${{ secrets.GITHUB_TOKEN }}
196+
parallel-finished: true
197+
145198
changeset-check:
146199
name: Changeset Required
147200
runs-on: ubuntu-latest
148201
if: github.event_name == 'pull_request' && github.head_ref != 'changeset-release/main'
149202
steps:
150203
- name: Checkout
151-
uses: actions/checkout@v3
204+
uses: actions/checkout@v4
152205
with:
153206
fetch-depth: 0
154-
- uses: actions/setup-node@v3
207+
- uses: actions/setup-node@v4
155208
with:
156209
node-version-file: .nvmrc
157210
cache: npm

0 commit comments

Comments
 (0)