fix: use clean v02 render worktree
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { gitMirrorFlushJobManifest, gitMirrorSyncJobManifest, gitMirrorV02SyncRequirement, hwlabG14MonitorStateFileName, parseGitMirrorStatusRefs, parsePipelineTaskRunMetrics, rolloutRecordBody, semanticChangelogBullets, v02PipelineServiceIds } from "./src/hwlab-g14";
|
||||
import { gitMirrorFlushJobManifest, gitMirrorSyncJobManifest, gitMirrorV02SyncRequirement, hwlabG14MonitorStateFileName, parseGitMirrorStatusRefs, parsePipelineTaskRunMetrics, rolloutRecordBody, semanticChangelogBullets, v02ControlPlaneRenderScript, v02PipelineServiceIds } from "./src/hwlab-g14";
|
||||
|
||||
function assertCondition(condition: unknown, message: string, detail: unknown = {}): void {
|
||||
if (!condition) throw new Error(`${message}: ${JSON.stringify(detail)}`);
|
||||
@@ -61,6 +61,17 @@ assertCondition(
|
||||
gitMirrorV02SyncRequirement("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", gitMirrorStatusRaw).required === true,
|
||||
"trigger-current must sync mirror before creating PipelineRun when local v0.2 is stale",
|
||||
);
|
||||
const renderScript = v02ControlPlaneRenderScript("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
|
||||
assertCondition(
|
||||
renderScript.includes("git worktree add --detach") && renderScript.includes("/tmp/hwlab-v02-control-plane-source-aaaaaaaaaaaa"),
|
||||
"v0.2 control-plane render must use a detached temp worktree",
|
||||
renderScript,
|
||||
);
|
||||
assertCondition(
|
||||
!renderScript.includes("git merge --ff-only origin/v0.2") && !renderScript.includes("git checkout v0.2"),
|
||||
"v0.2 control-plane render must not require fixed workspace checkout/merge and clean status",
|
||||
renderScript,
|
||||
);
|
||||
assertCondition(
|
||||
!v02PipelineServiceIds().includes("hwlab-cli"),
|
||||
"v0.2 PipelineRun service matrix must not build hwlab-cli because cli is short-connection source tool",
|
||||
@@ -173,6 +184,7 @@ console.log(JSON.stringify({
|
||||
"git mirror sync is a manual devops-infra Job, not a CronJob",
|
||||
"git mirror flush is a manual devops-infra Job, not a CronJob",
|
||||
"trigger-current can decide whether v0.2 git mirror pre-sync is required",
|
||||
"v0.2 control-plane render uses a detached temp worktree",
|
||||
"v0.2 PipelineRun service matrix excludes hwlab-cli",
|
||||
"rollout brief includes natural-language changelog before automatic diff summary",
|
||||
"semantic changelog extracts Chinese summary sections",
|
||||
|
||||
@@ -1168,24 +1168,38 @@ function runControlPlaneCleanup(options: G14ControlPlaneOptions): Record<string,
|
||||
};
|
||||
}
|
||||
|
||||
function runV02RenderToTemp(sourceCommit: string): CommandJsonResult {
|
||||
export function v02ControlPlaneRenderScript(sourceCommit: string): string {
|
||||
const renderDir = v02RenderDir(sourceCommit);
|
||||
return v02WorkspaceScript([
|
||||
const worktreeDir = v02RenderWorktreeDir(sourceCommit);
|
||||
return [
|
||||
"set -eu",
|
||||
`render_dir=${shellQuote(renderDir)}`,
|
||||
`worktree_dir=${shellQuote(worktreeDir)}`,
|
||||
"cleanup_render_worktree() { git worktree remove --force \"$worktree_dir\" >/dev/null 2>&1 || rm -rf \"$worktree_dir\"; }",
|
||||
"trap cleanup_render_worktree EXIT",
|
||||
"git fetch origin v0.2 --prune",
|
||||
"git checkout v0.2 >/dev/null 2>&1 || true",
|
||||
"git merge --ff-only origin/v0.2",
|
||||
`test "$(git rev-parse HEAD)" = ${shellQuote(sourceCommit)}`,
|
||||
`rm -rf ${shellQuote(renderDir)}`,
|
||||
`mkdir -p ${shellQuote(renderDir)}`,
|
||||
`node scripts/g14-gitops-render.mjs --lane v02 --source-revision ${shellQuote(sourceCommit)} --out ${shellQuote(renderDir)}`,
|
||||
].join("\n"), 180_000);
|
||||
`test "$(git rev-parse origin/v0.2)" = ${shellQuote(sourceCommit)}`,
|
||||
"cleanup_render_worktree",
|
||||
"rm -rf \"$render_dir\"",
|
||||
"mkdir -p \"$render_dir\" \"$(dirname \"$worktree_dir\")\"",
|
||||
`git worktree add --detach "$worktree_dir" ${shellQuote(sourceCommit)}`,
|
||||
"cd \"$worktree_dir\"",
|
||||
`node scripts/g14-gitops-render.mjs --lane v02 --source-revision ${shellQuote(sourceCommit)} --out "$render_dir"`,
|
||||
].join("\n");
|
||||
}
|
||||
|
||||
function runV02RenderToTemp(sourceCommit: string): CommandJsonResult {
|
||||
return v02WorkspaceScript(v02ControlPlaneRenderScript(sourceCommit), 180_000);
|
||||
}
|
||||
|
||||
function v02RenderDir(sourceCommit: string): string {
|
||||
return `/tmp/hwlab-v02-control-plane-${shortSha(sourceCommit)}`;
|
||||
}
|
||||
|
||||
function v02RenderWorktreeDir(sourceCommit: string): string {
|
||||
return `/tmp/hwlab-v02-control-plane-source-${shortSha(sourceCommit)}`;
|
||||
}
|
||||
|
||||
function applyV02ControlPlaneFiles(sourceCommit: string, dryRun: boolean, timeoutSeconds: number): CommandJsonResult {
|
||||
const renderDir = v02RenderDir(sourceCommit);
|
||||
return g14K3s([
|
||||
|
||||
Reference in New Issue
Block a user