Files
hyperframes/scripts/pr-edit-concurrency.test.mjs
T
Miguel Ángel 096a586b41 ci: editing a PR's text no longer cancels its running checks (#4420)
* ci: editing a PR's text no longer cancels its running checks

CI, regression and Windows render re-run on pull_request edited (for base changes) with cancel-in-progress, so a body or title edit cancelled the running checks and the fail-closed Test aggregator went red on the cancelled run. Only a push or a base change cancels now; a text edit queues behind the running run.

* test(ci): read the workflows folder by path, not as a module URL

Fallow treated new URL('../.github/workflows/', import.meta.url) as an unresolvable import. Use import.meta.dirname and join, as scripts/check-skill-mirror.mjs does.
2026-09-24 11:19:00 -04:00

38 lines
1.4 KiB
JavaScript

import assert from "node:assert/strict";
import { readdirSync, readFileSync } from "node:fs";
import { join } from "node:path";
import test from "node:test";
import { parse } from "yaml";
const workflowsDir = join(import.meta.dirname, "..", ".github", "workflows");
const workflows = readdirSync(workflowsDir)
.filter((file) => file.endsWith(".yml"))
.map((file) => ({ file, config: parse(readFileSync(join(workflowsDir, file), "utf8")) }));
// A body or title edit must not cancel in-flight code checks: the cancelled run's
// fail-closed `Test` stays red on the PR. Only a push or a base change cancels.
const CANCEL_UNLESS_PLAIN_EDIT =
"${{ github.event.action != 'edited' || github.event.changes.base != null }}";
// Reads the PR body itself, so the newest edit should replace an older run.
const BODY_WORKFLOWS = new Set(["pr-captures.yml"]);
const editedWorkflows = workflows.filter(({ config }) =>
config.on?.pull_request?.types?.includes("edited"),
);
test("the workflows that re-run on a PR edit are known", () => {
assert.deepEqual(editedWorkflows.map(({ file }) => file).sort(), [
"ci.yml",
"pr-captures.yml",
"regression.yml",
"windows-render.yml",
]);
});
for (const { file, config } of editedWorkflows) {
if (BODY_WORKFLOWS.has(file)) continue;
test(`${file}: a body or title edit does not cancel its running checks`, () => {
assert.equal(config.concurrency?.["cancel-in-progress"], CANCEL_UNLESS_PLAIN_EDIT);
});
}