feat: add v02 git write mirror relay
This commit is contained in:
@@ -61,6 +61,9 @@ test("v02 render follows TypeScript runtime checks and does not self-patch boots
|
||||
assert.match(gitopsPromoteScript, /BatchMode=yes/u);
|
||||
assert.match(gitopsPromoteScript, /ConnectTimeout=10/u);
|
||||
assert.match(gitopsPromoteScript, /git_timed "source-head-\$phase" 45 git ls-remote/u);
|
||||
assert.match(gitopsPromoteScript, /source_head_url="\$\(params\.git-read-url\)"/u);
|
||||
assert.match(gitopsPromoteScript, /gitops_write_url="\$\(params\.git-write-url\)"/u);
|
||||
assert.match(gitopsPromoteScript, /git clone --no-checkout "\$gitops_read_url"/u);
|
||||
assert.match(gitopsPromoteScript, /git_timed gitops-push 120 git push origin/u);
|
||||
|
||||
const prepareSource = taskByName(pipelineJson, "prepare-source");
|
||||
@@ -74,19 +77,28 @@ test("v02 render follows TypeScript runtime checks and does not self-patch boots
|
||||
|
||||
const pipelineGitReadParam = pipelineJson.spec.params.find((param) => param.name === "git-read-url");
|
||||
assert.equal(pipelineGitReadParam?.default, "http://git-mirror-http.devops-infra.svc.cluster.local/pikasTech/HWLAB.git");
|
||||
const pipelineGitWriteParam = pipelineJson.spec.params.find((param) => param.name === "git-write-url");
|
||||
assert.equal(pipelineGitWriteParam?.default, "http://git-mirror-write.devops-infra.svc.cluster.local/pikasTech/HWLAB.git");
|
||||
|
||||
const sourceDescriptor = JSON.parse(await readFile(path.join(outDir, "source.json"), "utf8"));
|
||||
assert.equal(sourceDescriptor.gitReadUrl, "http://git-mirror-http.devops-infra.svc.cluster.local/pikasTech/HWLAB.git");
|
||||
assert.equal(sourceDescriptor.gitWriteUrl, "http://git-mirror-write.devops-infra.svc.cluster.local/pikasTech/HWLAB.git");
|
||||
|
||||
const gitMirror = await readFile(path.join(outDir, "devops-infra", "git-mirror.yaml"), "utf8");
|
||||
assert.match(gitMirror, /"name": "devops-infra"/u);
|
||||
assert.match(gitMirror, /"name": "git-mirror-http"/u);
|
||||
assert.match(gitMirror, /"name": "git-mirror-write"/u);
|
||||
assert.match(gitMirror, /"name": "git-mirror-sync-script"/u);
|
||||
assert.match(gitMirror, /git-receive-pack/u);
|
||||
assert.match(gitMirror, /last-flush\.json/u);
|
||||
assert.match(gitMirror, /last-write\.json/u);
|
||||
assert.match(gitMirror, /ssh:\/\/git@ssh\.github\.com:443\/pikasTech\/HWLAB\.git/u);
|
||||
assert.doesNotMatch(gitMirror, /"kind": "CronJob"/u);
|
||||
assert.doesNotMatch(gitMirror, /"name": "git-mirror-hwlab-sync"/u);
|
||||
const gitMirrorJson = JSON.parse(gitMirror);
|
||||
const gitMirrorScript = gitMirrorJson.items.find((item) => item.kind === "ConfigMap" && item.metadata?.name === "git-mirror-sync-script")?.data?.["sync.sh"] ?? "";
|
||||
const gitMirrorConfigMap = gitMirrorJson.items.find((item) => item.kind === "ConfigMap" && item.metadata?.name === "git-mirror-sync-script");
|
||||
const gitMirrorScripts = gitMirrorConfigMap?.data ?? {};
|
||||
const gitMirrorScript = gitMirrorScripts["sync.sh"] ?? "";
|
||||
assert.match(gitMirrorScript, /refs\/heads\/v0\.2:refs\/mirror-stage\/heads\/v0\.2/u);
|
||||
assert.match(gitMirrorScript, /refs\/heads\/v0\.2-gitops:refs\/mirror-stage\/heads\/v0\.2-gitops/u);
|
||||
assert.match(gitMirrorScript, /refs\/heads\/G14:refs\/mirror-stage\/heads\/G14/u);
|
||||
@@ -96,10 +108,24 @@ test("v02 render follows TypeScript runtime checks and does not self-patch boots
|
||||
assert.match(gitMirrorScript, /git-mirror-sync-timing/u);
|
||||
assert.match(gitMirrorScript, /emit_timing fetch succeeded/u);
|
||||
assert.match(gitMirrorScript, /emit_timing total succeeded/u);
|
||||
assert.match(gitMirrorScript, /keeps local v0\.2-gitops ahead of GitHub/u);
|
||||
assert.ok((gitMirrorJson.items || []).every((item) => item.kind !== "Secret"));
|
||||
assert.ok((gitMirrorJson.items || []).every((item) => item.kind !== "CronJob"));
|
||||
assert.ok((gitMirrorJson.items || []).every((item) => !item.data?.["ssh-privatekey"]));
|
||||
|
||||
const scriptCheckDir = path.join(outDir, "script-check");
|
||||
await mkdir(scriptCheckDir, { recursive: true });
|
||||
for (const scriptName of ["http.mjs", "sync.sh", "install-hooks.sh", "flush.sh"]) {
|
||||
assert.ok(gitMirrorScripts[scriptName], `missing git mirror script ${scriptName}`);
|
||||
await writeFile(path.join(scriptCheckDir, scriptName), gitMirrorScripts[scriptName]);
|
||||
}
|
||||
const httpCheck = spawnSync("node", ["--check", path.join(scriptCheckDir, "http.mjs")], { encoding: "utf8" });
|
||||
assert.equal(httpCheck.status, 0, httpCheck.stderr || httpCheck.stdout);
|
||||
for (const scriptName of ["sync.sh", "install-hooks.sh", "flush.sh"]) {
|
||||
const shellCheck = spawnSync("sh", ["-n", path.join(scriptCheckDir, scriptName)], { encoding: "utf8" });
|
||||
assert.equal(shellCheck.status, 0, `${scriptName}: ${shellCheck.stderr || shellCheck.stdout}`);
|
||||
}
|
||||
|
||||
const removedServiceIds = [
|
||||
"hwlab-router",
|
||||
"hwlab-tunnel-client",
|
||||
@@ -177,6 +203,8 @@ test("v02 render follows TypeScript runtime checks and does not self-patch boots
|
||||
|
||||
const application = await readFile(path.join(outDir, "argocd", "application-v02.yaml"), "utf8");
|
||||
assert.match(application, /"prune": true/u);
|
||||
assert.match(application, /git-mirror-http\.devops-infra\.svc\.cluster\.local/u);
|
||||
assert.doesNotMatch(application, /git@github\.com:pikasTech\/HWLAB\.git/u);
|
||||
|
||||
for (const generatedFile of ["deepseek-proxy.yaml", "postgres.yaml", "g14-frpc.yaml"]) {
|
||||
const content = await readFile(path.join(outDir, "runtime-v02", generatedFile), "utf8");
|
||||
@@ -188,6 +216,7 @@ test("v02 render follows TypeScript runtime checks and does not self-patch boots
|
||||
|
||||
const pipelineRunSample = await readFile(path.join(outDir, "tekton-v02", "pipelinerun.sample.yaml"), "utf8");
|
||||
assert.match(pipelineRunSample, /"name": "git-read-url"[\s\S]{0,140}git-mirror-http\.devops-infra\.svc\.cluster\.local/u);
|
||||
assert.match(pipelineRunSample, /"name": "git-write-url"[\s\S]{0,140}git-mirror-write\.devops-infra\.svc\.cluster\.local/u);
|
||||
assert.match(pipelineRunSample, /"name": "revision"[\s\S]{0,80}"value": "[0-9a-f]{40}"/u);
|
||||
assert.match(pipelineRunSample, /"name": "source-branch"[\s\S]{0,80}"value": "v0\.2"/u);
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user