From 8f7f92cd2343ec5d28e4b96a888f0a5d38808b7d Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Mon, 1 Aug 2022 18:48:52 +0100 Subject: [PATCH] Only run the full test suite if required files are touched. This prevents the whole workflow from running for meta/readme changes Signed-off-by: Adam Warner --- .github/workflows/test.yml | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 177a24ba..db17824d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,6 +8,30 @@ permissions: contents: read jobs: + # JOB to run change detection + changes: + runs-on: ubuntu-latest + # Set job outputs to values from filter step + outputs: + requires-distro-test: ${{ steps.filter.outputs.requires-distro-test }} + steps: + - + name: Checkout Repo + uses: actions/checkout@v3 + - + name: Check which files have been touched + uses: dorny/paths-filter@v2 + id: filter + with: + filters: | + requires-distro-test: + - 'advanced/**' + - 'automated install/**' + - 'manpages/**' + - 'test/**' + - 'gravity.sh' + - 'pihole' + smoke-tests: if: github.event.pull_request.draft == false runs-on: ubuntu-latest @@ -17,6 +41,7 @@ jobs: uses: actions/checkout@v3.0.2 - name: Check scripts in repository are executable + if: ${{ needs.changes.outputs.requires-distro-test == 'true' }} run: | IFS=$'\n'; for f in $(find . -name '*.sh'); do if [[ ! -x $f ]]; then echo "$f is not executable" && FAIL=1; fi ;done @@ -35,11 +60,10 @@ jobs: name: Run editorconfig-checker run: editorconfig-checker - distro-test: - if: github.event.pull_request.draft == false + needs: [ smoke-tests, changes ] + if: ${{ github.event.pull_request.draft == false && needs.changes.outputs.requires-distro-test == 'true' }} runs-on: ubuntu-latest - needs: smoke-tests strategy: fail-fast: false matrix: