mirror of
https://github.com/callstack/agent-device.git
synced 2026-09-14 20:06:34 +08:00
423927fdd8
* chore(mutation): shrink the lane to report-only (#1457, #1781 wave 2) The mutation harness's two real catches (#1474, #1475) both came from humans reading the weekly score report. The ratchet half never operated: the baseline was committed exactly twice (8cce0ef6b,60400d04b), both times with `stableRuns: 0, gating: false`, and was never updated after the very fixes it triggered — the weekly job computed a new baseline and then `git checkout --`d it, uploading a proposal nobody applied in 3+ weeks. A gate nobody arms is harness weight; the report is the part that paid. Deletes ratchet.ts + ratchet.test.ts, mutation-baselines/, and every baseline/graduation/gating path in run.ts (`--update`, `mutation:baseline`). run.ts now exits non-zero only on a harness failure, never on a score. The report renders the per-kernel table (kernel, score, killed, survived, total, timeouts) plus the surviving mutants a strengthening PR works from. Kernel scoping stays: stryker.config.json and KERNEL_MODULES are untouched. * fix(mutation): restore denominator coverage and publish the table before judging the shard set Review of #1828: - `report.test.ts` re-asserts that Ignored/CompileError/RuntimeError leave the denominator — the one behaviour `ratchet.test.ts` covered and nothing replaced. A `tally()` edit that counted tool noise would have deflated every published score with a green `mutation:test`. - `assertShardsCoverModules` now runs after `emit()`, so an incomplete shard set still publishes the kernels that completed instead of only an error string. This makes the workflow comments' claim about the job summary true rather than re-wording them down. * chore(mutation): trigger the affected lane on exactly the paths that can select mutants The PR lane returns an empty matrix unless the diff touches the harness, so the kernel-source and `**/*.test.ts` triggers only bought a 1-4 min no-op job on ~96% of PRs. `on.pull_request.paths` is now exactly `LANE_TOOLING` plus the workflow file, asserted in both directions by workflow.test.ts against the exported constant — a missing path would let a harness change merge unproven, an extra one starts a job that can only answer `[]`. Also drops the workflow header's contradictory scope paragraph: it claimed the lane selects on kernel sources and any test reaching one, which has not been true since the ratchet went. * fix(mutation): score and publish a short shard set before failing on the count The expected-count check ran inside readShardedReports, before anything was summarized, so on the weekly's real `--expect-shards 10` one dead shard threw away the nine that had reported — the earlier reorder only moved the zero-mutants check. The merge now returns the shard count, and both verdicts run after emit() with the same exit code and `score` stage. Regression uses the weekly argument shape (`--expect-shards 10`, one shard present) and asserts the reporting kernel's row reaches stdout while the run still fails.
82 lines
3.4 KiB
TypeScript
82 lines
3.4 KiB
TypeScript
// The workflows' YAML cannot read the kernel registry or the lane's own source
|
|
// list, so these assertions keep them in step: a module added to KERNEL_MODULES
|
|
// that no weekly shard runs would silently drop out of the sweep, and a PR path
|
|
// filter out of step with LANE_TOOLING either lets a harness change merge
|
|
// unproven or starts a job that selects nothing.
|
|
|
|
import assert from 'node:assert/strict';
|
|
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import { test } from 'node:test';
|
|
import { shardMatrix } from './modules.ts';
|
|
import { LANE_TOOLING } from './run.ts';
|
|
|
|
const repoRoot = path.resolve(import.meta.dirname, '../..');
|
|
|
|
function workflow(name: string): string {
|
|
return fs.readFileSync(path.join(repoRoot, '.github/workflows', name), 'utf8');
|
|
}
|
|
|
|
test('the weekly sweep shards exactly the registry matrix', () => {
|
|
const yaml = workflow('mutation-weekly.yml');
|
|
const jobs = [...yaml.matchAll(/^ {10}- \{ (?<entry>[^}]+) \}$/gm)].map((match) =>
|
|
Object.fromEntries(
|
|
match
|
|
.groups!.entry.split(', ')
|
|
.map((pair) => pair.split(': ') as [string, string])
|
|
.map(([key, value]) => [key, value]),
|
|
),
|
|
);
|
|
assert.deepEqual(
|
|
jobs,
|
|
shardMatrix().map((spec) =>
|
|
spec.shard ? { ...spec } : { name: spec.name, module: spec.module },
|
|
),
|
|
);
|
|
});
|
|
|
|
test('the weekly sweep merges the shards into one score table', () => {
|
|
const yaml = workflow('mutation-weekly.yml');
|
|
assert.match(yaml, /gate: mutation-check[\s\S]*--report-dir/);
|
|
assert.match(yaml, /GITHUB_STEP_SUMMARY|\$GITHUB_STEP_SUMMARY/);
|
|
// A dead shard must not be merged into a table that looks like a sweep.
|
|
assert.match(
|
|
yaml,
|
|
new RegExp(`--expect-shards\\s+${shardMatrix().length}\\b`),
|
|
'the weekly report does not require the full shard set',
|
|
);
|
|
});
|
|
|
|
// A shard that outruns the job timeout reports nothing, so the per-shard budget
|
|
// is the acceptance criterion made mechanical.
|
|
test('no mutation shard is allowed to exceed the 30-minute budget', () => {
|
|
for (const name of ['mutation-weekly.yml', 'mutation-affected.yml']) {
|
|
for (const [, minutes] of workflow(name).matchAll(/timeout-minutes: (\d+)/g)) {
|
|
assert.ok(Number(minutes) <= 30, `${name} declares a ${minutes}-minute job`);
|
|
}
|
|
}
|
|
});
|
|
|
|
// Only a harness diff can produce a non-empty matrix, so the trigger is asserted
|
|
// in both directions against LANE_TOOLING: a missing path lets a harness change
|
|
// merge without ever running a mutant, and an extra one starts a select job that
|
|
// can only answer `[]`.
|
|
test('the affected lane triggers on exactly the lane sources that can select mutants', () => {
|
|
// Quote style is the formatter's business (oxfmt formats the workflow tree), so
|
|
// accept either spelling of the same scalar rather than pinning this gate to it.
|
|
const paths = [
|
|
...workflow('mutation-affected.yml').matchAll(/^ {6}- (?<q>['"])(?<glob>[^'"]+)\k<q>$/gm),
|
|
].map((match) => match.groups!.glob);
|
|
const expected = [
|
|
...LANE_TOOLING.map((prefix) => (prefix.endsWith('/') ? `${prefix}**` : prefix)),
|
|
// The workflow reruns itself so a trigger edit is proven by the lane it edits.
|
|
'.github/workflows/mutation-affected.yml',
|
|
];
|
|
assert.deepEqual(
|
|
[...paths].sort(),
|
|
[...expected].sort(),
|
|
'the PR path filter drifted from LANE_TOOLING in scripts/mutation/run.ts',
|
|
);
|
|
assert.match(workflow('mutation-affected.yml'), /gate: mutation-affected[\s\S]*--list-affected/);
|
|
});
|