mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-25 01:21:24 +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
@@ -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