mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-01 15:35:12 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - PR CI selects affected suites and test files to reduce feedback time. > - A selected test inherited the parent selection when it launched an independent runner fixture. > - Ordinary source filenames containing config or setup also forced broad coverage. > - AWS runner access must depend on current CI CODEOWNERS, not only a stored numeric roster. > - This pull request fixes both selection problems and verifies owners before AWS allocation. > - Contributors retain GitHub-hosted CI. Authorized maintainers retain AWS test and final verification jobs. ## Linked Issues or Issue Description Refs #18362 and #18348. The selected server run for #18369 failed in `vitest-chat-shards.test.ts` because its temporary fixture inherited `PAPERCLIP_CI_TEST_SELECTION` and attempted `git rev-parse HEAD` outside a Git repository. #18366 could not use graph selection because `session-config-metadata.test.ts` matched the broad filename rule. The AWS setting was already enabled. The reviewed outsider PRs correctly used hosted runners; a maintainer PR used AWS, including final verification. This change strengthens that boundary rather than enabling AWS for outsiders. ## What Changed - Remove selection settings from Vitest child environments after the wrapper validates the selected shard. - Match conventional Vite/Vitest configuration filenames rather than any occurrence of config or setup. Keep graph tracking for actual setup and configuration dependencies. - Bind rerun actor lookup to the exact run attempt. Require the author, event sender and rerun actor to be current CI CODEOWNERS and members of the existing numeric allowlist. Read the resolver and CODEOWNERS from one protected master revision. - Run metadata authorization on GitHub-hosted capacity before any AWS allocation. Keep authorized test and final verification placement on the AWS fleet. - Add a real selected-server regression that launches nested chat fixtures, negative authorization cases, and qualification for a real config-named test. - Update the developer and profiling guides. - Retire eight legacy PR workflow SHA authorizations and one deleted qualification-branch reference from the live `paperclip-public-pr` runner group. The remaining three references are the trusted PR workflow and the existing full-stack/protocol evaluation workflows on master. No active PR run referenced the retired versions. ## Verification - Selection regression tests: 13 passed, including the real nested chat runner. - Routing, planner and profiling tests: 100 passed, including 69 routing cases. - `actionlint` passed for both changed workflows. `git diff --check` passed. - Confirmed protected master still requires CODEOWNER review. A live lookup found four CI owners, with three of six numeric roster entries eligible and three denied by the new owner check. - `pnpm -r typecheck` and `pnpm build` passed. The full local Vitest suite was stopped after repeated embedded PostgreSQL initialization failures; it did not pass. On final revision `0b40ae15b7996603e405edd4157a5c337e0405c7`, both Linux qualification jobs and all required CI gates passed. The main PR workflow completed with 48 successful jobs and one intentional skip, including final verification. [CI run](https://github.com/paperclipai/paperclip/actions/runs/41126881716). Greptile reviewed the final revision at 5/5 with no inline findings. - Shard and workflow contracts: 44 passed. CI first caught an outdated assertion that required the routing job to use AWS; it now requires hosted authorization, and the policy job passes. - A read-only live gate exercise preserved the existing merge-freshness denial when master advanced beyond the available merge ref. It allocated no runner and was not a successful admission proof. ## Risks - The short metadata authorization job now depends on GitHub-hosted queue capacity. This prevents a stale roster from allocating AWS before current CODEOWNERS are checked. Authorized test and final verification jobs still use AWS. - Identity/API failures fall back to hosted CI. No caller can override the trusted owner list with PR contents. - Configuration dependencies still require conservative graph handling. Existing setup dependency, opaque I/O, stale manifest and wrong-lane tests remain in place. - The runner group is restricted to selected repositories and selected workflows. Its workflow allowlist was verified and narrowed through the GitHub settings UI. Legacy pinned callers must update to the current trusted workflow before using AWS; active PR runs used master references. The current PR workflow authorization and evaluation workflow authorizations remain in place. ## Model Used - OpenAI Codex, based on GPT-6. The exact serving variant and context limit are not exposed in this session. Used reasoning, repository inspection, code execution and GitHub tools. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass — targeted suites passed; the full local suite hit the PostgreSQL startup limitation documented above, and full Linux CI passed - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Paperclip <noreply@paperclip.ing>
244 lines
17 KiB
JavaScript
244 lines
17 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { chmodSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
import { spawnSync } from "node:child_process";
|
|
import { tmpdir } from "node:os";
|
|
import path from "node:path";
|
|
import test from "node:test";
|
|
|
|
const workflow = readFileSync(new URL("../../workflows/ci-routing.yml", import.meta.url), "utf8");
|
|
const jobs = workflow.split(/^jobs:\n/m)[1];
|
|
|
|
test("authorization uses hosted capacity and runs no PR code or actions", () => {
|
|
assert.deepEqual([...jobs.matchAll(/^ {2}([a-z_]+):$/gm)].map((match) => match[1]), ["gate"]);
|
|
const placement = jobs.match(/^ {4}runs-on: (.+)$/m)?.[1];
|
|
assert.ok(placement, "routing placement must be defined");
|
|
assert.equal(placement, "ubuntu-latest", "verify current owners before allocating any AWS runner");
|
|
assert.doesNotMatch(jobs, /uses:|actions\/checkout|secrets\./);
|
|
assert.doesNotMatch(workflow, /^ {2}(?:actions|contents|pull-requests): write$/m);
|
|
});
|
|
|
|
test("routing exports both placement and stack scope to callers", () => {
|
|
assert.match(workflow, /^ {6}runner:\n {8}value: \$\{\{ jobs\.gate\.outputs\.runner \}\}$/m);
|
|
assert.match(workflow, /^ {6}full_ci:\n {8}value: \$\{\{ jobs\.gate\.outputs\.full_ci \}\}$/m);
|
|
assert.match(jobs, /^ {6}runner: \$\{\{ steps\.route\.outputs\.runner \}\}$/m);
|
|
assert.match(jobs, /^ {6}full_ci: \$\{\{ steps\.scope\.outputs\.full_ci \}\}$/m);
|
|
});
|
|
|
|
const githubStub = "#!/usr/bin/env bash\nset -Eeuo pipefail\n\nendpoint=\"\"\nquery=\"\"\nfor arg in \"$@\"; do\n case \"$arg\" in /repos/*|/users/*) endpoint=\"$arg\" ;; esac\ndone\nif [[ \"$*\" == *\"--jq\"* ]]; then query=\"${*: -1}\"; fi\ncase \"$endpoint\" in\n */contents/scripts/ci-profile/authorize.mjs?ref=*)\n [[ -z \"${TEST_OWNER_HELPER_FAIL:-}\" ]] || exit 1\n [[ \"$endpoint\" == *\"ref=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\" ]] || exit 1\n base64 < \"$TEST_OWNER_HELPER\"\n ;;\n */contents/.github/CODEOWNERS?ref=*)\n [[ -z \"${TEST_CODEOWNERS_FAIL:-}\" ]] || exit 1\n [[ \"$endpoint\" == *\"ref=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\" ]] || exit 1\n jq -cn --arg content \"$TEST_CODEOWNERS_BASE64\" '{encoding: \"base64\", content: $content}'\n ;;\n /users/ci-owner)\n [[ -z \"${TEST_OWNER_LOOKUP_FAIL:-}\" ]] || exit 1\n jq -cn --argjson id \"${TEST_CI_OWNER_ID:-34892728}\" --arg type \"${TEST_CI_OWNER_TYPE:-User}\" '{id: $id, type: $type}'\n ;;\n */pulls/*)\n jq -cn \\\n --argjson author_id \"${TEST_PR_AUTHOR_ID:-34892728}\" \\\n --argjson repository_id \"${TEST_REPOSITORY_ID:-1170821064}\" \\\n --arg base_ref \"${TEST_BASE_REF:-master}\" \\\n --arg base_sha \"${TEST_PR_BASE_SHA:-$EVENT_BASE_SHA}\" \\\n --arg head_sha \"${TEST_PR_HEAD_SHA:-1111111111111111111111111111111111111111}\" \\\n --arg merge_sha \"${TEST_PR_MERGE_SHA:-4444444444444444444444444444444444444444}\" '{\n state: \"open\",\n user: {id: $author_id},\n base: {repo: {id: $repository_id}, ref: $base_ref, sha: $base_sha},\n head: {sha: $head_sha},\n merge_commit_sha: $merge_sha\n }'\n ;;\n */git/ref/heads/*)\n if [[ \"$query\" == \".object.sha\" ]]; then\n [[ -z \"${TEST_MASTER_FAIL:-}\" ]] || exit 1\n echo \"${TEST_TRUSTED_MASTER_SHA:-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}\"\n exit 0\n fi\n jq -cn \\\n --arg sha \"${TEST_LIVE_BASE_REF_SHA:-$EVENT_BASE_SHA}\" '{object: {sha: $sha}}'\n ;;\n */compare/*)\n [[ -z \"${TEST_COMPARE_FAIL:-}\" ]] || exit 1\n default_files='[{\"filename\":\"server/src/index.ts\"}]'\n jq -cn \\\n --arg merge_base_sha \"${TEST_BASE_COMPARISON_MERGE_BASE_SHA:-$EVENT_BASE_SHA}\" \\\n --arg status \"${TEST_BASE_COMPARISON_STATUS:-ahead}\" \\\n --argjson files \"${TEST_COMPARE_FILES:-$default_files}\" '{\n merge_base_commit: {sha: $merge_base_sha},\n status: $status,\n files: $files\n }'\n ;;\n */git/commits/*)\n requested_sha=\"${endpoint##*/}\"\n live_merge_sha=\"${TEST_PR_MERGE_SHA:-4444444444444444444444444444444444444444}\"\n synthetic_base_merge_sha=\"${TEST_SYNTHETIC_BASE_MERGE_SHA:-}\"\n if [[ \"$requested_sha\" == \"$EVENT_MERGE_SHA\" ]]; then\n tree_sha=\"${TEST_EVENT_MERGE_TREE_SHA:-5555555555555555555555555555555555555555}\"\n base_sha=\"${TEST_EVENT_MERGE_BASE_SHA:-$EVENT_BASE_SHA}\"\n head_sha=\"${TEST_EVENT_MERGE_HEAD_SHA:-$EVENT_HEAD_SHA}\"\n elif [[ \"$requested_sha\" == \"$live_merge_sha\" ]]; then\n tree_sha=\"${TEST_LIVE_MERGE_TREE_SHA:-5555555555555555555555555555555555555555}\"\n base_sha=\"${TEST_LIVE_MERGE_BASE_SHA:-$EVENT_BASE_SHA}\"\n head_sha=\"${TEST_LIVE_MERGE_HEAD_SHA:-$EVENT_HEAD_SHA}\"\n elif [[ -n \"$synthetic_base_merge_sha\" && \"$requested_sha\" == \"$synthetic_base_merge_sha\" ]]; then\n tree_sha=\"${TEST_SYNTHETIC_BASE_MERGE_TREE_SHA:-8888888888888888888888888888888888888888}\"\n base_sha=\"${TEST_SYNTHETIC_MASTER_PARENT_SHA:-9999999999999999999999999999999999999999}\"\n head_sha=\"${TEST_SYNTHETIC_BASE_REF_PARENT_SHA:-${TEST_LIVE_BASE_REF_SHA:-$EVENT_BASE_SHA}}\"\n else\n echo \"unexpected merge commit: $requested_sha\" >&2\n exit 1\n fi\n jq -cn \\\n --arg sha \"$requested_sha\" \\\n --arg tree_sha \"$tree_sha\" \\\n --arg base_sha \"$base_sha\" \\\n --arg head_sha \"$head_sha\" '{\n sha: $sha,\n tree: {sha: $tree_sha},\n parents: [{sha: $base_sha}, {sha: $head_sha}]\n }'\n ;;\n */actions/runs/*/attempts/*)\n jq -cn \\\n --argjson actor_id \"${TEST_TRIGGERING_ACTOR_ID:-34892728}\" \\\n --argjson repository_id \"${TEST_REPOSITORY_ID:-1170821064}\" \\\n --argjson run_attempt \"${TEST_RUN_ATTEMPT:-1}\" \\\n --arg event_name \"${TEST_EVENT_NAME:-pull_request}\" '{\n run_attempt: $run_attempt,\n triggering_actor: {id: $actor_id},\n repository: {id: $repository_id},\n event: $event_name\n }'\n ;;\n *)\n echo \"unexpected gh endpoint: $endpoint\" >&2\n exit 1\n ;;\nesac";
|
|
|
|
function stepScript(name) {
|
|
const start = workflow.indexOf(` - name: ${name}\n`);
|
|
assert.ok(start >= 0, `missing step: ${name}`);
|
|
const body = workflow.slice(start);
|
|
const runStart = body.indexOf(" run: |\n");
|
|
assert.ok(runStart >= 0, `missing script: ${name}`);
|
|
const script = body.slice(runStart + " run: |\n".length).split("\n - name:")[0];
|
|
return script.split("\n").map((line) => line.replace(/^ {10}/, "")).join("\n");
|
|
}
|
|
|
|
function executeStep(name, overrides = {}) {
|
|
const directory = mkdtempSync(path.join(tmpdir(), "paperclip-routing-test-"));
|
|
const output = path.join(directory, "output");
|
|
try {
|
|
const gh = path.join(directory, "gh");
|
|
writeFileSync(gh, githubStub);
|
|
chmodSync(gh, 0o700);
|
|
const result = spawnSync("bash", ["-c", stepScript(name)], {
|
|
encoding: "utf8",
|
|
env: {
|
|
...process.env,
|
|
PATH: `${directory}:${process.env.PATH}`,
|
|
GITHUB_OUTPUT: output,
|
|
RUNNER_TEMP: directory,
|
|
TEST_OWNER_HELPER: path.resolve("scripts/ci-profile/authorize.mjs"),
|
|
TEST_CODEOWNERS_BASE64: Buffer.from(".github/** @ci-owner\n").toString("base64"),
|
|
AWS_CI_ENABLED: "true",
|
|
TRUSTED_USER_IDS: "[34892728]",
|
|
EVENT_NAME: "pull_request",
|
|
EVENT_REPOSITORY: "paperclipai/paperclip",
|
|
EVENT_REPOSITORY_ID: "1170821064",
|
|
EVENT_ACTION: "synchronize",
|
|
EVENT_PR_NUMBER: "12350",
|
|
EVENT_PR_AUTHOR_ID: "34892728",
|
|
EVENT_SENDER_ID: "34892728",
|
|
EVENT_BASE_REPOSITORY_ID: "1170821064",
|
|
EVENT_BASE_REF: "master",
|
|
EVENT_BASE_SHA: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
|
EVENT_HEAD_SHA: "1111111111111111111111111111111111111111",
|
|
EVENT_MERGE_SHA: "2222222222222222222222222222222222222222",
|
|
RUN_ID: "123456789",
|
|
RUN_ATTEMPT: "1",
|
|
...overrides,
|
|
},
|
|
});
|
|
assert.equal(result.status, 0, result.stderr);
|
|
const lines = readFileSync(output, "utf8").trim().split("\n");
|
|
assert.equal(lines.length, 1, "each step must emit exactly one decision");
|
|
return Object.fromEntries(lines.map((line) => {
|
|
const separator = line.indexOf("=");
|
|
return [line.slice(0, separator), line.slice(separator + 1)];
|
|
}));
|
|
} finally {
|
|
rmSync(directory, { recursive: true, force: true });
|
|
}
|
|
}
|
|
|
|
const awsRunner = "runs-on/fleet=paperclip-public-pr-x64/env=public-ci";
|
|
const stackedBase = {
|
|
EVENT_BASE_REF: "trusted-stack-base",
|
|
TEST_BASE_REF: "trusted-stack-base",
|
|
TEST_PR_BASE_SHA: "7777777777777777777777777777777777777777",
|
|
TEST_LIVE_BASE_REF_SHA: "7777777777777777777777777777777777777777",
|
|
TEST_SYNTHETIC_BASE_MERGE_SHA: "8888888888888888888888888888888888888888",
|
|
TEST_EVENT_MERGE_BASE_SHA: "8888888888888888888888888888888888888888",
|
|
TEST_LIVE_MERGE_BASE_SHA: "8888888888888888888888888888888888888888",
|
|
};
|
|
|
|
const routeCases = [
|
|
["allowlisted PR", {}, awsRunner],
|
|
["allowlisted profile label", { EVENT_ACTION: "labeled", EVENT_LABEL_NAME: "profile-ci" }, awsRunner],
|
|
["unrelated label", { EVENT_ACTION: "labeled", EVENT_LABEL_NAME: "documentation" }],
|
|
["validated stacked base", stackedBase, awsRunner],
|
|
["lagging PR API base snapshot", { TEST_PR_BASE_SHA: "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" }, awsRunner],
|
|
["disabled AWS", { AWS_CI_ENABLED: "false" }],
|
|
["missing AWS variables", { AWS_CI_ENABLED: "", TRUSTED_USER_IDS: "" }],
|
|
["unlisted author", { EVENT_PR_AUTHOR_ID: "99999999" }],
|
|
["unlisted sender", { EVENT_SENDER_ID: "99999999" }],
|
|
["unlisted rerun actor", { TEST_TRIGGERING_ACTOR_ID: "99999999" }],
|
|
["allowlisted user removed from CODEOWNERS", { TEST_CI_OWNER_ID: "99999999" }],
|
|
["CODEOWNER not on numeric allowlist", { TRUSTED_USER_IDS: "[99999999]" }],
|
|
["non-owner PR with owner rerun", { EVENT_PR_AUTHOR_ID: "99999999", TEST_PR_AUTHOR_ID: "99999999", TRUSTED_USER_IDS: "[34892728,99999999]" }],
|
|
["non-owner event sender", { EVENT_SENDER_ID: "99999999", TRUSTED_USER_IDS: "[34892728,99999999]" }],
|
|
["non-owner rerun actor", { TEST_TRIGGERING_ACTOR_ID: "99999999", TRUSTED_USER_IDS: "[34892728,99999999]" }],
|
|
["CODEOWNERS unavailable", { TEST_CODEOWNERS_FAIL: "1" }],
|
|
["owner identity unavailable", { TEST_OWNER_LOOKUP_FAIL: "1" }],
|
|
["owner is not a person", { TEST_CI_OWNER_TYPE: "Bot" }],
|
|
["trusted helper unavailable", { TEST_OWNER_HELPER_FAIL: "1" }],
|
|
["trusted master unavailable", { TEST_MASTER_FAIL: "1" }],
|
|
["invalid trusted master", { TEST_TRUSTED_MASTER_SHA: "bad" }],
|
|
["documentation owners do not authorize CI", { TEST_CODEOWNERS_BASE64: Buffer.from("doc/** @ci-owner\n").toString("base64") }],
|
|
["ambiguous CODEOWNERS deny access", { TEST_CODEOWNERS_BASE64: Buffer.from(".github/** @ci-owner\n/.github/** @ci-owner\n").toString("base64") }],
|
|
["malformed run attempt", { RUN_ATTEMPT: "bad" }],
|
|
["wrong run attempt", { TEST_RUN_ATTEMPT: "2" }],
|
|
["owner rerun validates its own attempt", { RUN_ATTEMPT: "2", TEST_RUN_ATTEMPT: "2" }, awsRunner],
|
|
["missing base", { EVENT_BASE_REF: "" }],
|
|
["wrong base repository", { EVENT_BASE_REPOSITORY_ID: "999999999" }],
|
|
["replaced base ancestry", { TEST_BASE_COMPARISON_MERGE_BASE_SHA: "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" }],
|
|
["stale head", { TEST_PR_HEAD_SHA: "3333333333333333333333333333333333333333" }],
|
|
["changed merge head", { TEST_LIVE_MERGE_HEAD_SHA: "3333333333333333333333333333333333333333" }],
|
|
["stacked base with wrong parent", { ...stackedBase, TEST_SYNTHETIC_BASE_REF_PARENT_SHA: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }],
|
|
["changed merge tree", { TEST_LIVE_MERGE_TREE_SHA: "6666666666666666666666666666666666666666" }],
|
|
["wrong repository", { EVENT_REPOSITORY_ID: "999999999" }],
|
|
["malformed allowlist", { TRUSTED_USER_IDS: '["34892728"]' }],
|
|
["manual dispatch", { EVENT_NAME: "workflow_dispatch" }],
|
|
["unsupported PR action", { EVENT_ACTION: "closed" }],
|
|
["malformed commit SHA", { EVENT_HEAD_SHA: "invalid" }],
|
|
];
|
|
|
|
for (const [name, env, expected = "ubuntu-latest"] of routeCases) {
|
|
test(`runner decision: ${name}`, () => {
|
|
assert.equal(executeStep("Validate PR identity and select runner", env).runner, expected);
|
|
});
|
|
}
|
|
|
|
const scopeCases = [
|
|
["ordinary PR", null, "master", "true"],
|
|
["top stack PR", { position: 11, size: 11, base: { ref: "master" } }, "stack-10", "true"],
|
|
["lowest unmerged PR", { position: 1, size: 11, base: { ref: "master" } }, "master", "true"],
|
|
["middle stack PR", { position: 6, size: 11, base: { ref: "master" } }, "stack-5", "false"],
|
|
["malformed position", { position: "invalid", size: 11, base: { ref: "master" } }, "stack-5", "true"],
|
|
["out-of-range position", { position: 12, size: 11, base: { ref: "master" } }, "stack-5", "true"],
|
|
["missing stack base", { position: 6, size: 11 }, "stack-5", "true"],
|
|
["empty metadata", {}, "master", "true"],
|
|
];
|
|
|
|
for (const [name, stack, base, expected] of scopeCases) {
|
|
test(`scope decision: ${name}`, () => {
|
|
assert.equal(executeStep("Select PR CI scope", {
|
|
STACK_JSON: JSON.stringify(stack), PR_BASE_REF: base,
|
|
}).full_ci, expected);
|
|
});
|
|
}
|
|
|
|
const files = (...paths) => JSON.stringify(paths.map((filename) => ({ filename })));
|
|
|
|
test("full-suite requests override both middle-stack and release-notes-only skips", () => {
|
|
for (const overrides of [
|
|
{ STACK_JSON: JSON.stringify({ position: 2, size: 3, base: { ref: "master" } }), PR_BASE_REF: "stack-1" },
|
|
{ STACK_JSON: "null", PR_BASE_REF: "master", TEST_COMPARE_FILES: files("releases/v2026.1015.0.md") },
|
|
]) {
|
|
assert.equal(executeStep("Select PR CI scope", { ...overrides, PROFILE_CI: "false" }).full_ci, "false");
|
|
for (const request of [{ PROFILE_CI: "true" }, { FORCE_FULL_CI: "true" }, { CI_INCREMENTAL_MODE: "full" }]) {
|
|
assert.equal(executeStep("Select PR CI scope", { ...overrides, ...request }).full_ci, "true");
|
|
}
|
|
}
|
|
});
|
|
const manyReleaseNotes = JSON.stringify(Array.from({ length: 300 }, (_, index) => ({
|
|
filename: `releases/beta/v2026.1012.${index}-beta.0.md`,
|
|
})));
|
|
|
|
const pathScopeCases = [
|
|
["stable release notes", { TEST_COMPARE_FILES: files("releases/v2026.1015.0.md") }, "false"],
|
|
["beta release notes draft", { TEST_COMPARE_FILES: files("releases/beta/v2026.1012.1-beta.0.md") }, "false"],
|
|
["stable and beta notes", { TEST_COMPARE_FILES: files("releases/v2026.1015.0.md", "releases/beta/v2026.1012.1-beta.0.md") }, "false"],
|
|
["removed release notes", { TEST_COMPARE_FILES: JSON.stringify([{ filename: "releases/beta/v2026.1006.0-beta.0.md", status: "removed" }]) }, "false"],
|
|
["release notes and code", { TEST_COMPARE_FILES: files("releases/v2026.1015.0.md", "server/src/index.ts") }, "true"],
|
|
["code renamed into releases", { TEST_COMPARE_FILES: JSON.stringify([{ filename: "releases/v2026.1015.0.md", previous_filename: "scripts/release.sh" }]) }, "true"],
|
|
["non-markdown file in releases", { TEST_COMPARE_FILES: files("releases/beta/v2026.1012.1-beta.0.json") }, "true"],
|
|
["nested releases directory", { TEST_COMPARE_FILES: files("releases/beta/drafts/v2026.1012.1-beta.0.md") }, "true"],
|
|
["markdown outside releases", { TEST_COMPARE_FILES: files("doc/RELEASING.md") }, "true"],
|
|
["file entry without a name", { TEST_COMPARE_FILES: JSON.stringify([{ status: "modified" }]) }, "true"],
|
|
["empty diff", { TEST_COMPARE_FILES: "[]" }, "true"],
|
|
["possibly truncated file list", { TEST_COMPARE_FILES: manyReleaseNotes }, "true"],
|
|
["compare lookup failure", { TEST_COMPARE_FAIL: "1", TEST_COMPARE_FILES: files("releases/v2026.1015.0.md") }, "true"],
|
|
["non-PR event", { EVENT_NAME: "workflow_dispatch", TEST_COMPARE_FILES: files("releases/v2026.1015.0.md") }, "true"],
|
|
["malformed head SHA", { EVENT_HEAD_SHA: "invalid", TEST_COMPARE_FILES: files("releases/v2026.1015.0.md") }, "true"],
|
|
];
|
|
|
|
for (const [name, env, expected] of pathScopeCases) {
|
|
test(`path scope decision: ${name}`, () => {
|
|
assert.equal(executeStep("Select PR CI scope", {
|
|
STACK_JSON: "null", PR_BASE_REF: "master", ...env,
|
|
}).full_ci, expected);
|
|
});
|
|
}
|
|
|
|
test("path scope keeps full CI for the top PR in a stack that touches code", () => {
|
|
assert.equal(executeStep("Select PR CI scope", {
|
|
STACK_JSON: JSON.stringify({ position: 11, size: 11, base: { ref: "master" } }),
|
|
PR_BASE_REF: "stack-10",
|
|
}).full_ci, "true");
|
|
});
|
|
|
|
test("path scope keeps full CI for release notes on top of code-changing stacked PRs", () => {
|
|
assert.equal(executeStep("Select PR CI scope", {
|
|
STACK_JSON: JSON.stringify({ position: 11, size: 11, base: { ref: "master" } }),
|
|
PR_BASE_REF: "stack-10",
|
|
TEST_COMPARE_FILES: files("releases/v2026.1015.0.md"),
|
|
}).full_ci, "true");
|
|
});
|
|
|
|
test("path scope keeps full CI for release notes with malformed stack metadata", () => {
|
|
assert.equal(executeStep("Select PR CI scope", {
|
|
STACK_JSON: JSON.stringify({ position: 0, size: 2, base: { ref: "master" } }),
|
|
PR_BASE_REF: "master",
|
|
TEST_COMPARE_FILES: files("releases/v2026.1015.0.md"),
|
|
}).full_ci, "true");
|
|
});
|
|
|
|
test("path scope skips full CI for the lowest PR in a stack that only touches release notes", () => {
|
|
assert.equal(executeStep("Select PR CI scope", {
|
|
STACK_JSON: JSON.stringify({ position: 1, size: 3, base: { ref: "master" } }),
|
|
PR_BASE_REF: "master",
|
|
TEST_COMPARE_FILES: files("releases/v2026.1015.0.md"),
|
|
}).full_ci, "false");
|
|
});
|
|
|
|
test("path scope skips full CI for a single-PR stack that only touches release notes", () => {
|
|
assert.equal(executeStep("Select PR CI scope", {
|
|
STACK_JSON: JSON.stringify({ position: 1, size: 1, base: { ref: "master" } }),
|
|
PR_BASE_REF: "master",
|
|
TEST_COMPARE_FILES: files("releases/v2026.1015.0.md"),
|
|
}).full_ci, "false");
|
|
});
|