fix: read v02 ci source from git mirror

This commit is contained in:
Codex
2026-05-29 21:45:24 +08:00
parent 9deffc415d
commit 9e4fd3f758
2 changed files with 183 additions and 8 deletions
+26 -2
View File
@@ -64,9 +64,27 @@ test("v02 render follows TypeScript runtime checks and does not self-patch boots
assert.match(gitopsPromoteScript, /git_timed gitops-push 120 git push origin/u);
const prepareSource = taskByName(pipelineJson, "prepare-source");
assert.ok(prepareSource.taskSpec.params.some((param) => param.name === "git-read-url"));
assert.ok(prepareSource.params.some((param) => param.name === "git-read-url" && param.value === "$(params.git-read-url)"));
const prepareSourceScript = prepareSource.taskSpec.steps[0].script;
assert.match(prepareSourceScript, /git_timed source-clone 180 git clone/u);
assert.match(prepareSourceScript, /git_timed catalog-ls-remote 45 git ls-remote/u);
assert.match(prepareSourceScript, /git_read_url="\$\(params\.git-read-url\)"/u);
assert.match(prepareSourceScript, /git_timed source-clone 180 git clone --branch "\$\(params\.source-branch\)" "\$git_read_url"/u);
assert.match(prepareSourceScript, /git_timed catalog-ls-remote 45 git ls-remote --exit-code --heads "\$\(params\.git-url\)"/u);
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 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");
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-hwlab-sync"/u);
assert.match(gitMirror, /ssh:\/\/git@ssh\.github\.com:443\/pikasTech\/HWLAB\.git/u);
const gitMirrorJson = JSON.parse(gitMirror);
assert.ok((gitMirrorJson.items || []).every((item) => item.kind !== "Secret"));
assert.ok((gitMirrorJson.items || []).every((item) => !item.data?.["ssh-privatekey"]));
const removedServiceIds = [
"hwlab-router",
@@ -138,6 +156,12 @@ test("v02 render follows TypeScript runtime checks and does not self-patch boots
const reconciler = await readFile(path.join(outDir, "tekton-v02", "control-plane-reconciler.yaml"), "utf8");
assert.match(reconciler, /cross-namespace-rbac-bootstrap-managed/u);
assert.match(reconciler, /HWLAB_RECONCILE_CROSS_NAMESPACE_RBAC/u);
assert.match(reconciler, /"name": "GIT_READ_URL"[\s\S]{0,140}git-mirror-http\.devops-infra\.svc\.cluster\.local/u);
assert.match(reconciler, /git_timed control-plane-clone 180 git clone --depth 1 --branch \\"\$SOURCE_BRANCH\\" \\"\$GIT_READ_URL\\"/u);
const poller = await readFile(path.join(outDir, "tekton-v02", "poller.yaml"), "utf8");
assert.match(poller, /"name": "GIT_READ_URL"[\s\S]{0,140}git-mirror-http\.devops-infra\.svc\.cluster\.local/u);
assert.match(poller, /git_timed poller-clone 180 git clone --depth 1 --branch \\"\$SOURCE_BRANCH\\" \\"\$GIT_READ_URL\\"/u);
} finally {
await rm(outDir, { recursive: true, force: true });
}