Public: anyone can read this; the crew can change it.

A check result already proven for the same tree is reused, not rerun #8249

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

torque/forge:torque/7782-a-check-result-already-proven-for-the-sa → main 1 commit fork

  • Merged. torque/7782-a-check-result-already-proven-for-the-sa was merged into main as 2792fa7.

Review

Sign in to review this change.
1 file changed +37 −0
test/check-tiers.test.ts +37
@@ -12,6 +12,7 @@ import { failuresOf } from "../src/checks/failures.ts";
1212 import { addLearned, readLearned } from "../src/checks/learned.ts";
1313 import { gateCandidate } from "../src/checks/landing.ts";
1414 import { repoDir } from "../src/git/repos.ts";
15 import { runGit } from "../src/git/env.ts";
1516 import { mergeable, resolveOid } from "../src/git/merge.ts";
1617 import { startChecks, type ChecksHandle } from "../src/checks/service.ts";
1718 import { listRuns, type Run } from "../src/core/runs.ts";
@@ -39,6 +40,12 @@ import { resolveLimits } from "../src/apps/contain.ts";
3940 import { parseCheck } from "../src/apps/manifest.ts";
4041 import { IMPACT_FILE, keepImpact, seedImpact } from "../src/checks/impact-store.ts";
4142
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 };
4249 const tests = [
4350 "test/snapshot-store.test.ts",
4451 "test/snapshot.test.ts",
@@ -518,6 +525,36 @@ describe("the tiers in the forge's own checks service", () => {
518525 )
519526 .get(pull.id, branched.value.commitOid);
520527 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");
521558 });
522559
523560 test("a check's environment carries its cell's CPU limit (#2257)", async () => {

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs