Skip to content

Commit

Permalink
ci: only run tests when needed via needs_tests filter (#9781)
Browse files Browse the repository at this point in the history
Only run tests when needed via `needs_tests` filter. Useful to avoid
running test suite with template changes.
  • Loading branch information
paulpopus authored Dec 6, 2024
1 parent c9ce350 commit cb691e0
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
pull-requests: read
outputs:
needs_build: ${{ steps.filter.outputs.needs_build }}
needs_tests: ${{ steps.filter.outputs.needs_tests }}
templates: ${{ steps.filter.outputs.templates }}
steps:
# https://github.com/actions/virtual-environments/issues/1187
Expand All @@ -48,11 +49,18 @@ jobs:
- 'pnpm-lock.yaml'
- 'package.json'
- 'templates/**'
needs_tests:
- '.github/workflows/**'
- 'packages/**'
- 'test/**'
- 'pnpm-lock.yaml'
- 'package.json'
templates:
- 'templates/**'
- name: Log all filter results
run: |
echo "needs_build: ${{ steps.filter.outputs.needs_build }}"
echo "needs_tests: ${{ steps.filter.outputs.needs_tests }}"
echo "templates: ${{ steps.filter.outputs.templates }}"
lint:
Expand Down Expand Up @@ -154,8 +162,8 @@ jobs:

tests-unit:
runs-on: ubuntu-latest
needs: build

needs: [changes, build]
if: ${{ needs.changes.outputs.needs_tests == 'true' }}
steps:
# https://github.com/actions/virtual-environments/issues/1187
- name: tune linux network
Expand Down Expand Up @@ -186,7 +194,8 @@ jobs:

tests-int:
runs-on: ubuntu-latest
needs: build
needs: [changes, build]
if: ${{ needs.changes.outputs.needs_tests == 'true' }}
name: int-${{ matrix.database }}
strategy:
fail-fast: false
Expand Down Expand Up @@ -288,7 +297,8 @@ jobs:

tests-e2e:
runs-on: ubuntu-latest
needs: build
needs: [changes, build]
if: ${{ needs.changes.outputs.needs_tests == 'true' }}
name: e2e-${{ matrix.suite }}
strategy:
fail-fast: false
Expand Down Expand Up @@ -493,8 +503,8 @@ jobs:
tests-type-generation:
runs-on: ubuntu-latest
needs: build

needs: [changes, build]
if: ${{ needs.changes.outputs.needs_tests == 'true' }}
steps:
# https://github.com/actions/virtual-environments/issues/1187
- name: tune linux network
Expand Down

0 comments on commit cb691e0

Please sign in to comment.