Skip to content

Commit

Permalink
Succeed action when irrelevant tests are not run.
Browse files Browse the repository at this point in the history
Instead of not running an action at all when relevant files are unchanged, run the action but skip the actual tests. This allows required checks to succees.
  • Loading branch information
JeltevanBoheemen committed Jun 12, 2024
1 parent 634b1b6 commit 94c48c9
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 12 deletions.
28 changes: 22 additions & 6 deletions .github/workflows/backend-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,31 @@ on:
- 'hotfix/**'
- 'release/**'
- 'dependabot/**'
paths-ignore:
- 'frontend/**'
- '**.md'

jobs:
backend-test:
name: Test Backend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run backend tests
run: sudo mkdir -p /ci-data && sudo docker-compose --env-file .env-ci run backend pytest
- name: Check if files have been changed in the backend
uses: actions/[email protected]
id: backend-changed
with:
result-encoding: string
script: |
const result = await github.pulls.listFiles({
owner: context.payload.repository.owner.login,
repo: context.payload.repository.name,
pull_number: context.payload.number,
per_page: 100
})
const backendChanged = result.data.filter(f => f.filename.startsWith("backend/") || f.filename.startsWith(".github") || f.filename.startsWith("docker-compose") || f.filename.startsWith(".env-ci")).length > 0
console.log("backend changed: ", backendChanged)
return backendChanged
- name: Checkout repository
if: ${{ steps.backend-changed.outputs.result == 'true' }}
uses: actions/checkout@v3

- name: Run backend tests
run: sudo mkdir -p /ci-data && sudo docker-compose --env-file .env-ci run backend pytest
28 changes: 22 additions & 6 deletions .github/workflows/frontend-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,31 @@ on:
- 'hotfix/**'
- 'release/**'
- 'dependabot/**'
paths-ignore:
- 'backend/**'
- '**.md'

jobs:
frontend-test:
name: Test Frontend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run frontend tests
run: sudo docker-compose --env-file .env-ci run frontend yarn test
- name: Check if files have been changed in the frontend
uses: actions/[email protected]
id: frontend-changed
with:
result-encoding: string
script: |
const result = await github.pulls.listFiles({
owner: context.payload.repository.owner.login,
repo: context.payload.repository.name,
pull_number: context.payload.number,
per_page: 100
})
const frontendChanged = result.data.filter(f => f.filename.startsWith("frontend/") || f.filename.startsWith(".github") || f.filename.startsWith("docker-compose") || f.filename.startsWith(".env-ci")).length > 0
console.log("Frontend changed: ", frontendChanged)
return frontendChanged
- name: Checkout repository
if: ${{ steps.frontend-changed.outputs.result == 'true' }}
uses: actions/checkout@v3

- name: Run frontend tests
run: sudo docker-compose --env-file .env-ci run frontend yarn test

0 comments on commit 94c48c9

Please sign in to comment.