ci: reuse candidates for production pull requests
Platform CI tests / QuickStack deploy action tests (push) Successful in 27s
Nuvisphere/Platform-CI: Immutable QuickStack OCI deployment / Build once and deploy exact digest (push) Successful in 28s

This commit is contained in:
2026-08-20 16:30:23 +02:00
parent a4247d2697
commit f4ffb28018
3 changed files with 91 additions and 6 deletions
@@ -2,16 +2,19 @@ import assert from "node:assert/strict";
import test from "node:test";
import {
classifyVersion2Execution,
deployExactImage,
expandTokens,
mergeEnvironment,
orderApplications,
resolveDeploymentBranch,
resolvePullRequestHeadBranch,
selectDeployment,
selectPipeline,
toSavePayload,
validateArtifact,
validateApplication,
validatePromotionPullRequestSource,
validateTarget,
validateVersion2Pipeline,
verifyEndpoint,
@@ -62,6 +65,39 @@ test("resolves push and pull request deployment branches without accepting empty
);
});
test("resolves the pull request head branch from direct and payload context", () => {
assert.equal(
resolvePullRequestHeadBranch({ environment: { GITHUB_HEAD_REF: "staging" } }),
"staging",
);
assert.equal(
resolvePullRequestHeadBranch({
environment: {},
eventPayload: { pull_request: { head: { ref: "release-candidate" } } },
}),
"release-candidate",
);
assert.throws(
() => resolvePullRequestHeadBranch({ environment: {}, eventPayload: {} }),
/Pull request head branch/,
);
});
test("production pull requests validate tested candidates without rebuilding", () => {
assert.equal(classifyVersion2Execution({ strategy: "candidate" }, "pull_request"), "build-validation");
assert.equal(classifyVersion2Execution({ strategy: "candidate" }, "push"), "build-deploy");
assert.equal(classifyVersion2Execution({ strategy: "promote" }, "pull_request"), "validate-candidate");
assert.equal(classifyVersion2Execution({ strategy: "promote" }, "push"), "promote");
assert.equal(
validatePromotionPullRequestSource({ source: { branch: "staging" } }, "staging"),
"staging",
);
assert.throws(
() => validatePromotionPullRequestSource({ source: { branch: "staging" } }, "feature"),
/must originate from staging, not feature/,
);
});
test("validates OCI paths and repository-local build paths", () => {
assert.equal(validateTarget({ name: "Web", image: "Owner/Web", appId: "app-1" }).image, "owner/web");
assert.throws(() => validateTarget({ name: "Web", image: "owner/web", appId: "app-1", context: "../secret" }), /inside/);