Skip to content

Commit 3e4751f

Browse files
tests: always trigger gapic specialized tests (#17636)
This PR adds a new `Gapic Generator Specialized tests / status` check, and makes sure it always runs, regardless of whether the generator code was touched. This test is green if all gapic generator tests are skipped or passed, otherwise red This change allows us to mark gapic generator tests as required, so issues don't slip through (see #17632) This PR also uncovered an issue with fragment tests, where they were not being triggered properly, and addresses it as well
1 parent 8feb1b8 commit 3e4751f

1 file changed

Lines changed: 26 additions & 11 deletions

File tree

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

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,8 @@ name: Gapic Generator Specialized Tests
55

66
on:
77
pull_request:
8-
paths:
9-
- 'packages/gapic-generator/**'
10-
- '.github/workflows/gapic-generator-tests.yml'
118
push:
129
branches: [main]
13-
paths:
14-
- 'packages/gapic-generator/**'
1510

1611
concurrency:
1712
group: gapic-gen-${{ github.head_ref || github.run_id }}
@@ -30,11 +25,8 @@ env:
3025
PYO3_USE_ABI3_FORWARD_COMPATIBILITY: "1"
3126

3227
jobs:
28+
# Check if the gapic-generator was changed. If so, execute specialized tests
3329
check_changes:
34-
# We use a job-level 'if' with dorny/paths-filter because GitHub's top-level
35-
# 'on: pull_request: paths' can be bypassed during repository-wide migrations
36-
# or structural changes. This ensures these specialized (and heavy) matrix
37-
# jobs stay silent on PRs that do not touch the generator.
3830
runs-on: ubuntu-latest
3931
outputs:
4032
run_generator: ${{ steps.filter.outputs.generator }}
@@ -59,7 +51,7 @@ jobs:
5951
all_python: ${{ env.ALL_PYTHON }}
6052
latest_stable_python: ${{ env.LATEST_STABLE_PYTHON }}
6153
prerelease_python: ${{ env.PRERELEASE_PYTHON }}
62-
trimmed_python: $${{ env.TRIMMED_PYTHON }}
54+
trimmed_python: ${{ env.TRIMMED_PYTHON }}
6355
steps:
6456
- run: echo "Initializing config for gapic-generator"
6557

@@ -232,7 +224,6 @@ jobs:
232224
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
233225
with:
234226
persist-credentials: false
235-
236227
- name: Cache Bazel files
237228
id: cache-bazel
238229
uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5
@@ -247,3 +238,27 @@ jobs:
247238
# WORKSPACE file is located there.
248239
cd packages/gapic-generator
249240
bazelisk test //tests/integration/... --test_output=errors
241+
242+
# Final job to simplify branch protection rules.
243+
# This job will be reported as 'Success' if all its dependencies either
244+
# pass or are skipped due to path filtering.
245+
status:
246+
needs: [check_changes, python_config, showcase-unit, showcase-mypy, goldens, goldens-prerelease, fragment-snippet, integration]
247+
if: always()
248+
runs-on: ubuntu-latest
249+
steps:
250+
- name: Check all jobs for failure
251+
env:
252+
NEEDS_JSON: ${{ toJson(needs) }}
253+
run: |
254+
# 1. Print a human-readable list of each dependency job and its final status.
255+
echo "Job Results:"
256+
echo "$NEEDS_JSON" | jq -r 'to_entries[] | " - \(.key): \(.value.result)"'
257+
258+
# 2. Evaluate if any job actually failed or was cancelled.
259+
if echo "$NEEDS_JSON" | jq -e 'to_entries[].value | select(.result == "failure" or .result == "cancelled")' >/dev/null; then
260+
echo "Error: One or more required jobs failed or were cancelled."
261+
exit 1
262+
fi
263+
echo "All checks passed or were successfully skipped."
264+

0 commit comments

Comments
 (0)