Skip to content

Commit cb691e0

Browse files
authored
ci: only run tests when needed via needs_tests filter (#9781)
Only run tests when needed via `needs_tests` filter. Useful to avoid running test suite with template changes.
1 parent c9ce350 commit cb691e0

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

.github/workflows/main.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ jobs:
2828
pull-requests: read
2929
outputs:
3030
needs_build: ${{ steps.filter.outputs.needs_build }}
31+
needs_tests: ${{ steps.filter.outputs.needs_tests }}
3132
templates: ${{ steps.filter.outputs.templates }}
3233
steps:
3334
# https://github.com/actions/virtual-environments/issues/1187
@@ -48,11 +49,18 @@ jobs:
4849
- 'pnpm-lock.yaml'
4950
- 'package.json'
5051
- 'templates/**'
52+
needs_tests:
53+
- '.github/workflows/**'
54+
- 'packages/**'
55+
- 'test/**'
56+
- 'pnpm-lock.yaml'
57+
- 'package.json'
5158
templates:
5259
- 'templates/**'
5360
- name: Log all filter results
5461
run: |
5562
echo "needs_build: ${{ steps.filter.outputs.needs_build }}"
63+
echo "needs_tests: ${{ steps.filter.outputs.needs_tests }}"
5664
echo "templates: ${{ steps.filter.outputs.templates }}"
5765
5866
lint:
@@ -154,8 +162,8 @@ jobs:
154162

155163
tests-unit:
156164
runs-on: ubuntu-latest
157-
needs: build
158-
165+
needs: [changes, build]
166+
if: ${{ needs.changes.outputs.needs_tests == 'true' }}
159167
steps:
160168
# https://github.com/actions/virtual-environments/issues/1187
161169
- name: tune linux network
@@ -186,7 +194,8 @@ jobs:
186194

187195
tests-int:
188196
runs-on: ubuntu-latest
189-
needs: build
197+
needs: [changes, build]
198+
if: ${{ needs.changes.outputs.needs_tests == 'true' }}
190199
name: int-${{ matrix.database }}
191200
strategy:
192201
fail-fast: false
@@ -288,7 +297,8 @@ jobs:
288297

289298
tests-e2e:
290299
runs-on: ubuntu-latest
291-
needs: build
300+
needs: [changes, build]
301+
if: ${{ needs.changes.outputs.needs_tests == 'true' }}
292302
name: e2e-${{ matrix.suite }}
293303
strategy:
294304
fail-fast: false
@@ -493,8 +503,8 @@ jobs:
493503
494504
tests-type-generation:
495505
runs-on: ubuntu-latest
496-
needs: build
497-
506+
needs: [changes, build]
507+
if: ${{ needs.changes.outputs.needs_tests == 'true' }}
498508
steps:
499509
# https://github.com/actions/virtual-environments/issues/1187
500510
- name: tune linux network

0 commit comments

Comments
 (0)