diff --git a/.github/workflows/backend-test.yml b/.github/workflows/backend-test.yml index 2b87893d4..a737d0e0a 100644 --- a/.github/workflows/backend-test.yml +++ b/.github/workflows/backend-test.yml @@ -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/github-script@0.9.0 + 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 diff --git a/.github/workflows/frontend-test.yml b/.github/workflows/frontend-test.yml index fdb14f20e..218399ef4 100644 --- a/.github/workflows/frontend-test.yml +++ b/.github/workflows/frontend-test.yml @@ -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/github-script@0.9.0 + 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