Skip to content

Commit 593bb23

Browse files
ci: no-op heavy jobs on version-bump PRs so matrix checks report (PER-9560)
1 parent 1db2f59 commit 593bb23

1 file changed

Lines changed: 42 additions & 23 deletions

File tree

.github/workflows/windows.yml

Lines changed: 42 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,42 +14,51 @@ jobs:
1414
name: Detect version-only changes
1515
runs-on: ubuntu-latest
1616
outputs:
17-
version_only: ${{ steps.filter.outputs.version_only }}
17+
skip_heavy: ${{ steps.decide.outputs.skip_heavy }}
1818
steps:
19-
- name: Check the PR changes only version files
20-
id: filter
21-
if: github.event_name == 'pull_request'
19+
- name: Decide whether to skip the heavy test suites
20+
id: decide
2221
env:
2322
GH_TOKEN: ${{ github.token }}
23+
EVENT: ${{ github.event_name }}
24+
HEAD_REF: ${{ github.head_ref }}
25+
AUTHOR: ${{ github.event.pull_request.user.login }}
2426
PR: ${{ github.event.pull_request.number }}
2527
REPO: ${{ github.repository }}
2628
run: |
27-
if ! files=$(gh api "repos/$REPO/pulls/$PR/files" --paginate --jq '.[].filename'); then
28-
echo "Could not list PR files — running full CI to be safe."
29-
echo "version_only=false" >> "$GITHUB_OUTPUT"
30-
exit 0
31-
fi
32-
printf 'Changed files:\n%s\n' "$files"
33-
# version_only=true only if EVERY changed file is lerna.json or a top-level
34-
# packages/<pkg>/package.json (exactly what version-bump.yml commits).
35-
others=$(printf '%s\n' "$files" | grep -vE '^(lerna\.json|packages/[^/]+/package\.json)$' || true)
36-
if [ -n "$files" ] && [ -z "$others" ]; then
37-
echo "version_only=true" >> "$GITHUB_OUTPUT"
38-
else
39-
echo "version_only=false" >> "$GITHUB_OUTPUT"
29+
# Skip the heavy matrices only for automated version-bump PRs: a
30+
# github-actions[bot] PR on a release/* branch whose diff is confined to
31+
# lerna.json + packages/<pkg>/package.json (exactly what version-bump.yml
32+
# commits). The jobs below still RUN (so the matrix expands and every
33+
# required "Test @percy/<pkg>" check is created/reported) — only their
34+
# work steps no-op. Fail-safe: anything unexpected -> skip_heavy=false ->
35+
# full CI runs (PER-9560).
36+
skip=false
37+
if [ "$EVENT" = "pull_request" ] && [ "$AUTHOR" = "github-actions[bot]" ] && printf '%s' "$HEAD_REF" | grep -q '^release/'; then
38+
if files=$(gh api "repos/$REPO/pulls/$PR/files" --paginate --jq '.[].filename'); then
39+
printf 'Changed files:\n%s\n' "$files"
40+
others=$(printf '%s\n' "$files" | grep -vE '^(lerna\.json|packages/[^/]+/package\.json)$' || true)
41+
if [ -n "$files" ] && [ -z "$others" ]; then skip=true; fi
42+
else
43+
echo "Could not list PR files — running full CI to be safe."
44+
fi
4045
fi
46+
echo "skip_heavy=$skip" >> "$GITHUB_OUTPUT"
47+
echo "skip_heavy=$skip"
4148
4249
build:
4350
name: Build
4451
needs: [changes]
45-
if: ${{ !(startsWith(github.head_ref, 'release/') && github.event.pull_request.user.login == 'github-actions[bot]' && needs.changes.outputs.version_only == 'true') }}
4652
runs-on: windows-latest
4753
steps:
4854
- uses: actions/checkout@v5
55+
if: needs.changes.outputs.skip_heavy != 'true'
4956
- uses: actions/setup-node@v3
57+
if: needs.changes.outputs.skip_heavy != 'true'
5058
with:
5159
node-version: 14
5260
- uses: actions/cache@v3
61+
if: needs.changes.outputs.skip_heavy != 'true'
5362
with:
5463
path: |
5564
node_modules
@@ -62,17 +71,19 @@ jobs:
6271
restore-keys: >
6372
${{ runner.os }}/node-14/
6473
${{ hashFiles('.github/.cache-key') }}/
65-
- run: yarn
66-
- run: yarn build
74+
- if: needs.changes.outputs.skip_heavy != 'true'
75+
run: yarn
76+
- if: needs.changes.outputs.skip_heavy != 'true'
77+
run: yarn build
6778
- uses: actions/upload-artifact@v4
79+
if: needs.changes.outputs.skip_heavy != 'true'
6880
with:
6981
name: dist
7082
path: packages/*/dist
7183

7284
test:
7385
name: Test ${{ matrix.package }}
7486
needs: [build, changes]
75-
if: ${{ !(startsWith(github.head_ref, 'release/') && github.event.pull_request.user.login == 'github-actions[bot]' && needs.changes.outputs.version_only == 'true') }}
7687
strategy:
7788
fail-fast: false
7889
matrix:
@@ -102,10 +113,13 @@ jobs:
102113
CLI_TEST_FAILURES_FILE: ${{ github.workspace }}/.cli-test-failures.json
103114
steps:
104115
- uses: actions/checkout@v5
116+
if: needs.changes.outputs.skip_heavy != 'true'
105117
- uses: actions/setup-node@v3
118+
if: needs.changes.outputs.skip_heavy != 'true'
106119
with:
107120
node-version: 14
108121
- uses: actions/cache@v3
122+
if: needs.changes.outputs.skip_heavy != 'true'
109123
with:
110124
path: |
111125
node_modules
@@ -119,17 +133,22 @@ jobs:
119133
${{ runner.os }}/node-14/
120134
${{ hashFiles('.github/.cache-key') }}/
121135
- uses: actions/download-artifact@v5
136+
if: needs.changes.outputs.skip_heavy != 'true'
122137
with:
123138
name: dist
124139
path: packages
125-
- run: yarn
126-
# First attempt runs the full suite and records any failed specs.
140+
- if: needs.changes.outputs.skip_heavy != 'true'
141+
run: yarn
142+
# First attempt runs the full suite and records any failed specs. Skipped
143+
# (with every other step) on version-bump PRs — see the `changes` job.
127144
- name: Run tests
128145
continue-on-error: true
129146
id: retry0
147+
if: needs.changes.outputs.skip_heavy != 'true'
130148
run: yarn workspace ${{ matrix.package }} test --colors
131149
# Retries re-run ONLY the specs that failed in the previous attempt
132150
# (CLI_TEST_ONLY_FAILED), so a flaky spec costs seconds, not ~60 min.
151+
# (These auto-skip when retry0 is skipped, so they need no extra guard.)
133152
- name: Run tests Retry (1/4)
134153
continue-on-error: true
135154
id: retry1

0 commit comments

Comments
 (0)