@@ -20,6 +20,36 @@ permissions:
2020 contents : read
2121
2222jobs :
23+ classify :
24+ # Classifies the pull request change range before any validation
25+ # runs. Only an explicit documentation-only allowlist match can
26+ # skip expensive jobs, and only for pull_request events; a failed
27+ # or missing classification fails safe to full validation. The
28+ # validation-gate job below audits this decision on every run.
29+ runs-on : ubuntu-latest
30+ outputs :
31+ category : ${{ steps.classify.outputs.category }}
32+ reason : ${{ steps.classify.outputs.reason }}
33+ reason-code : ${{ steps.classify.outputs.reason-code }}
34+ changed-files : ${{ steps.classify.outputs.changed-files }}
35+ allowlist-fingerprint : ${{ steps.classify.outputs.allowlist-fingerprint }}
36+ steps :
37+ - name : Checkout code
38+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
39+ with :
40+ # Classification resolves the merge base from history.
41+ fetch-depth : 0
42+ # This job never pushes — don't persist the GITHUB_TOKEN.
43+ persist-credentials : false
44+ - name : Classify changed files
45+ id : classify
46+ uses : ./.github/actions/classify-changes
47+ with :
48+ event-name : ${{ github.event_name }}
49+ head-sha : ${{ github.sha }}
50+ force-full-label : ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ci:full-validation') }}
51+ force-full-variable : ${{ vars.ZOO_CODE_REQUIRE_FULL_VALIDATION == 'true' }}
52+
2353 dependency-review :
2454 runs-on : ubuntu-latest
2555 # Only meaningful for PRs — validates the dependency diff of the pull
6595 exit 1
6696 fi
6797
98+ format-check :
99+ # Always runs, including documentation-only pull requests: Prettier
100+ # checks every Markdown file, so formatting validation must never be
101+ # reduced by classification. This job also validates the classifier
102+ # and gate logic on every run.
103+ runs-on : ubuntu-latest
104+ steps :
105+ - name : Checkout code
106+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
107+ - name : Setup Node.js and pnpm
108+ uses : ./.github/actions/setup-node-pnpm
109+ with :
110+ install-args : " --frozen-lockfile"
111+ - name : Check formatting
112+ run : pnpm format:check
113+ - name : Test change classification and validation gate
114+ run : pnpm test:change-gate
115+
68116 check-translations :
117+ needs : classify
118+ # Fail-safe: only a successful documentation-only classification on
119+ # a pull request skips this job. Everything else runs unchanged.
120+ if : ${{ !cancelled() && (needs.classify.result != 'success' || github.event_name != 'pull_request' || needs.classify.outputs.category != 'docs-only') }}
69121 runs-on : ubuntu-latest
70122 steps :
71123 - name : Checkout code
80132 run : node scripts/check-i18n-interpolation.js
81133
82134 knip :
135+ # Intentionally ungated: the repository invariant test requires the
136+ # knip job to run without conditions or allowed failure.
83137 runs-on : ubuntu-latest
84138 steps :
85139 - name : Checkout code
@@ -96,6 +150,10 @@ jobs:
96150 run : pnpm knip:production
97151
98152 compile :
153+ needs : classify
154+ # Fail-safe: only a successful documentation-only classification on
155+ # a pull request skips this job. Everything else runs unchanged.
156+ if : ${{ !cancelled() && (needs.classify.result != 'success' || github.event_name != 'pull_request' || needs.classify.outputs.category != 'docs-only') }}
99157 runs-on : ubuntu-latest
100158 steps :
101159 - name : Checkout code
@@ -104,8 +162,6 @@ jobs:
104162 uses : ./.github/actions/setup-node-pnpm
105163 with :
106164 install-args : " --frozen-lockfile"
107- - name : Check formatting
108- run : pnpm format:check
109165 - name : Lint
110166 run : pnpm lint
111167 - name : Check types
@@ -131,7 +187,8 @@ jobs:
131187
132188 build-vsix :
133189 name : Build test VSIX
134- if : github.event_name == 'pull_request'
190+ needs : classify
191+ if : ${{ !cancelled() && github.event_name == 'pull_request' && (needs.classify.result != 'success' || needs.classify.outputs.category != 'docs-only') }}
135192 runs-on : ubuntu-latest
136193 steps :
137194 - name : Checkout code
@@ -158,6 +215,10 @@ jobs:
158215
159216 unit-test :
160217 name : platform-unit-test (${{ matrix.name }})
218+ needs : classify
219+ # Fail-safe: only a successful documentation-only classification on
220+ # a pull request skips this job. Everything else runs unchanged.
221+ if : ${{ !cancelled() && (needs.classify.result != 'success' || github.event_name != 'pull_request' || needs.classify.outputs.category != 'docs-only') }}
161222 runs-on : ${{ matrix.os }}
162223 concurrency :
163224 # Duplicate runs for one commit must not race the OS-specific Turbo cache save.
@@ -317,3 +378,49 @@ jobs:
317378 packages/core/coverage/unit/lcov.info
318379 packages/core/coverage/integration/lcov.info
319380 retention-days : 7
381+
382+ validation-gate :
383+ # Always-running required gate for change-based validation. It
384+ # rejects a missing or failed classification, validation jobs that
385+ # did not run when full validation was required, jobs that ran when
386+ # a documentation-only skip was expected, and a classifier replay
387+ # that disagrees with the recorded classification. It also records
388+ # the classification, the skipped work, runner minutes, and the
389+ # required-check completion time in the job summary.
390+ if : always()
391+ needs :
392+ - classify
393+ - dependency-review
394+ - invisible-chars
395+ - format-check
396+ - check-translations
397+ - knip
398+ - compile
399+ - build-vsix
400+ - unit-test
401+ runs-on : ubuntu-latest
402+ permissions :
403+ contents : read
404+ actions : read
405+ steps :
406+ - name : Checkout code
407+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
408+ with :
409+ # The gate replays the classifier against the same range.
410+ fetch-depth : 0
411+ # This job never pushes — don't persist the GITHUB_TOKEN.
412+ persist-credentials : false
413+ - name : Run validation gate
414+ env :
415+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
416+ NEEDS_JSON : ${{ toJSON(needs) }}
417+ EVENT_NAME : ${{ github.event_name }}
418+ PR_DRAFT : ${{ github.event.pull_request.draft }}
419+ RUN_ID : ${{ github.run_id }}
420+ HEAD_SHA : ${{ github.sha }}
421+ FORCE_FULL_LABEL : ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ci:full-validation') }}
422+ FORCE_FULL_VARIABLE : ${{ vars.ZOO_CODE_REQUIRE_FULL_VALIDATION == 'true' }}
423+ WATCHED_JOBS : dependency-review:pr-only:ungated,invisible-chars:always:ungated,format-check:always:ungated,check-translations:always:gated,knip:always:ungated,compile:always:gated,build-vsix:pr-only:gated,unit-test:always:gated
424+ run : |
425+ BASE_SHA="$(git rev-parse "${HEAD_SHA}^1")"
426+ node scripts/change-gate.mjs ci --base "$BASE_SHA" --head "$HEAD_SHA"
0 commit comments