diff --git a/.github/workflows/mutation-report.yml b/.github/workflows/mutation-report.yml index 55afa880b..f2d6bddfd 100644 --- a/.github/workflows/mutation-report.yml +++ b/.github/workflows/mutation-report.yml @@ -43,6 +43,15 @@ jobs: run: | bash scripts/ubicloud/setup-free-suite.sh echo "$HOME/.bun/bin" >> "$GITHUB_PATH" + # build:gates in the setup rebuilds the committed lib/diagram-render/dist + # bundle, whose bytes differ by machine, so the checkout read as dirty + # and the report refused to start (run 46115058363). This checkout has no + # edits of its own, and the report restores this same committed tree with + # git after every file, so put it back before the report's clean-tree check. + - name: Restore tracked files the setup rebuilt + run: | + git status --short --untracked-files=no + git checkout -- . - name: Install pinned Stryker outside the checkout run: | set -euo pipefail diff --git a/changelog.d/fix-stable-cut-report-only-workflows.md b/changelog.d/fix-stable-cut-report-only-workflows.md new file mode 100644 index 000000000..058fed26e --- /dev/null +++ b/changelog.d/fix-stable-cut-report-only-workflows.md @@ -0,0 +1,4 @@ +--- +important: blocker +--- +**The stable release no longer skips a fully tested commit because a report-only workflow failed on it.** The daily stable cut refused v1.104.2.0 because the weekly mutation report, which never blocks a merge, failed on that commit. Now its check runs are set aside like the nightly Windows suite's, along with the other workflows whose own header says they never block, which are the Trunk flaky-test upload, the marathon evals and the eval sweep. A red free-tests or main-backstop check still keeps a commit out. The weekly mutation report also runs again. The free-suite setup rebuilds a committed bundle whose bytes differ by machine, so the report refused its own fresh checkout as dirty; the workflow now puts those files back first, and the report names the edited files when it does refuse. Release note lines also drop a stray trailing comma or semicolon before the pull request link. diff --git a/crew/scripts/release-cut.ts b/crew/scripts/release-cut.ts index 7a201571f..a5623250c 100755 --- a/crew/scripts/release-cut.ts +++ b/crew/scripts/release-cut.ts @@ -23,8 +23,10 @@ * workflow produced itself (CUT_WORKFLOW: the jobs of a workflow run whose path * is that file; a job's id is its check run's id) are set aside, running or * finished: a cut lands its own job on main's head, the commit it may cut. - * Check runs from NEVER_GATING_WORKFLOWS (the nightly Windows free suite, which - * docs/support-tiers.md says never blocks) are set aside the same way. + * Check runs from NEVER_GATING_WORKFLOWS (workflows whose own header says they + * never block: the nightly Windows free suite, the weekly mutation report, the + * Trunk flaky-test upload, the marathon evals and the eval sweep) are set aside + * the same way. * Matching by job, not check suite, keeps check runs other workflows create * through the API, which GitHub files under any github-actions suite on the * commit. When the workflow runs cannot be read, nothing is set aside. @@ -84,8 +86,17 @@ export const REQUIRED_CHECK = 'free-tests'; export const BACKSTOP_CHECK = 'main-backstop'; export const NOTES_REF = 'refs/notes/gstack-trains'; export const CUT_WORKFLOW = '.github/workflows/weekly-release.yml'; -/** Workflows documented as never gating (docs/support-tiers.md): their check runs are set aside like the cut's own, matched the same way. */ -export const NEVER_GATING_WORKFLOWS: readonly string[] = ['.github/workflows/windows-free-tests.yml']; +/** + * Workflows documented as never gating, each in its own header: their check runs are set aside like the cut's own, matched the same way. + * crew/test/release-cut.test.ts checks every entry exists, never runs on pull requests or pushes, and says so in its header. + */ +export const NEVER_GATING_WORKFLOWS: readonly string[] = [ + '.github/workflows/windows-free-tests.yml', // nightly Windows suite; minimal support never blocks (docs/support-tiers.md) + '.github/workflows/mutation-report.yml', // weekly report-only mutation trial; not a required check + '.github/workflows/trunk-flaky-tests.yml', // detection only: uploads Free Tests JUnit to Trunk, nothing reads its result + '.github/workflows/evals-marathon.yml', // non-blocking marathon lane; a red run reports through its own issue + '.github/workflows/eval-sweep.yml', // weekly diagnostic sweep: no verdict, no pass-rate history +]; const NOTES_LOCAL = 'refs/notes/gstack-trains-release'; const RED = new Set(['failure', 'timed_out', 'cancelled', 'action_required', 'startup_failure', 'stale']); export const WINDOW_DAYS = 7; diff --git a/crew/scripts/release-notes.ts b/crew/scripts/release-notes.ts index 022005836..82c9449c3 100644 --- a/crew/scripts/release-notes.ts +++ b/crew/scripts/release-notes.ts @@ -113,7 +113,7 @@ export function changeLine(text: string): string { return lead.replace(/\*\*/g, '') .replace(/\s*\((?!CVE-|GHSA-)[A-Z][A-Z0-9]*-\d+(?:(?:,\s*|\s+and\s+)(?!CVE-|GHSA-)[A-Z][A-Z0-9]*-\d+)*\)/g, '') .replace(/\b([Oo])utside voice/g, (_, o: string) => (o === 'O' ? 'S' : 's') + 'econd-model review') - .replace(/\s+/g, ' ').replace(/\s+([.,;:!?])/g, '$1').trim(); + .replace(/\s+/g, ' ').replace(/\s+([.,;:!?])/g, '$1').trim().replace(/[,;]+$/, ''); } function prOf(subject: string): number | null { diff --git a/crew/test/release-cut.test.ts b/crew/test/release-cut.test.ts index d07f83bb1..dd31ef420 100644 --- a/crew/test/release-cut.test.ts +++ b/crew/test/release-cut.test.ts @@ -416,6 +416,46 @@ describe('release-cut: the cut sets aside its own check runs (GST-2463)', () => .toEqual({ green: false, why: 'red check runs: windows-free-shard (4)', pending: false }); }); + // Value: protects=a red or running check run from the weekly report-only mutation report (or the other never-gating workflows) never keeps a gated + // commit out of the cut, while a red free-tests, a red main-backstop and a same-named job outside those workflows still refuse; fails_when=the + // mutation report's failure on 778934c0 (run 46115058363) holds the v1.104.2.0 daily cut, or the exclusion is keyed on the check name; + // why_new=only the Windows nightly was set aside; seam=gh is faked with the check-runs, actions/runs and jobs payload shapes; no_claim=a live workflow run + test('gateVerdict: the report-only mutation report\'s red check run is set aside; red free-tests and main-backstop still refuse (GST-4095)', () => { + const evidence = gatedBy(sha, '46088945889'); + const mutation = { id: 9200, path: '.github/workflows/mutation-report.yml', jobs: [72001] }; + expect(NEVER_GATING_WORKFLOWS).toContain(mutation.path); + const api = workflowRuns(sha, [ownWorkflow, mutation, { id: 555, path: '.github/workflows/evals.yml', jobs: [70555] }]); + const report = (status: string, conclusion: string | null, id = 72001) => ({ id, name: 'Mutation report', status, conclusion }) as CheckRun; + for (const run of [report('completed', 'failure'), report('completed', 'timed_out'), report('in_progress', null)]) { + expect(gateVerdict(ghFor([...unbacked, run], api), 'o/r', sha, { evidence })).toEqual({ green: true, via: 'release gate run 46088945889' }); + expect(gateVerdict(ghFor([...GREEN, run], api), 'o/r', sha)).toEqual({ green: true, via: BACKSTOP_CHECK }); + } + expect(gateVerdict(ghFor([{ name: REQUIRED_CHECK, status: 'completed', conclusion: 'failure' }, ...unbacked.filter(c => c.name !== REQUIRED_CHECK), report('completed', 'failure')], api), 'o/r', sha, { evidence })) + .toEqual({ green: false, why: REQUIRED_CHECK + ' concluded failure', pending: false }); + expect(gateVerdict(ghFor([...unbacked, { name: BACKSTOP_CHECK, status: 'completed', conclusion: 'failure' }, report('completed', 'failure')], api), 'o/r', sha, { evidence })) + .toEqual({ green: false, why: 'red check runs: ' + BACKSTOP_CHECK, pending: false }); + expect(gateVerdict(ghFor([...unbacked, report('completed', 'failure', 70555)], api), 'o/r', sha, { evidence })) + .toEqual({ green: false, why: 'red check runs: Mutation report', pending: false }); + expect(gateVerdict(ghFor([...unbacked, report('completed', 'failure')], {}), 'o/r', sha, { evidence })) + .toEqual({ green: false, why: 'red check runs: Mutation report', pending: false }); + }); + + // Value: protects=only a workflow that cannot gate is set aside: every NEVER_GATING_WORKFLOWS entry exists, never runs on pull requests or pushes, and + // says in its own header that it does not block; fails_when=a typo'd path silently sets nothing aside, or a gating workflow is added to the list; + // why_new=the list had no wiring check and missed mutation-report.yml (GST-4095); seam=the workflow files themselves; no_claim=GitHub's required checks + test('every never-gating workflow exists, has no pull_request or push trigger, and its header says it never blocks', () => { + const root = path.resolve(import.meta.dir, '../..'); + expect(NEVER_GATING_WORKFLOWS).toEqual(expect.arrayContaining(['.github/workflows/windows-free-tests.yml', '.github/workflows/mutation-report.yml', '.github/workflows/trunk-flaky-tests.yml'])); + for (const wf of NEVER_GATING_WORKFLOWS) { + const text = fs.readFileSync(path.join(root, wf), 'utf-8'); + const on = /^on:\n((?:[ #].*\n|\n)*)/m.exec(text)?.[1] ?? ''; + expect(on).toMatch(/^ [a-z_]+:/m); + expect(on).not.toMatch(/^ (pull_request|pull_request_target|push|merge_group):/m); + const header = text.slice(0, text.search(/^on:/m)).split('\n').filter(l => l.startsWith('#')).join(' '); + expect(header).toMatch(/never blocks|not a PR gate|report-only|DETECTION ONLY|NON-BLOCKING|no verdict/); + } + }); + const note = (f: ReturnType, record: unknown, on: string) => { git(f.seed, 'notes', '--ref=' + NOTES_REF, 'add', '-f', '-m', JSON.stringify(record), on); git(f.seed, 'push', '-q', '-f', 'origin', NOTES_REF); @@ -1359,6 +1399,14 @@ describe('release-cut: notes', () => { expect(changeLine('**/review now reads Rust files (GST-101).** More.')).toBe('/review now reads Rust files.'); }); + // Value: protects=a release note line never reads "...files, ([#12](...))" when a change has no sentence end and stops on a comma or semicolon; + // fails_when=changeLine keeps the stray trailing punctuation the PR link is appended after; why_new=GST-4095 polish; seam=changeLine; no_claim=a live cut + test('a change line drops a stray trailing comma or semicolon', () => { + expect(changeLine('/ship now reads worktrees, ')).toBe('/ship now reads worktrees'); + expect(changeLine('**Retries stop after three tries;**')).toBe('Retries stop after three tries'); + expect(changeLine('Keeps a comma, in the middle.')).toBe('Keeps a comma, in the middle.'); + }); + // Value: protects=a cut fails loudly instead of publishing a stub; fails_when=a version with an empty entry or a span with no entry still // yields notes; why_new=the old notes always rendered, padding gaps with "see CHANGELOG.md". test('a version with no change or a missing entry refuses instead of publishing a stub', () => { diff --git a/docs/TESTING_INTERNALS.md b/docs/TESTING_INTERNALS.md index 13decf179..5aefb2390 100644 --- a/docs/TESTING_INTERNALS.md +++ b/docs/TESTING_INTERNALS.md @@ -1146,7 +1146,7 @@ machine swap, in this order: ## Mutation report -A weekly, report-only trial of mutation testing. It checks whether gstack's tests reject plausible wrong code in the files agents change most. `.github/workflows/mutation-report.yml` runs every Saturday at 06:00 UTC, or on demand through workflow_dispatch, on `ubicloud-standard-16`. It is not a required check, never runs on pull requests, and never blocks a merge. +A weekly, report-only trial of mutation testing. It checks whether gstack's tests reject plausible wrong code in the files agents change most. `.github/workflows/mutation-report.yml` runs every Saturday at 06:00 UTC, or on demand through workflow_dispatch, on `ubicloud-standard-16`. It is not a required check, never runs on pull requests, and never blocks a merge; the stable release cut sets its check runs aside too ([releases.md](releases.md#what-a-release-is)). Before the report starts, the workflow restores the tracked files the free-suite setup rebuilt (the committed `lib/diagram-render/dist` bundle differs by machine), because the script refuses a dirty checkout and names the edited files when it does. `scripts/mutation-report.ts` does the work: diff --git a/docs/releases.md b/docs/releases.md index 42842b7a3..72bb60734 100644 --- a/docs/releases.md +++ b/docs/releases.md @@ -55,10 +55,15 @@ days or 200 first-parent commits. The cut's own job lands a check run on main's head, the very commit it may cut, so check runs from this workflow's own runs (its file path, `.github/workflows/weekly-release.yml`, matched by the job ids of those workflow runs) are set aside whether running or -failed. Check runs from the nightly Windows free suite -(`.github/workflows/windows-free-tests.yml`), which -[never blocks](support-tiers.md#windows-ci), are set aside the same way; -every other check run counts as above. The lookup needs the +failed. Check runs from workflows whose own header says they never block are +set aside the same way: the nightly Windows free suite +(`.github/workflows/windows-free-tests.yml`, which +[never blocks](support-tiers.md#windows-ci)), the weekly mutation report +(`mutation-report.yml`), the Trunk flaky-test upload +(`trunk-flaky-tests.yml`), the marathon evals (`evals-marathon.yml`) and the +eval sweep (`eval-sweep.yml`), listed in `NEVER_GATING_WORKFLOWS`. A red +`free-tests` or `main-backstop` check still keeps a commit out, and every +other check run counts as above. The lookup needs the workflow's `actions: read` permission; when it cannot read those runs, nothing is set aside. The workflow runs no tests and no paid evals of its own; it only reads what the trains, the backstop and the release gate diff --git a/scripts/mutation-report.ts b/scripts/mutation-report.ts index 55b445805..8130cea92 100755 --- a/scripts/mutation-report.ts +++ b/scripts/mutation-report.ts @@ -185,7 +185,8 @@ if (import.meta.main) { const files = intArg(argv, '--files', 5), sinceDays = intArg(argv, '--since-days', 30); const budgetMs = intArg(argv, '--file-budget-min', 55) * 60_000, concurrency = intArg(argv, '--concurrency', 4); process.chdir(git(['rev-parse', '--show-toplevel']).trim()); - if (git(['status', '--porcelain', '--untracked-files=no']).trim()) fail('the checkout has uncommitted changes; use a clean disposable checkout'); + const dirty = git(['status', '--porcelain', '--untracked-files=no']).split('\n').filter(Boolean).map(l => l.slice(3)); + if (dirty.length) fail(`the checkout has uncommitted changes (${dirty.slice(0, 10).join(', ')}${dirty.length > 10 ? `, and ${dirty.length - 10} more` : ''}); use a clean disposable checkout`); const resolvedOut = path.resolve(outDir); const rel = path.relative(process.cwd(), resolvedOut); if (!path.isAbsolute(rel) && rel !== '..' && !rel.startsWith('..' + path.sep)) fail('--out-dir must be outside the checkout'); diff --git a/test/mutation-report.test.ts b/test/mutation-report.test.ts index ef309777f..1fa02b3a8 100644 --- a/test/mutation-report.test.ts +++ b/test/mutation-report.test.ts @@ -1,7 +1,9 @@ import { describe, expect, test } from 'bun:test'; import * as fs from 'node:fs'; +import * as os from 'node:os'; import * as path from 'node:path'; import { spawnSync } from 'node:child_process'; +import { bunIsolationArgs } from '../lib/bun-isolation'; import { CONTROL_LINE, CONTROL_MESSAGE, STRYKER_PACKAGES, plantControl, rankChurn, renderMarkdown, summarize, type Mutant } from '../scripts/mutation-report'; const ROOT = path.resolve(import.meta.dir, '..'); @@ -48,6 +50,41 @@ describe('mutation-report', () => { expect(r.stderr).toContain('--throwaway-checkout'); }); + test('refuses a checkout with an edited tracked file and names it; untracked files are not edits', () => { + const root = fs.mkdtempSync(path.join(os.tmpdir(), 'mutation-dirty-')); + const repo = path.join(root, 'repo'); + fs.mkdirSync(repo); + try { + const git = (...args: string[]) => spawnSync('git', args, { cwd: repo, encoding: 'utf-8', timeout: 30_000 }); + fs.mkdirSync(path.join(repo, 'lib')); + fs.writeFileSync(path.join(repo, 'lib/a.ts'), 'export const a = 1;\n'); + expect(git('init', '-q').status).toBe(0); + expect(git('add', '.').status).toBe(0); + expect(git('-c', 'user.name=t', '-c', 'user.email=t@example.com', '-c', 'commit.gpgsign=false', 'commit', '-qm', 'seed').status).toBe(0); + const run = () => spawnSync(process.execPath, [...bunIsolationArgs(), path.join(ROOT, 'scripts/mutation-report.ts'), '--throwaway-checkout', '--stryker-dir', path.join(root, 'stryker'), '--out-dir', path.join(root, 'out'), '--since-days', '1', '--only', 'lib/none.ts'], { cwd: repo, encoding: 'utf-8', timeout: 30_000 }); + fs.writeFileSync(path.join(repo, 'build-output.html'), 'generated\n'); + const untracked = run(); + expect(untracked.status).toBe(1); + expect(untracked.stderr).not.toContain('uncommitted changes'); + fs.writeFileSync(path.join(repo, 'lib/a.ts'), 'export const a = 2;\n'); + const edited = run(); + expect(edited.status).toBe(1); + expect(edited.stderr).toContain('the checkout has uncommitted changes (lib/a.ts); use a clean disposable checkout'); + } finally { + fs.rmSync(root, { recursive: true, force: true }); + } + }); + + test('the workflow restores tracked files the free-suite setup rebuilt before the report checks for a clean tree', () => { + const wf = fs.readFileSync(path.join(ROOT, '.github/workflows/mutation-report.yml'), 'utf-8'); + const setup = wf.indexOf('bash scripts/ubicloud/setup-free-suite.sh'); + const restore = wf.indexOf('git checkout -- .'); + const report = wf.indexOf('scripts/mutation-report.ts \\'); + expect(setup).toBeGreaterThan(-1); + expect(restore).toBeGreaterThan(setup); + expect(report).toBeGreaterThan(restore); + }); + test('the workflow is scheduled, read-only and never runs on pull requests', () => { const wf = fs.readFileSync(path.join(ROOT, '.github/workflows/mutation-report.yml'), 'utf-8'); expect(wf).toMatch(/^on:\n schedule:\n/m);