From 473c53cf1e484b792554b29d86a75ba5316a9a8c Mon Sep 17 00:00:00 2001 From: Ghais Zaher Date: Wed, 16 Aug 2023 22:02:44 +0200 Subject: [PATCH] ci: use `dorny/paths-filter` to filter paths when running go-tests --- .github/workflows/test-required.yml | 37 ----------------------------- .github/workflows/test.yml | 35 +++++++++++++++++++-------- 2 files changed, 25 insertions(+), 47 deletions(-) delete mode 100644 .github/workflows/test-required.yml diff --git a/.github/workflows/test-required.yml b/.github/workflows/test-required.yml deleted file mode 100644 index 7ef2984b6b..0000000000 --- a/.github/workflows/test-required.yml +++ /dev/null @@ -1,37 +0,0 @@ -# For required checks when path filtering doesn;'t trigger the other job -# https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks#handling-skipped-but-required-checks - -name: tester - -on: - push: - branches: - - "main" - paths-ignore: - - '**.go' - - 'go.*' - - '.github/workflows/test.yml' - pull_request: - types: - - opened - - reopened - - synchronize - - ready_for_review - branches: - - "main" - paths-ignore: - - '**.go' - - 'go.*' - - '.github/workflows/test.yml' - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - test: - if: github.event.pull_request.draft == false - name: runner / gotest - runs-on: ubuntu-22.04 - steps: - - run: 'echo "No build required"' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f4074481b8..74d6c88d93 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,10 +4,6 @@ on: push: branches: - "main" - paths: - - '**.go' - - 'go.*' - - '.github/workflows/test.yml' pull_request: types: - opened @@ -16,18 +12,29 @@ on: - ready_for_review branches: - "main" - paths: - - '**.go' - - 'go.*' - - '.github/workflows/test.yml' - + concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: - test: + changes: + outputs: + should-run-tests: ${{ steps.changes.outputs.go == 'true' }} if: github.event.pull_request.draft == false + runs-on: ubuntu-22.04 + steps: + - uses: dorny/paths-filter@v2 + id: changes + with: + filters: | + go: + - '**.go' + - 'go.*' + - '.github/workflows/test.yml' + test: + needs: [changes] + if: needs.changes.outputs.should-run-tests == 'true' name: runner / gotest runs-on: ubuntu-22.04 container: ghcr.io/runatlantis/testing-env:latest @@ -35,3 +42,11 @@ jobs: - uses: actions/checkout@v3 - run: make test-all - run: make check-fmt + + skip-test: + needs: [changes] + if: needs.changes.outputs.should-run-tests == 'false' + name: runner / gotest + runs-on: ubuntu-22.04 + steps: + - run: 'echo "No build required"'