Enforce external plugin ref/sha consistency (#2463)

* Enforce external plugin ref/sha consistency

Extract shared ref/sha normalization and consistency checks into eng/lib and reuse them in intake plus quality gate flows.

Add a dedicated ref/sha consistency quality gate surfaced in PR/intake summaries, and add targeted tests for matching and mismatched refs.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 6afe21ad-eafa-4c90-a1f2-053dedac7625

* Address review: tree/blob ref errors and PR workflow ref/sha column

- resolveCommitShaAtReadRef: classify rev-parse failure as 'fail'
  instead of 'infra_error' because a successfully-fetched ref that
  doesn't dereference to a commit is a submitter problem, not infra.
- validateRemoteRepository (intake): treat HTTP 422 from the commit
  endpoint as a submitter error; all other non-404 errors remain
  transient warnings requiring maintainer re-run.
- external-plugin-pr-quality-gates.yml: add ref/sha consistency
  column to the per-plugin quality table and failure details block.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6afe21ad-eafa-4c90-a1f2-053dedac7625

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6afe21ad-eafa-4c90-a1f2-053dedac7625
This commit is contained in:
Aaron Powell
2026-07-29 15:28:13 +10:00
committed by GitHub
parent 1e14bd4faa
commit 8ae5a99109
7 changed files with 397 additions and 8 deletions
+36 -1
View File
@@ -4,7 +4,7 @@ import os from "os";
import path from "path";
import { spawnSync } from "child_process";
import { after, test } from "node:test";
import { runCanvasStructureGate, runVersionMatchGate } from "./external-plugin-quality-gates.mjs";
import { runCanvasStructureGate, runRefShaConsistencyGate, runVersionMatchGate } from "./external-plugin-quality-gates.mjs";
const tempDirs = [];
@@ -298,3 +298,38 @@ test("runCanvasStructureGate passes when the primary locator is a tag ref", () =
assert.equal(result.status, "pass", result.output);
assert.match(result.output, /- v1\.0\.0: found "extensions"/);
});
test("runRefShaConsistencyGate fails when ref and sha point to different commits", () => {
const remoteDir = initRemoteRepo();
writeValidPluginContent(remoteDir);
const firstSha = commitAll(remoteDir, "Add plugin manifest v1");
runGit(remoteDir, "tag", "-a", "v1.0.0", "-m", "release 1.0.0");
fs.writeFileSync(path.join(remoteDir, "README.md"), "v2\n");
const secondSha = commitAll(remoteDir, "Add plugin manifest v2");
const repoDir = cloneSubmissionRepo(remoteDir, secondSha);
const plugin = {
name: "tag-plugin",
source: { source: "github", repo: "owner/repo", ref: "v1.0.0", sha: secondSha },
};
const result = runRefShaConsistencyGate(repoDir, plugin, secondSha);
assert.equal(result.status, "fail", result.output);
assert.match(result.output, new RegExp(`resolves to "${firstSha}"`));
});
test("runRefShaConsistencyGate passes when ref and sha point to the same commit", () => {
const remoteDir = initRemoteRepo();
writeValidPluginContent(remoteDir);
const sha = commitAll(remoteDir, "Add plugin manifest");
runGit(remoteDir, "tag", "-a", "v1.0.0", "-m", "release 1.0.0");
const repoDir = cloneSubmissionRepo(remoteDir, sha);
const plugin = {
name: "tag-plugin",
source: { source: "github", repo: "owner/repo", ref: "v1.0.0", sha },
};
const result = runRefShaConsistencyGate(repoDir, plugin, sha);
assert.equal(result.status, "pass", result.output);
});