Skip to content

Commit b91c666

Browse files
committed
avoid running github jobs if not relevant
1 parent c23b067 commit b91c666

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

.github/workflows/gapic-generator-tests.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,27 @@ env:
2323
ALL_PYTHON: "['3.9', '3.10', '3.11', '3.12', '3.13', '3.14']"
2424

2525
jobs:
26+
check_changes:
27+
# We use a job-level 'if' with dorny/paths-filter because GitHub's top-level
28+
# 'on: pull_request: paths' can be bypassed during repository-wide migrations
29+
# or structural changes. This ensures these specialized (and heavy) matrix
30+
# jobs stay silent on PRs that do not touch the generator.
31+
runs-on: ubuntu-latest
32+
outputs:
33+
run_generator: ${{ steps.filter.outputs.generator }}
34+
steps:
35+
- uses: actions/checkout@v4
36+
- uses: dorny/paths-filter@v3
37+
id: filter
38+
with:
39+
filters: |
40+
generator:
41+
- 'packages/gapic-generator/**'
42+
- '.github/workflows/gapic-generator-tests.yml'
43+
2644
# Preserve the workaround for env variables in matrix
2745
python_config:
46+
needs: check_changes
2847
runs-on: ubuntu-latest
2948
outputs:
3049
all_python: ${{ env.ALL_PYTHON }}
@@ -34,7 +53,7 @@ jobs:
3453
- run: echo "Initializing config"
3554

3655
showcase-unit:
37-
needs: python_config
56+
needs: [check_changes, python_config]
3857
strategy:
3958
fail-fast: false
4059
matrix:
@@ -64,7 +83,7 @@ jobs:
6483
nox -s showcase_unit${{ matrix.variant }}-${{ matrix.python }}
6584
6685
goldens:
67-
needs: python_config
86+
needs: [check_changes, python_config]
6887
runs-on: ubuntu-latest
6988
steps:
7089
- uses: actions/checkout@v5
@@ -83,7 +102,7 @@ jobs:
83102
done
84103
85104
fragment-snippet:
86-
needs: python_config
105+
needs: [check_changes, python_config]
87106
strategy:
88107
matrix:
89108
python: ["3.10", "3.14"]

0 commit comments

Comments
 (0)