diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f481f3296c..ea72d734b4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -487,10 +487,14 @@ jobs: - name: Run reverse tools tests with coverage run: npm run test:coverage:reverse-tools - name: Preflight both reverse tools mutation configurations + # Run named hooks without adding their own pre/post lifecycle. + shell: bash run: | + npm run --ignore-scripts --if-present pretest:mutation:reverse-tools node scripts/prepare-reverse-tools-mutation.mjs npx --no-install stryker run stryker.config.mjs --dryRunOnly npx --no-install stryker run stryker.semantics.config.mjs --dryRunOnly + npm run --ignore-scripts --if-present posttest:mutation:reverse-tools - name: Retain available reverse tools diagnostics if: ${{ !cancelled() }} uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 diff --git a/.github/workflows/sqlite-runtime.yml b/.github/workflows/sqlite-runtime.yml index 9e167248ac..abffb0e41d 100644 --- a/.github/workflows/sqlite-runtime.yml +++ b/.github/workflows/sqlite-runtime.yml @@ -37,4 +37,10 @@ jobs: name: rea-test-runtime path: . - name: Verify SQLite discovery, inspection and cleanup - run: npm run test:sqlite:run + # The downloaded runtime supplies the preparation done by test:sqlite. + # Run named hooks without adding their own pre/post lifecycle. + shell: bash + run: | + npm run --ignore-scripts --if-present pretest:sqlite + npm run test:sqlite:run + npm run --ignore-scripts --if-present posttest:sqlite diff --git a/scripts/ci/change-plan.mjs b/scripts/ci/change-plan.mjs index 9781e9c9cf..47344fa685 100644 --- a/scripts/ci/change-plan.mjs +++ b/scripts/ci/change-plan.mjs @@ -198,15 +198,19 @@ export function planChanges(request, repository) { ]), ].filter((key) => beforeScripts?.[key] !== afterScripts?.[key]); for (const script of changed) { - if (/^test:(coverage|mutation):reverse-tools$/.test(script)) { + const lifecycleTarget = script.replace(/^(?:pre|post)(?=test:)/u, ""); + if (/^test:(coverage|mutation):reverse-tools$/.test(lifecycleTarget)) { selected.reverse_tools = true; continue; } - if (script === "test:python") { + if (lifecycleTarget === "test:python") { selected.python = true; continue; } - if (script === "test:sqlite" || script === "test:sqlite:run") { + if ( + lifecycleTarget === "test:sqlite" || + lifecycleTarget === "test:sqlite:run" + ) { selected.sqlite = true; continue; } diff --git a/tests/boundary/filesystem/ciChangeScope.test.ts b/tests/boundary/filesystem/ciChangeScope.test.ts index 5e90bbfe03..5bf133e7d5 100644 --- a/tests/boundary/filesystem/ciChangeScope.test.ts +++ b/tests/boundary/filesystem/ciChangeScope.test.ts @@ -1928,6 +1928,27 @@ it.each(["test:sqlite", "test:sqlite:run"])( }, ); +it.each( + ( + [ + ["test:coverage:reverse-tools", "reverse_tools"], + ["test:mutation:reverse-tools", "reverse_tools"], + ["test:python", "python"], + ["test:sqlite", "sqlite"], + ["test:sqlite:run", "sqlite"], + ] as const + ).flatMap(([target, scope]) => + ["pre", "post"].map((prefix) => [`${prefix}${target}`, scope] as const), + ), +)("routes a change to %s to the %s lane", async (script, scope) => { + expect( + await classifyPackage( + JSON.stringify({ scripts: { [script]: "node before.mjs" } }), + JSON.stringify({ scripts: { [script]: "node after.mjs" } }), + ), + ).toMatchObject({ code: true, [scope]: true, runtime: false }); +}); + it("keeps unrelated test script changes off the SQLite runtime matrix", async () => { expect( await classifyPackage( diff --git a/tests/boundary/filesystem/ciFeedback.test.ts b/tests/boundary/filesystem/ciFeedback.test.ts index ff69d2805b..e99771003a 100644 --- a/tests/boundary/filesystem/ciFeedback.test.ts +++ b/tests/boundary/filesystem/ciFeedback.test.ts @@ -183,9 +183,11 @@ it.each(["fast", "full"] as const)( ); expect(mutationCommands).toEqual([ "npm run verify:mutation-targets", + "npm run --ignore-scripts --if-present pretest:mutation:reverse-tools", "node scripts/prepare-reverse-tools-mutation.mjs", "npx --no-install stryker run stryker.config.mjs --dryRunOnly", "npx --no-install stryker run stryker.semantics.config.mjs --dryRunOnly", + "npm run --ignore-scripts --if-present posttest:mutation:reverse-tools", ]); const guard = commands.indexOf("npm run verify:mutation-targets"); const coverage = commands.indexOf("npm run test:coverage:reverse-tools"); diff --git a/tests/boundary/filesystem/ciRequiredLanes.test.ts b/tests/boundary/filesystem/ciRequiredLanes.test.ts index 83feab8868..7da7af54ec 100644 --- a/tests/boundary/filesystem/ciRequiredLanes.test.ts +++ b/tests/boundary/filesystem/ciRequiredLanes.test.ts @@ -371,9 +371,14 @@ it("requires each named SQLite compatibility test while retaining both directory const steps = z .array(z.object({ run: z.string().optional() })) .parse((await workflow("sqlite-runtime.yml")).jobs.sqlite?.steps); - expect(steps.some((step) => step.run === "npm run test:sqlite:run")).toBe( - true, + const sqlite = steps.find((step) => + step.run?.includes("npm run test:sqlite:run"), ); + expect(sqlite?.run?.trim().split("\n")).toEqual([ + "npm run --ignore-scripts --if-present pretest:sqlite", + "npm run test:sqlite:run", + "npm run --ignore-scripts --if-present posttest:sqlite", + ]); }); it("exports every canonical scope with read authority for admission and keeps telemetry outside the gate", async () => {