Skip to content

Commit 6d8684a

Browse files
committed
ci(type-check-ui): check out at depth 1 and fetch only the history it reads
type-check-ui drops fetch-depth: 0 for a depth-1 checkout plus the same "Fetch this commit's history and the base branch" step test-plan, test and test-ui already run. All four copies take timeout-minutes: 8, sized from 277 fetches on main and the queue (p99 72 s, max 85 s) against the 11-03 incident factor. A new case pins depth 1, the fetch step's place and its budget across the four jobs; the two type-check-ui pins that read fetch-depth: 0 now read the fetch step, and the drift gate's shallow-clone prescription names it. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jRSntnsNKYKPXp9kFG
1 parent dced781 commit 6d8684a

5 files changed

Lines changed: 106 additions & 19 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,7 @@ jobs:
653653

654654
# The `test` job's step of the same name, verbatim (its comment says why).
655655
- name: Fetch this commit's history and the base branch
656+
timeout-minutes: 8
656657
env:
657658
PR_BASE_REF: ${{ github.event.pull_request.base.ref }}
658659
run: |
@@ -929,7 +930,18 @@ jobs:
929930
# commit, not a branch tip. Three attempts, like the checkout's own fetch,
930931
# then a red step: a selection read from a shallow clone is the silent
931932
# all-packages answer above, never a fallback this job may take quietly.
933+
#
934+
# FETCH BUDGET: 8 minutes, the same in all four copies (`test-plan`,
935+
# `test`, `test-ui`, `type-check-ui`). Read on `main` and the queue over
936+
# 22 runs after this step landed: 277 fetches, all green, p50 50 s,
937+
# p99 72 s, max 85 s. The 2026-11-03 fetch incident
938+
# slowed the full-ref fetch 5.6-6.5x, and this step pulls the whole
939+
# ancestry, so 480 s holds p99 x 6.5 and max x 5.6; three healthy
940+
# attempts plus the two sleeps take 300 s. It fits under `test-plan`'s
941+
# 10-minute wall with that job's measured checkout and body. A fetch
942+
# that hangs ends red here, named, instead of eating the job's wall.
932943
- name: Fetch this commit's history and the base branch
944+
timeout-minutes: 8
933945
env:
934946
PR_BASE_REF: ${{ github.event.pull_request.base.ref }}
935947
run: |
@@ -1029,7 +1041,7 @@ jobs:
10291041
# gives this checkout a `ref:`, where parent^1 becomes the PR's
10301042
# previous commit. `merge-base` is right under BOTH checkouts.
10311043
# - Dropping the variable and letting turbo default to `main`. Measured
1032-
# in a CI-shaped clone: `fetch-depth: 0` populates
1044+
# in a CI-shaped clone: the fetch step above populates
10331045
# `refs/remotes/origin/*`, NOT local heads, so there is no local `main`
10341046
# — and turbo does not error, it silently returns the ENTIRE
10351047
# workspace, untouched packages included. Safe, and the whole
@@ -3590,12 +3602,39 @@ jobs:
35903602
TURBO_RUN_SUMMARY: 'true'
35913603

35923604
steps:
3605+
# Depth 1, then the step below: this job reads HEAD's ancestry and the
3606+
# base branch, and no tag or other head (#22034).
35933607
- name: Checkout repository
35943608
uses: actions/checkout@v7
3595-
with:
3596-
# The affected scope below asks turbo for the packages changed since
3597-
# the base commit, which needs the base's history in the clone.
3598-
fetch-depth: 0
3609+
3610+
# The `test` job's step of the same name, verbatim (its comment says why
3611+
# and sizes the budget). Here the readers are check:lockfile-integrity
3612+
# (`git merge-base origin/<base> HEAD`), check:i18n-drift (the merge base
3613+
# with origin/<base> or origin/main), the affected type-check scope
3614+
# (`turbo --filter=...[BASE]`) and spec's build. On a shallow clone the
3615+
# lockfile alarm finds no merge base and stays green, and the drift check
3616+
# exits red.
3617+
- name: Fetch this commit's history and the base branch
3618+
timeout-minutes: 8
3619+
env:
3620+
PR_BASE_REF: ${{ github.event.pull_request.base.ref }}
3621+
run: |
3622+
refspecs=('+refs/heads/main:refs/remotes/origin/main')
3623+
if [ -n "$PR_BASE_REF" ] && [ "$PR_BASE_REF" != main ]; then
3624+
refspecs+=("+refs/heads/$PR_BASE_REF:refs/remotes/origin/$PR_BASE_REF")
3625+
fi
3626+
head=$(git rev-parse HEAD)
3627+
for attempt in 1 2 3; do
3628+
deepen=()
3629+
if [ "$(git rev-parse --is-shallow-repository)" = true ]; then deepen=(--unshallow); fi
3630+
if git fetch --no-tags "${deepen[@]}" origin "$head" "${refspecs[@]}"; then break; fi
3631+
if [ "$attempt" = 3 ]; then
3632+
echo "::error::Could not fetch $head's history and ${refspecs[*]} after 3 attempts. The package selection reads that history, so this job stops here rather than selecting from a shallow clone."
3633+
exit 1
3634+
fi
3635+
sleep $((attempt * 15))
3636+
done
3637+
echo "History: $(git rev-list --count HEAD) commit(s) behind HEAD, shallow=$(git rev-parse --is-shallow-repository), no tags, refs: $(git for-each-ref --format='%(refname)' refs/remotes | tr '\n' ' ')"
35993638
36003639
- name: Setup Node.js
36013640
uses: actions/setup-node@v7
@@ -3652,9 +3691,9 @@ jobs:
36523691
# request's `pnpm-lock.yaml` may not give any package a second physical
36533692
# copy. The script's header has the mechanism and its boundary.
36543693
#
3655-
# It lives here because this job already checks out with
3656-
# `fetch-depth: 0`, so `origin/<base>` and the merge base are in the
3657-
# clone, and because it runs on every change to `pnpm-lock.yaml` (the
3694+
# It lives here because this job's fetch step already brings HEAD's
3695+
# ancestry and `origin/<base>`, so the merge base is in the clone, and
3696+
# because it runs on every change to `pnpm-lock.yaml` (the
36583697
# `ui` filter lists it). Before the install on purpose: the gate reads
36593698
# two text files with Node builtins only, which Lint UI's pre-install
36603699
# import graph check holds. `pull_request` only, because the gate's
@@ -3898,6 +3937,7 @@ jobs:
38983937
# base...HEAD`) and spec's build. On a shallow clone the select step
38993938
# would not fail: it would warn and run the full suite.
39003939
- name: Fetch this commit's history and the base branch
3940+
timeout-minutes: 8
39013941
env:
39023942
PR_BASE_REF: ${{ github.event.pull_request.base.ref }}
39033943
run: |

‎ui/scripts/__tests__/check-i18n-en-drift.test.ts‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,13 +1170,17 @@ describe('the gate is wired to run', () => {
11701170
expect(step, 'the check runs before dependencies are installed').toBeGreaterThan(install);
11711171
});
11721172

1173-
it('gives that job a full-history checkout, or the merge base does not exist', () => {
1174-
// actions/checkout defaults to depth 1. Without this the gate cannot resolve
1175-
// a base — and by design that is a red build, not a silent pass, so losing
1176-
// this line breaks CI loudly. The pin is here so the reason survives.
1173+
it("fetches HEAD's history and the base branch before it runs, or the merge base does not exist", () => {
1174+
// actions/checkout defaults to depth 1, and the job keeps that default: the
1175+
// fetch step after it brings HEAD's ancestry and origin/<base> (objectstack#22034).
1176+
// Without it the gate cannot resolve a base — and by design that is a red
1177+
// build, not a silent pass, so losing the step breaks CI loudly. The pin is
1178+
// here so the reason survives.
1179+
const fetch = job.indexOf("- name: Fetch this commit's history and the base branch");
11771180
const step = job.indexOf(`run: ${uiRun('check:i18n-drift')}`);
11781181
expect(step, '`type-check-ui` does not run `pnpm --dir ui run check:i18n-drift`').toBeGreaterThan(-1);
1179-
expect(job.slice(0, step)).toContain('fetch-depth: 0');
1182+
expect(fetch, '`type-check-ui` has no step fetching HEAD\'s history and the base branch').toBeGreaterThan(-1);
1183+
expect(fetch, 'the history is fetched after the check runs').toBeLessThan(step);
11801184
});
11811185

11821186
it('is not hidden from the locale packs by ci.yml path filters', () => {

‎ui/scripts/__tests__/check-lockfile-integrity.test.ts‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,14 +218,17 @@ describe('the gate is wired into the root CI (objectstack#26717)', () => {
218218
expect(step()).toContain("if: github.event_name == 'pull_request'");
219219
});
220220

221-
it('checks out deep enough to have a merge base', () => {
222-
// A shallow clone has no merge base, and the script exits 2 rather than
223-
// guess one: a reading that never measured the change.
221+
it('fetches deep enough to have a merge base', () => {
222+
// A shallow clone has no merge base, and the script refuses rather than
223+
// guess one: a reading that never measured the change. The checkout stays
224+
// at depth 1; the fetch step after it brings HEAD's ancestry and
225+
// origin/<base> (objectstack#22034).
224226
const block = withoutComments(jobBlock(rootCi(), JOB));
225227
const checkout = block.indexOf('uses: actions/checkout@');
228+
const fetch = block.indexOf("- name: Fetch this commit's history and the base branch");
226229
expect(checkout).toBeGreaterThan(-1);
227-
expect(block.indexOf('fetch-depth: 0', checkout)).toBeGreaterThan(checkout);
228-
expect(block.indexOf('fetch-depth: 0', checkout)).toBeLessThan(block.indexOf(`- name: ${STEP_NAME}`));
230+
expect(fetch).toBeGreaterThan(checkout);
231+
expect(fetch).toBeLessThan(block.indexOf(`- name: ${STEP_NAME}`));
229232
});
230233

231234
it('⛔ stays an alarm in a required job: continue-on-error, before the install', () => {

‎ui/scripts/__tests__/select-affected-tests.test.ts‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import {
2222
trackedFiles,
2323
} from '../select-affected-tests.mjs';
2424
import { shardTotal } from '../../../scripts/ci-shard-matrix.mjs';
25+
import { parse as parseYaml } from 'yaml';
26+
2527
import { jobBlock, rootCi, triggerBlock, UI_JOBS, uiRun, withoutComments } from './helpers/root-ci';
2628

2729
/**
@@ -600,3 +602,41 @@ describe("the root ci.yml's Test UI job wires the selector fail-open (objectui#1
600602
expect(run).toContain(`pnpm --dir ui exec vitest run --shard=\${{ matrix.shard }}/${shards} --reporter=default --reporter=github-actions "\${filters[@]}"`);
601603
});
602604
});
605+
606+
// objectstack#22034: the four root ci.yml jobs that read git history check out
607+
// at depth 1 and fetch only HEAD's ancestry and the base branch, in one step
608+
// that is the same in all four. `fetch-depth: 0` fetched every head and every
609+
// tag; a checkout that grows it back passes every other gate and silently
610+
// undoes the measurement the fetch step's budget was sized from.
611+
describe("the root ci.yml's history readers check out at depth 1, then fetch (objectstack#22034)", () => {
612+
type Step = { name?: string; uses?: string; with?: Record<string, unknown>; 'timeout-minutes'?: number; run?: string; env?: Record<string, string> };
613+
const jobs = (parseYaml(rootCi()) as { jobs: Record<string, { steps: Step[] }> }).jobs;
614+
const FETCH = "Fetch this commit's history and the base branch";
615+
// Each job's first step that reads history: the fetch must come before it.
616+
const FIRST_READER: Record<string, string> = {
617+
'test-plan': "Plan this run's Test Core shards",
618+
test: "Compute this shard's package set",
619+
[UI_JOBS.test]: 'Select the tests this change affects',
620+
[UI_JOBS.typeCheck]: 'check:lockfile-integrity — compare this pull request\'s lockfile with its merge base',
621+
};
622+
623+
for (const [job, reader] of Object.entries(FIRST_READER)) {
624+
it(`${job}: depth-1 checkout, the fetch step next, then the first reader`, () => {
625+
const steps = jobs[job]?.steps ?? [];
626+
expect(steps.length, `ci.yml has no job ${job}`).toBeGreaterThan(0);
627+
const checkout = steps.findIndex((s) => s.uses?.startsWith('actions/checkout@'));
628+
expect(checkout, `${job} has no actions/checkout step`).toBeGreaterThan(-1);
629+
expect(steps[checkout].with?.['fetch-depth'], `${job}'s checkout sets fetch-depth`).toBeUndefined();
630+
expect(steps[checkout + 1]?.name, `${job}: the step after the checkout is not the fetch`).toBe(FETCH);
631+
const first = steps.findIndex((s) => s.name === reader);
632+
expect(first, `${job} has no step named ${reader}`).toBeGreaterThan(checkout + 1);
633+
expect(steps[checkout + 1]['timeout-minutes']).toBe(8);
634+
});
635+
}
636+
637+
it('the fetch step is one step, the same in all four jobs', () => {
638+
const copies = Object.keys(FIRST_READER).map((job) => jobs[job].steps.find((s) => s.name === FETCH));
639+
for (const copy of copies) expect(copy).toEqual(copies[0]);
640+
expect(copies[0]?.run).toContain('git fetch --no-tags "${deepen[@]}" origin "$head" "${refspecs[@]}"');
641+
});
642+
});

‎ui/scripts/check-i18n-en-drift.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ if (invokedDirectly) {
839839
' answer it confidently. Name a commit that exists in this clone, or pass none and\n' +
840840
' let the merge base with the target branch be found.\n'
841841
: base.shallow
842-
? ' This clone is SHALLOW. In CI, give the checkout `fetch-depth: 0`; locally,\n' +
842+
? ' This clone is SHALLOW. In CI, fetch HEAD\'s history and the base branch after the checkout; locally,\n' +
843843
' run `git fetch --no-tags origin main` (or `git fetch --unshallow`).\n'
844844
: ' Fetch the base branch (`git fetch --no-tags origin main`) and re-run.\n') +
845845
' This is a failure, not a skip: a diff gate with no diff would pass while\n' +

0 commit comments

Comments
 (0)