mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-23 08:31:44 +01:00
Free Tests plans its shards beside the reuse and docs checks (GST-3303) (#4570)
Free Tests on a pull request now starts its test shards after one round of small GitHub-hosted jobs instead of two, because the planner no longer waits for the reuse and docs-only checks. Why: faster PR feedback on the required `free-tests` check. Nothing to do: no check is renamed, and the same tests run. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> Review-Finding: p1/specialist-batched#1 reader=state-machines
This commit is contained in:
1 parent
acb1f4ece9
commit
69e67e264d
12 files changed
+55
-22
No files matched your search
@@ -207,9 +207,14 @@ jobs:
|
||||
read -ra tests <<< "$DOCS_TESTS"
|
||||
bun --no-env-file test --timeout=30000 "${tests[@]}"
|
||||
|
||||
# The planner runs beside reuse and docs-scope instead of after them, so the
|
||||
# shards wait for one round of small jobs, not two (GST-3303: the second
|
||||
# round cost 21 s at p50 and 363 s at p95 of GitHub queue). It only plans:
|
||||
# free-suite and the aggregate still read reuse and docs-scope, so a reused
|
||||
# main push or a docs-only pull request runs no shard. On those runs the
|
||||
# plan and its artifact are unused; scripts/lib/ci-history.ts reads a run
|
||||
# whose only artifact is free-plan as one that ran no shard.
|
||||
free-plan:
|
||||
needs: [reuse, docs-scope]
|
||||
if: ${{ !cancelled() && (needs.reuse.result != 'success' || needs.reuse.outputs.reused != 'true') && !(needs.docs-scope.result == 'success' && needs.docs-scope.outputs.docs_only == 'true') }}
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 5
|
||||
outputs:
|
||||
@@ -587,8 +592,8 @@ jobs:
|
||||
|
||||
free-suite:
|
||||
name: free-suite (${{ matrix.shard }})
|
||||
needs: [free-plan, reuse]
|
||||
if: ${{ !cancelled() && needs.free-plan.result == 'success' && (needs.reuse.result != 'success' || needs.reuse.outputs.reused != 'true') }}
|
||||
needs: [free-plan, reuse, docs-scope]
|
||||
if: ${{ !cancelled() && needs.free-plan.result == 'success' && (needs.reuse.result != 'success' || needs.reuse.outputs.reused != 'true') && !(needs.docs-scope.result == 'success' && needs.docs-scope.outputs.docs_only == 'true') }}
|
||||
runs-on: ${{ needs.free-plan.outputs.runner }}
|
||||
# Per shard, from the plan: runner wall + flaky retry + setup (#3850).
|
||||
timeout-minutes: ${{ matrix.timeout_minutes }}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
"free-tests.yml/free-suite": "bun run scripts/test-free-shards.ts --list"
|
||||
},
|
||||
"run_profiles": {
|
||||
"ci-reuse/free-tests": { "workflow": "free-tests.yml", "events": ["pull_request", "workflow_dispatch"], "jobs": ["free-plan", "typecheck", "quick-bun-default", "cso-macos-launcher", "macos-named-regressions", "cso-windows-launcher", "cso-docker-integration", "free-tests"], "artifact": "tested-tree", "os": "Linux", "skippable": { "jobs": ["free-plan", "typecheck", "quick-bun-default", "cso-macos-launcher", "macos-named-regressions", "cso-windows-launcher", "cso-docker-integration"], "gate": "docs-scope", "scripts": [".github/actions/docs-scope/action.yml", "bin/gstack-docs-only", "lib/docs-only.ts", "lib/review-depth.ts", "lib/ship-policy.ts", "lib/ship-policy-docs-only.ts"] } },
|
||||
"ci-reuse/free-tests": { "workflow": "free-tests.yml", "events": ["pull_request", "workflow_dispatch"], "jobs": ["free-plan", "typecheck", "quick-bun-default", "cso-macos-launcher", "macos-named-regressions", "cso-windows-launcher", "cso-docker-integration", "free-tests"], "artifact": "tested-tree", "os": "Linux", "skippable": { "jobs": ["typecheck", "quick-bun-default", "cso-macos-launcher", "macos-named-regressions", "cso-windows-launcher", "cso-docker-integration"], "gate": "docs-scope", "scripts": [".github/actions/docs-scope/action.yml", "bin/gstack-docs-only", "lib/docs-only.ts", "lib/review-depth.ts", "lib/ship-policy.ts", "lib/ship-policy-docs-only.ts"] } },
|
||||
"ci-reuse/windows-free-tests": { "workflow": "windows-free-tests.yml", "events": ["pull_request", "workflow_dispatch"], "jobs": ["windows-plan", "windows-free-tests"], "artifact": "tested-tree", "os": "Windows" }
|
||||
},
|
||||
"remote_gate_runs": {
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
**Free Tests on pull requests starts its test shards one round of small jobs sooner.** The job that plans the shards now runs beside the reuse and docs-only checks instead of after them, so the shards no longer wait twice for a GitHub-hosted runner (that second wait was 21 seconds at the median and 6 minutes at p95 over the last two weeks). Every shard still waits for both checks, so a reused main push or a docs-only pull request still runs no shard, and the test-health and scorecard reports still leave reused main pushes out of their flake counts.
|
||||
@@ -289,7 +289,7 @@ measured later does not count anything that happened after that week.
|
||||
| Gate runs green / red / cancelled | completed runs of the gate workflow (`workflow_dispatch` by default; `--gate-event any`); cost from the run's `report-verdict-a*` artifact (`collector-outcomes.json` `.verdict.costUsd`), else the `**$N** rule/judge cost` or `cost=$N` line of the PR's verdict comment | green on 95%+ of runs, cancelled near 0, cost known for every run |
|
||||
| Known gate cost per merged PR | known cost / merged PRs; unknown-cost runs make it a floor | known, stable or falling week over week |
|
||||
| Red-train rate | runs whose head branch starts with `--train-prefix`, cancelled excluded; red = conclusion other than success; red backstops and screens shown beside it | under 5% (each red train is a bisect plus a rebuild, about two gates) |
|
||||
| Flaky events | `flake-records-a*` records of the newest gate runs (count, known rerun spend) and `flake-ledger-*` entries of free runs on the default branch; a run whose artifacts cannot be read is counted and named, never scored 0, and a main push that reused its pull request's run (no artifacts, `reuse` job green) is left out and named | 0 repeat cases; under 1 flaky case per 10 gates; free retries under 1% of runs |
|
||||
| Flaky events | `flake-records-a*` records of the newest gate runs (count, known rerun spend) and `flake-ledger-*` entries of free runs on the default branch; a run whose artifacts cannot be read is counted and named, never scored 0, and a main push that reused its pull request's run (no shard artifacts, `reuse` job green) is left out and named | 0 repeat cases; under 1 flaky case per 10 gates; free retries under 1% of runs |
|
||||
| Issues opened / closed | GitHub search, created and closed in the window | closed ≥ opened; nothing severe older than a week |
|
||||
| Releases cut | releases published in the window, drafts excluded | at least one tagged release a week, on schedule |
|
||||
|
||||
|
||||
@@ -1522,8 +1522,9 @@ window thinner than 20 runs in the last 7 days widens to the newest 20 runs, and
|
||||
fewer than 20 runs is report-only. A main push that reused its pull request's
|
||||
run ([CI reuse](pregate.md#ci-reuse)) ran no shards, so it stays out of the
|
||||
window and its denominator, and older runs take its place. Such a run has no
|
||||
artifacts and a green `reuse` job; checking that costs one job listing per
|
||||
run with no artifacts, at most 40 per read. Past that cap, or when a listing
|
||||
shard artifacts (only the planner's `free-plan`, since the planner runs beside
|
||||
`reuse`) and a green `reuse` job; checking that costs one job listing per run
|
||||
with no shard artifacts, at most 40 per read. Past that cap, or when a listing
|
||||
fails, the run counts as before and the report says so.
|
||||
`bun run test:health flake-summary <dir>`
|
||||
prints a run's ledgers as a table. A flaky file is fixed at source; the retry
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
* that failed once and passed its one rerun) and flake-ledger-* artifacts
|
||||
* of <free workflow> runs on <base> (free-suite serial retries); the same
|
||||
* two sources the daily flaky pass reads; a main push that reused its PR's
|
||||
* run (no artifacts, `reuse` job green; reuseChecker) is left out
|
||||
* run (no shard artifacts, `reuse` job green; reuseChecker) is left out
|
||||
* issues search/issues created / closed inside the window
|
||||
* releases releases published inside the window (drafts excluded)
|
||||
*
|
||||
|
||||
@@ -267,10 +267,11 @@ export const REUSE_LOOKUPS_MAX = 40;
|
||||
|
||||
/**
|
||||
* Finds runs that reused their merged pull request's verified run (#3709): such
|
||||
* a run uploads no artifact and its `reuse` job succeeds, because every suite
|
||||
* a run uploads no artifact but the planner's `free-plan` (the planner runs
|
||||
* beside `reuse`, GST-3303) and its `reuse` job succeeds, because every suite
|
||||
* job was skipped. It holds no flake evidence, so flake counts leave it out of
|
||||
* their runs and their denominator (#3725). A run with any artifact costs no
|
||||
* call. A run with none costs one job listing, at most REUSE_LOOKUPS_MAX per
|
||||
* their runs and their denominator (#3725). A run with any other artifact costs
|
||||
* no call. A run with none costs one job listing, at most REUSE_LOOKUPS_MAX per
|
||||
* checker; past the cap, or when the listing fails, the run counts as it did
|
||||
* before #3725 and note() says so.
|
||||
*/
|
||||
@@ -280,7 +281,7 @@ export function reuseChecker(client: GhClient, repo: string) {
|
||||
let reason = '';
|
||||
return {
|
||||
reused(run: Pick<CiRun, 'id' | 'attempt'>, artifactNames: string[]): boolean {
|
||||
if (artifactNames.length) return false;
|
||||
if (artifactNames.some(name => name !== 'free-plan')) return false;
|
||||
if (lookups >= REUSE_LOOKUPS_MAX) { unchecked++; reason ||= `cap of ${REUSE_LOOKUPS_MAX} job listings reached`; return false; }
|
||||
lookups++;
|
||||
try {
|
||||
@@ -288,7 +289,7 @@ export function reuseChecker(client: GhClient, repo: string) {
|
||||
} catch (error) { unchecked++; reason ||= unavailableReason(error); return false; }
|
||||
},
|
||||
note: (): string | undefined => (unchecked
|
||||
? `${unchecked} run(s) with no artifacts not checked for main-push reuse (${reason}); counted as before #3725` : undefined),
|
||||
? `${unchecked} run(s) with no shard artifacts not checked for main-push reuse (${reason}); counted as before #3725` : undefined),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -292,7 +292,7 @@ export function collectHealth(inputs: HealthInputs): HealthReport {
|
||||
metrics.push(...censusMetrics(inputs, artifactDirs));
|
||||
|
||||
const flakes = attempt(() => readCiFlakeLedgers({ client, repo, sinceDays, now, cacheDir }));
|
||||
metrics.push(metric('free-flaky-pass-rate', 'Free-suite flaky-pass rate', 'share of main free-tests runs (success or failure) with at least one flaky-pass ledger entry; per-file rate = runs with that file / runs; a main push that reused its pull request\'s run (no artifacts, `reuse` job green) is left out', () => {
|
||||
metrics.push(metric('free-flaky-pass-rate', 'Free-suite flaky-pass rate', 'share of main free-tests runs (success or failure) with at least one flaky-pass ledger entry; per-file rate = runs with that file / runs; a main push that reused its pull request\'s run (no shard artifacts, `reuse` job green) is left out', () => {
|
||||
const window = need(flakes);
|
||||
return { value: `${pct(window.runs ? window.flakyRuns / window.runs : 0)} (${window.flakyRuns}/${window.runs} main runs since ${window.since.slice(0, 10)} needed the retry pass; ${window.files.length} file(s)${flakeWindowNotes(window)})`,
|
||||
detail: window.files.slice(0, 15).map(file => `${file.file}: ${file.flakyRuns}/${window.runs} runs (${pct(file.rate)})${file.failing ? ' FAIL > 5%' : ''}`) };
|
||||
|
||||
@@ -19,7 +19,7 @@ const ROOT = path.resolve(import.meta.dir, '..');
|
||||
const read = (rel: string) => fs.readFileSync(path.join(ROOT, rel), 'utf8');
|
||||
const MAIN_PUSH = "github.event_name == 'push' && github.ref == 'refs/heads/main'";
|
||||
const FILES = {
|
||||
'free-tests.yml': { aggregate: 'free-tests', profile: 'ci-reuse/free-tests', plan: 'free-plan', exempt: ['trunk-dynamic-ci', 'trunk-flaky-tests', 'docs-scope', 'docs-lane'], observer: 'trunk-dynamic-ci', uploader: 'trunk-flaky-tests', manual: false, reuseIf: `(${MAIN_PUSH}) || github.event_name == 'pull_request'`, pullRequest: true, docsScope: true, skip: "steps.route.outputs.skip != 'true'" },
|
||||
'free-tests.yml': { aggregate: 'free-tests', profile: 'ci-reuse/free-tests', plan: 'free-plan', exempt: ['trunk-dynamic-ci', 'trunk-flaky-tests', 'docs-scope', 'docs-lane', 'free-plan'], observer: 'trunk-dynamic-ci', uploader: 'trunk-flaky-tests', manual: false, reuseIf: `(${MAIN_PUSH}) || github.event_name == 'pull_request'`, pullRequest: true, docsScope: true, skip: "steps.route.outputs.skip != 'true'" },
|
||||
'windows-free-tests.yml': { aggregate: 'windows-free-tests', profile: 'ci-reuse/windows-free-tests', plan: 'windows-plan', exempt: ['windows-record-durations'], observer: null, uploader: null, manual: true, reuseIf: MAIN_PUSH, pullRequest: false, docsScope: false, skip: "steps.route.outputs.reused != 'true'" },
|
||||
};
|
||||
const PROFILES = JSON.parse(read('.gstack/pregate.json')).run_profiles as Record<string, { workflow: string; jobs: string[]; artifact: string; events: string[]; os: string }>;
|
||||
@@ -167,6 +167,29 @@ for (const [file, spec] of Object.entries(FILES)) {
|
||||
});
|
||||
}
|
||||
|
||||
test('free-tests.yml plans beside reuse and docs-scope, and every job that reads the plan still waits for both and skips on a reuse or a docs-only pull request (GST-3303)', () => {
|
||||
const jobs = (Bun.YAML.parse(read('.github/workflows/free-tests.yml')) as any).jobs as Record<string, any>;
|
||||
expect([jobs['free-plan'].needs, jobs['free-plan'].if]).toEqual([undefined, undefined]);
|
||||
const readers = Object.keys(jobs).filter(n => n !== 'free-tests' && JSON.stringify(jobs[n]).includes('needs.free-plan'));
|
||||
expect(readers).toEqual(['free-suite']);
|
||||
for (const name of readers) {
|
||||
expect([name, [jobs[name].needs].flat()]).toEqual([name, expect.arrayContaining(['free-plan', 'reuse', 'docs-scope'])]);
|
||||
expect(runs(jobs[name].if, { result: 'success', reused: 'true' })).toBe(false);
|
||||
expect(runs(jobs[name].if, { result: 'skipped', reused: '', docsScope: 'success', docsOnly: 'true' })).toBe(false);
|
||||
expect(runs(jobs[name].if, { result: 'skipped', reused: '', plan: 'failure' })).toBe(false);
|
||||
expect(runs(jobs[name].if, { result: 'success', reused: 'false', docsScope: 'success', docsOnly: 'false' })).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
test('every skippable job in the ci-reuse/free-tests profile skips on a docs-only pull request, so a docs-only run still carries as not owed (GST-3303)', () => {
|
||||
const jobs = (Bun.YAML.parse(read('.github/workflows/free-tests.yml')) as any).jobs as Record<string, any>;
|
||||
const skippable = (JSON.parse(read('.gstack/pregate.json')).run_profiles['ci-reuse/free-tests'].skippable.jobs) as string[];
|
||||
for (const name of skippable) {
|
||||
expect([name, [jobs[name].needs].flat()]).toEqual([name, expect.arrayContaining(['docs-scope'])]);
|
||||
expect([name, String(jobs[name].if ?? '')]).toEqual([name, expect.stringContaining("needs.docs-scope.outputs.docs_only == 'true'")]);
|
||||
}
|
||||
});
|
||||
|
||||
test('every workflow that calls one of these grants the calling job actions: read, which the reuse job needs even when it is skipped', () => {
|
||||
const dir = path.join(ROOT, '.github/workflows');
|
||||
const callers: string[] = [];
|
||||
|
||||
@@ -35,7 +35,7 @@ describe('docs-scope', () => {
|
||||
});
|
||||
|
||||
describe('free-tests', () => {
|
||||
const suites = ['free-plan', 'typecheck', 'quick-bun-default', 'cso-macos-launcher', 'macos-named-regressions', 'cso-windows-launcher', 'cso-docker-integration'];
|
||||
const suites = ['free-suite', 'typecheck', 'quick-bun-default', 'cso-macos-launcher', 'macos-named-regressions', 'cso-windows-launcher', 'cso-docker-integration'];
|
||||
test('every suite job skips only when docs-scope succeeded and said docs-only', () => {
|
||||
for (const name of suites) {
|
||||
expect([name, needs(free[name])]).toEqual([name, expect.arrayContaining(['reuse', 'docs-scope'])]);
|
||||
|
||||
@@ -132,7 +132,7 @@ describe('free-tests workflow wiring', () => {
|
||||
const suite = workflow.jobs['free-suite'];
|
||||
const aggregate = workflow.jobs['free-tests'];
|
||||
expect(planner.steps.find((step: any) => step.id === 'plan').run).toContain('--ci-plan');
|
||||
expect(suite.needs).toEqual(['free-plan', 'reuse']);
|
||||
expect(suite.needs).toEqual(['free-plan', 'reuse', 'docs-scope']);
|
||||
expect(suite.strategy.matrix).toBe('${{ fromJSON(needs.free-plan.outputs.matrix) }}');
|
||||
expect(suite.strategy['fail-fast']).toBe(false);
|
||||
expect(suite.strategy['max-parallel']).toBe(20);
|
||||
|
||||
@@ -120,12 +120,14 @@ describe('W7a flake ledger reader', () => {
|
||||
expect(client.calls[0]).toContain('branch=main');
|
||||
});
|
||||
|
||||
// A reused main push (#3709) uploads no artifact and its reuse job succeeds; a real run uploads free-plan and free-result-*.
|
||||
// A reused main push (#3709) uploads nothing but the planner's free-plan (none before GST-3303) and its reuse job succeeds; a real run uploads free-plan and free-result-*.
|
||||
const reuseClient = (runs: ReturnType<typeof run>[], kind: (id: number) => 'reused' | 'real' | 'flaky', jobs?: () => unknown) => fakeClient([
|
||||
[/workflows\/free-tests\.yml\/runs/, () => ({ workflow_runs: runs })],
|
||||
[/runs\/\d+\/artifacts/, apiPath => {
|
||||
const k = kind(Number(/runs\/(\d+)\/artifacts/.exec(apiPath)![1]));
|
||||
return { artifacts: k === 'reused' ? [] : [{ id: 8, name: 'free-plan', size_in_bytes: 10 },
|
||||
const plan = { id: 8, name: 'free-plan', size_in_bytes: 10 };
|
||||
if (k === 'reused') return { artifacts: Number(/runs\/(\d+)\/artifacts/.exec(apiPath)![1]) % 2 ? [plan] : [] };
|
||||
return { artifacts: [plan, { id: 7, name: 'free-result-1', size_in_bytes: 10 },
|
||||
...(k === 'flaky' ? [{ id: 9, name: 'flake-ledger-3', size_in_bytes: 10 }] : [])] };
|
||||
}],
|
||||
[/runs\/\d+\/attempts\/1\/jobs/, jobs ?? (() => ({ jobs: [{ id: 1, name: 'reuse', conclusion: 'success' }, { id: 2, name: 'free-plan', conclusion: 'skipped' },
|
||||
@@ -155,7 +157,7 @@ describe('W7a flake ledger reader', () => {
|
||||
const window = readCiFlakeLedgers({ client, repo: 'o/r', sinceDays: 7, now: NOW, cacheDir: tmp('health-cache-') });
|
||||
expect(window).toMatchObject({ runs: 20, flakyRuns: 1, skipped: 40, enforceable: true, since: day(8 + 39 * 0.5),
|
||||
files: [{ file: 'test/a.test.ts', rate: 0.05, failing: false }] });
|
||||
expect(window.note).toBe('18 run(s) with no artifacts not checked for main-push reuse (cap of 40 job listings reached); counted as before #3725');
|
||||
expect(window.note).toBe('18 run(s) with no shard artifacts not checked for main-push reuse (cap of 40 job listings reached); counted as before #3725');
|
||||
expect(client.calls.filter(call => call.includes('/jobs')).length).toBe(40);
|
||||
expect(client.calls.filter(call => call.includes('/artifacts')).length).toBe(60);
|
||||
expect(flakeCheck(window).detail).toBe('no file above 5% over 20 main runs; 40 reused main push(es) left out; ' + window.note);
|
||||
@@ -163,7 +165,7 @@ describe('W7a flake ledger reader', () => {
|
||||
const failing = reuseClient(runs, kind, () => { throw new Error('gh api failed: HTTP 502: Bad Gateway'); });
|
||||
const unchecked = readCiFlakeLedgers({ client: failing, repo: 'o/r', sinceDays: 7, now: NOW, cacheDir: tmp('health-cache-') });
|
||||
expect(unchecked).toMatchObject({ runs: 20, skipped: 0, since: day(1 + 19 * 0.1), files: [{ file: 'test/a.test.ts', rate: 0.05 }] });
|
||||
expect(unchecked.note).toStartWith('18 run(s) with no artifacts not checked for main-push reuse (GitHub API server error');
|
||||
expect(unchecked.note).toStartWith('18 run(s) with no shard artifacts not checked for main-push reuse (GitHub API server error');
|
||||
});
|
||||
|
||||
test('the job-summary table names files, counts and shards', () => {
|
||||
|
||||
Reference in new issue
Block a user