Public: anyone can read this; the crew can change it.
A check result already proven for the same tree is reused, not rerun #8249
Check · Review · Land · Live done — Landed and live in production.
torque/forge:torque/7782-a-check-result-already-proven-for-the-sa → main 1 commit fork
1 file
changed +37
−0
test/check-tiers.test.ts +37
| @@ -12,6 +12,7 @@ import { failuresOf } from "../src/checks/failures.ts"; | ||
| 12 | 12 | import { addLearned, readLearned } from "../src/checks/learned.ts"; |
| 13 | 13 | import { gateCandidate } from "../src/checks/landing.ts"; |
| 14 | 14 | import { repoDir } from "../src/git/repos.ts"; |
| 15 | import { runGit } from "../src/git/env.ts"; | |
| 15 | 16 | import { mergeable, resolveOid } from "../src/git/merge.ts"; |
| 16 | 17 | import { startChecks, type ChecksHandle } from "../src/checks/service.ts"; |
| 17 | 18 | import { listRuns, type Run } from "../src/core/runs.ts"; |
| @@ -39,6 +40,12 @@ import { resolveLimits } from "../src/apps/contain.ts"; | ||
| 39 | 40 | import { parseCheck } from "../src/apps/manifest.ts"; |
| 40 | 41 | import { IMPACT_FILE, keepImpact, seedImpact } from "../src/checks/impact-store.ts"; |
| 41 | 42 | |
| 43 | const IDENT = { | |
| 44 | GIT_AUTHOR_NAME: "t", | |
| 45 | GIT_AUTHOR_EMAIL: "[email protected]", | |
| 46 | GIT_COMMITTER_NAME: "t", | |
| 47 | GIT_COMMITTER_EMAIL: "[email protected]", | |
| 48 | }; | |
| 42 | 49 | const tests = [ |
| 43 | 50 | "test/snapshot-store.test.ts", |
| 44 | 51 | "test/snapshot.test.ts", |
| @@ -518,6 +525,36 @@ describe("the tiers in the forge's own checks service", () => { | ||
| 518 | 525 | ) |
| 519 | 526 | .get(pull.id, branched.value.commitOid); |
| 520 | 527 | expect(traced?.n).toBe(2); |
| 528 | ||
| 529 | // The same tree under another commit — a batch of one is a new squash of | |
| 530 | // the same files — is the same verdict: it names the run it came from and | |
| 531 | // runs nothing (#7782). | |
| 532 | const bare = repoDir(app.reposRoot, repo.ownerName, repo.name); | |
| 533 | const head = branched.value.commitOid; | |
| 534 | const treeOid = (await runGit(["rev-parse", `${head}^{tree}`], { cwd: bare })); | |
| 535 | if (!treeOid.ok) throw new Error("no tree"); | |
| 536 | const squash = await runGit(["commit-tree", treeOid.value, "-m", "Squash of the pull"], { cwd: bare, env: IDENT }); | |
| 537 | if (!squash.ok) throw new Error("no commit"); | |
| 538 | expect(squash.value).not.toBe(head); | |
| 539 | const batch = await checks.gate(repo, pull, squash.value); | |
| 540 | expect(batch.ok).toBe(true); | |
| 541 | expect(batch.lines.join("\n")).toContain("already proven green by gate-"); | |
| 542 | expect(batch.lines.join("\n")).not.toContain("FULL-GREEN"); | |
| 543 | ||
| 544 | // Another tree is another question: it runs. | |
| 545 | const blob = await runGit(["hash-object", "-w", "--stdin"], { cwd: bare, stdin: "other\n" }); | |
| 546 | if (!blob.ok) throw new Error("no blob"); | |
| 547 | const index = join(dataDir, "tree-index"); | |
| 548 | const env = { GIT_INDEX_FILE: index }; | |
| 549 | await runGit(["read-tree", treeOid.value], { cwd: bare, env }); | |
| 550 | await runGit(["update-index", "--add", "--cacheinfo", `100644,${blob.value},other.txt`], { cwd: bare, env }); | |
| 551 | const changed = await runGit(["write-tree"], { cwd: bare, env }); | |
| 552 | if (!changed.ok) throw new Error("no tree"); | |
| 553 | const other = await runGit(["commit-tree", changed.value, "-m", "Another tree"], { cwd: bare, env: IDENT }); | |
| 554 | if (!other.ok) throw new Error("no commit"); | |
| 555 | const rerun = await checks.gate(repo, pull, other.value); | |
| 556 | expect(rerun.ok).toBe(true); | |
| 557 | expect(rerun.lines.join("\n")).toContain("FULL-GREEN"); | |
| 521 | 558 | }); |
| 522 | 559 | |
| 523 | 560 | test("a check's environment carries its cell's CPU limit (#2257)", async () => { |
new above
offline