perf(ci): reuse tree-equivalent merge candidates
Nuvisphere/Platform-CI: Immutable QuickStack OCI deployment / Build once and deploy exact digest (push) Successful in 23s
Platform CI tests / QuickStack deploy action tests (push) Successful in 31s

This commit is contained in:
2026-08-26 15:16:12 +02:00
parent 0cc4f072e7
commit f520255d61
3 changed files with 100 additions and 10 deletions
@@ -1,4 +1,8 @@
import assert from "node:assert/strict";
import { execFileSync } from "node:child_process";
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import test from "node:test";
import {
@@ -17,6 +21,7 @@ import {
orderApplications,
resolveDeploymentBranch,
resolvePullRequestHeadBranch,
resolveTreeEquivalentCandidateSha,
selectDeployment,
selectPipeline,
toSavePayload,
@@ -130,6 +135,45 @@ test("same-repository pull requests publish reusable candidates while forks stay
);
});
test("tree-equivalent merge commits resolve to their tested candidate parent", () => {
const workspace = fs.mkdtempSync(path.join(os.tmpdir(), "quickstack-merge-candidate-"));
const git = (args) => execFileSync("git", args, {
cwd: workspace,
encoding: "utf8",
stdio: ["ignore", "pipe", "pipe"],
}).trim();
try {
git(["init"]);
git(["checkout", "-b", "main"]);
git(["config", "user.email", "ci@example.test"]);
git(["config", "user.name", "CI"]);
fs.writeFileSync(path.join(workspace, "app.txt"), "base\n");
git(["add", "app.txt"]);
git(["commit", "-m", "base"]);
const baseSha = git(["rev-parse", "HEAD"]);
git(["checkout", "-b", "feature"]);
fs.writeFileSync(path.join(workspace, "app.txt"), "feature\n");
git(["commit", "-am", "feature"]);
const featureSha = git(["rev-parse", "HEAD"]);
git(["checkout", "main"]);
git(["merge", "--no-ff", "feature", "-m", "merge feature"]);
const mergeSha = git(["rev-parse", "HEAD"]);
git(["checkout", "-b", "prod", baseSha]);
git(["merge", "--no-ff", "main", "-m", "merge staging"]);
const prodMergeSha = git(["rev-parse", "HEAD"]);
assert.equal(resolveTreeEquivalentCandidateSha(workspace, mergeSha), featureSha);
assert.equal(resolveTreeEquivalentCandidateSha(workspace, prodMergeSha), featureSha);
assert.equal(resolveTreeEquivalentCandidateSha(workspace, featureSha), featureSha);
assert.equal(
resolveTreeEquivalentCandidateSha(workspace, mergeSha, { requireTreeMatch: false }),
mergeSha,
);
} finally {
fs.rmSync(workspace, { recursive: true, force: true });
}
});
test("validates split action modes and artifact build slots", () => {
assert.equal(resolveActionMode(undefined), "all");
assert.equal(resolveActionMode("BUILD"), "build");