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 <me@adamwarner.co.uk>
pull/4852/head
Adam Warner 2 years ago
parent 8f7f92cd23
commit 0676f38978
No known key found for this signature in database
GPG Key ID: 872950F3ECF2B173

@ -13,7 +13,28 @@ on:
- cron: '32 11 * * 6' - cron: '32 11 * * 6'
jobs: 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: analyze:
needs: changes
if: ${{ needs.changes.outputs.python == 'true' }}
name: Analyze name: Analyze
runs-on: ubuntu-latest runs-on: ubuntu-latest

@ -17,10 +17,10 @@ jobs:
steps: steps:
- -
name: Checkout Repo name: Checkout Repo
uses: actions/checkout@v3 uses: actions/checkout@v3.0.2
- -
name: Check which files have been touched name: Check which files have been touched
uses: dorny/paths-filter@v2 uses: dorny/paths-filter@v2.10.2
id: filter id: filter
with: with:
filters: | filters: |
@ -31,6 +31,7 @@ jobs:
- 'test/**' - 'test/**'
- 'gravity.sh' - 'gravity.sh'
- 'pihole' - 'pihole'
- '.github/workflows/test.yml'
smoke-tests: smoke-tests:
if: github.event.pull_request.draft == false if: github.event.pull_request.draft == false
@ -62,7 +63,7 @@ jobs:
distro-test: distro-test:
needs: [ smoke-tests, changes ] 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 runs-on: ubuntu-latest
strategy: strategy:
fail-fast: false fail-fast: false
@ -73,15 +74,23 @@ jobs:
steps: steps:
- -
name: Checkout repository name: Checkout repository
if: ${{ needs.changes.outputs.requires-distro-test == 'true' }}
uses: actions/checkout@v3.0.2 uses: actions/checkout@v3.0.2
- -
name: Set up Python 3.8 name: Set up Python 3.8
if: ${{ needs.changes.outputs.requires-distro-test == 'true' }}
uses: actions/setup-python@v4.1.0 uses: actions/setup-python@v4.1.0
with: with:
python-version: 3.8 python-version: 3.8
- -
name: Install dependencies name: Install dependencies
if: ${{ needs.changes.outputs.requires-distro-test == 'true' }}
run: pip install -r test/requirements.txt run: pip install -r test/requirements.txt
- -
name: Test with tox name: Test with tox
if: ${{ needs.changes.outputs.requires-distro-test == 'true' }}
run: tox -c test/tox.${DISTRO}.ini 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!"

Loading…
Cancel
Save