From 0676f3897844b3635c8777998990bcbf80306f82 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Mon, 1 Aug 2022 19:11:12 +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 Same for CodeQL and python files Signed-off-by: Adam Warner --- .github/workflows/codeql-analysis.yml | 21 +++++++++++++++++++++ .github/workflows/test.yml | 15 ++++++++++++--- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 2c844337..644d28c8 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -13,7 +13,28 @@ on: - cron: '32 11 * * 6' jobs: + # JOB to run change detection + changes: + runs-on: ubuntu-latest + # Set job outputs to values from filter step + outputs: + python: ${{ steps.filter.outputs.python }} + steps: + - + name: Checkout Repo + uses: actions/checkout@v3.0.2 + - + name: Check which files have been touched + uses: dorny/paths-filter@v2.10.2 + id: filter + with: + filters: | + python: + - 'test/*.py' + analyze: + needs: changes + if: ${{ needs.changes.outputs.python == 'true' }} name: Analyze runs-on: ubuntu-latest diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index db17824d..03fb082b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,10 +17,10 @@ jobs: steps: - name: Checkout Repo - uses: actions/checkout@v3 + uses: actions/checkout@v3.0.2 - name: Check which files have been touched - uses: dorny/paths-filter@v2 + uses: dorny/paths-filter@v2.10.2 id: filter with: filters: | @@ -31,6 +31,7 @@ jobs: - 'test/**' - 'gravity.sh' - 'pihole' + - '.github/workflows/test.yml' smoke-tests: if: github.event.pull_request.draft == false @@ -62,7 +63,7 @@ jobs: distro-test: needs: [ smoke-tests, changes ] - if: ${{ github.event.pull_request.draft == false && needs.changes.outputs.requires-distro-test == 'true' }} + if: ${{ github.event.pull_request.draft == false }} runs-on: ubuntu-latest strategy: fail-fast: false @@ -73,15 +74,23 @@ jobs: steps: - name: Checkout repository + if: ${{ needs.changes.outputs.requires-distro-test == 'true' }} uses: actions/checkout@v3.0.2 - name: Set up Python 3.8 + if: ${{ needs.changes.outputs.requires-distro-test == 'true' }} uses: actions/setup-python@v4.1.0 with: python-version: 3.8 - name: Install dependencies + if: ${{ needs.changes.outputs.requires-distro-test == 'true' }} run: pip install -r test/requirements.txt - name: Test with tox + if: ${{ needs.changes.outputs.requires-distro-test == 'true' }} run: tox -c test/tox.${DISTRO}.ini + - + name: Passed with nothing to do + if: ${{ needs.changes.outputs.requires-distro-test == 'false' }} + run: echo "Nothing to test!"