11# ============================================================================
22# CI POLICY (maintainer decision — do not change in a contributor PR)
3- # * Pull requests run ONLY the fast Ubuntu subset.
3+ # * Pull requests run ONLY the fast Ubuntu subset (default: gates + `test changed`) .
44# * Full cross-platform (macOS/Windows) CI runs ONLY via manual
55# workflow_dispatch and on push to main/preview (release lines).
66# * NEVER add a dev push trigger or pull_request runs for macOS/Windows jobs.
2525 # carry contributor prefixes (`fix/`, `feat/`, `agent/`) as readily as
2626 # `codex/`, and contributor stacks need CI most. The `changes` job below is
2727 # the real scope gate, using the same allowlist as the push trigger. Safe to
28- # widen here
29- # because this workflow is `pull_request` (not `pull_request_target`),
28+ # widen here because this workflow is `pull_request` (not `pull_request_target`),
3029 # declares `contents: read`, and reads no secrets.
3130 #
32- #
3331 # Pull requests run only the fast Ubuntu subset. Every macOS and Windows
3432 # job (and the macOS/Windows legs of the keyring, npm-global, setup-action
3533 # and remote-helper matrices) is skipped on `pull_request` and runs after
9492permissions :
9593 contents : read
9694
97- # Retrigger CI after dir-fsync / oauth deadline follow-ups (tip 34a1ac46).
9895concurrency :
9996 # `push` and `pull_request` want supersession: a newer head on the same ref
10097 # makes the older one irrelevant, and cancelling it saves an hour of runners
@@ -216,6 +213,7 @@ jobs:
216213 # of silently making every expensive job skip.
217214 ci : ${{ steps.scope.outputs.ci }}
218215 desktop : ${{ steps.scope.outputs.desktop }}
216+ fast : ${{ steps.lane.outputs.fast }} # true: `test changed` replaces the four shards
219217 native : ${{ steps.matrices.outputs.native }}
220218 # Matrix include lists for keyring-smoke and npm-global-smoke, built and
221219 # shape-checked by the same validation step as `native`.
@@ -590,6 +588,15 @@ jobs:
590588 esac
591589 done
592590
591+ - name : Choose the pull request test lane
592+ id : lane
593+ shell : bash
594+ env :
595+ EVENT_NAME : ${{ github.event_name }}
596+ CI_SCOPE : ${{ steps.scope.outputs.ci }}
597+ FULL_LABEL : ${{ contains(github.event.pull_request.labels.*.name, 'ci:full') }}
598+ run : bash scripts/ci/select-test-lane.sh
599+
593600 - name : Decide whether the Windows shards run
594601 id : windows
595602 shell : bash
@@ -647,7 +654,7 @@ jobs:
647654 test :
648655 name : test ${{ matrix.shard }}/4
649656 needs : changes
650- if : github.event_name != 'pull_request' || needs.changes.outputs.ci == 'true'
657+ if : github.event_name != 'pull_request' || ( needs.changes.outputs.ci == 'true' && needs.changes.outputs.fast != 'true')
651658 runs-on : ubuntu-latest
652659 # A quarter of the suite. A shard that needs longer than this is wedged, not
653660 # slow — the old 30-minute ceiling was margin for the Windows leg, which no
@@ -710,6 +717,27 @@ jobs:
710717 TEST_SHARD : ${{ matrix.shard }}/4
711718 run : bash scripts/ci/run-bun-test-batches.sh "$TEST_SHARD"
712719
720+ # Fast lane: import-graph tests for the diff; the batched dev dispatch is the backstop.
721+ test-changed :
722+ name : test changed
723+ needs : changes
724+ if : github.event_name == 'pull_request' && needs.changes.outputs.fast == 'true'
725+ runs-on : ubuntu-latest
726+ timeout-minutes : 30
727+ steps :
728+ - uses : actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
729+ with :
730+ persist-credentials : false
731+ ref : ${{ needs.changes.outputs.checkout_ref }}
732+ fetch-depth : 2 # merge commit + base tip, which the selection diffs against
733+ - uses : ./.github/actions/setup-project-bun
734+ with :
735+ role : test-runner # See the Bun roles contract above test.
736+ - name : Install dependencies and build the GUI the tests serve
737+ run : bun install --frozen-lockfile && cd gui && bun install --frozen-lockfile && bun run build
738+ - name : Test the files this pull request reaches
739+ run : bash scripts/ci/run-changed-tests.sh
740+
713741 # Bun 1.3.14 has shown a Linux isolate/epoll race around the storage-policy
714742 # harness. Keep the entire six-file family in one fresh process so a runtime
715743 # failure is bounded to this job instead of poisoning a general test shard.
@@ -1750,7 +1778,7 @@ jobs:
17501778 # direct dependencies only, so a failing `select-windows-runner` would
17511779 # otherwise reach this gate as nothing at all while its dependents report
17521780 # `skipped`, which is the shape the step below is written to catch.
1753- needs : [changes, select-windows-runner, test, storage-policy, api-usage, gates, platform-macos, macos-control, platform-windows, keyring-smoke, docker-smoke, docs-site-build, structure-gate, privacy-gate, npm-global-smoke, widget, desktop-shell, setup-action, remote-helper]
1781+ needs : [changes, select-windows-runner, test, test-changed, storage-policy, api-usage, gates, platform-macos, macos-control, platform-windows, keyring-smoke, docker-smoke, docs-site-build, structure-gate, privacy-gate, npm-global-smoke, widget, desktop-shell, setup-action, remote-helper]
17541782 runs-on : ubuntu-latest
17551783 timeout-minutes : 5
17561784 permissions :
@@ -1766,6 +1794,7 @@ jobs:
17661794 EVENT_NAME : ${{ github.event_name }}
17671795 LANE : ${{ github.event.inputs.lane }}
17681796 CHANGES_CI : ${{ needs.changes.outputs.ci }}
1797+ CHANGES_FAST : ${{ needs.changes.outputs.fast }}
17691798 CHANGES_PACKAGING : ${{ needs.changes.outputs.packaging }}
17701799 CHANGES_DOCS : ${{ needs.changes.outputs.docs }}
17711800 CHANGES_STRUCTURE : ${{ needs.changes.outputs.structure }}
@@ -1796,6 +1825,12 @@ jobs:
17961825 if [ "$EVENT_NAME" = "pull_request" ] && [ "$CHANGES_CI" != "true" ]; then
17971826 scoped=not-requested
17981827 fi
1828+ full_tests=$scoped # the fast lane swaps the shards for test changed; unset = full
1829+ changed_tests=not-requested
1830+ if [ "$EVENT_NAME" = "pull_request" ] && [ "$scoped" = requested ] && [ "${CHANGES_FAST:-false}" = "true" ]; then
1831+ full_tests=not-requested
1832+ changed_tests=requested
1833+ fi
17991834 # platform-macos and widget never run on a pull request (macOS runs after merge).
18001835 # desktop-shell (ubuntu) carries the ordinary scope gate AND the native or
18011836 # package-E2E path filters. This mirrors those expressions exactly; where it
@@ -1866,7 +1901,7 @@ jobs:
18661901
18671902 # One line per job, mirroring that job's own `if:`. Adding a job to this workflow
18681903 # without adding it here fails the gate by name rather than passing unnoticed.
1869- GATED_JOBS="changes select-windows-runner test storage-policy api-usage gates"
1904+ GATED_JOBS="changes select-windows-runner test test-changed storage-policy api-usage gates"
18701905 GATED_JOBS="$GATED_JOBS platform-macos keyring-smoke docker-smoke npm-global-smoke"
18711906 GATED_JOBS="$GATED_JOBS macos-control platform-windows docs-site-build"
18721907 GATED_JOBS="$GATED_JOBS structure-gate widget"
@@ -1877,7 +1912,9 @@ jobs:
18771912 expected_for() {
18781913 case "$1" in
18791914 changes|select-windows-runner) echo requested ;;
1880- test|storage-policy|api-usage|gates)
1915+ test) echo "$full_tests" ;;
1916+ test-changed) echo "$changed_tests" ;;
1917+ storage-policy|api-usage|gates)
18811918 echo "$scoped" ;;
18821919 docker-smoke) echo "$docker" ;;
18831920 keyring-smoke) echo "$keyring" ;;
0 commit comments