fix: restore Gitea git timing helper

This commit is contained in:
root
2026-07-21 22:01:09 +02:00
parent 8fa39c2e8a
commit 3fe21079fb
10 changed files with 54 additions and 32 deletions
+10
View File
@@ -47,6 +47,14 @@ function taskByName(pipeline, name) {
return task;
}
function assertShellFunctionDefinedBeforeCall(script, functionName) {
const definitionIndex = script.indexOf(`${functionName}() {`);
assert.notEqual(definitionIndex, -1, `missing ${functionName} definition`);
const invocationIndex = script.search(new RegExp(`(?:^|\\n)[^\\n]*\\b${functionName}[ \\t]+`, "u"));
assert.notEqual(invocationIndex, -1, `missing ${functionName} invocation`);
assert.ok(definitionIndex < invocationIndex, `${functionName} must be defined before its first invocation`);
}
test("NC01 PaC artifact keeps the runtime GitOps file contract", async () => {
const pipelinePath = "ci/pipelines/hwlab-nc01-v03-ci-image-publish.yaml";
const pacSource = await readFile(".tekton/hwlab-nc01-v03-pac.yaml", "utf8");
@@ -275,6 +283,7 @@ test("v02 render follows TypeScript runtime checks and does not self-patch boots
assert.match(gitopsPromoteScript, /GIT_ASKPASS_REQUIRE=force/u);
assert.match(gitopsPromoteScript, /test -s \/workspace\/gitea-auth\/token/u);
assert.match(gitopsPromoteScript, /git_timed "source-head-\$phase" 45 git ls-remote/u);
assertShellFunctionDefinedBeforeCall(gitopsPromoteScript, "git_timed");
assert.doesNotMatch(gitopsPromoteScript, /git-ssh-setup/u);
assert.match(gitopsPromoteScript, /source_head_url="\$\(params\.git-read-url\)"/u);
assert.match(gitopsPromoteScript, /gitops_write_url="\$\(params\.git-write-url\)"/u);
@@ -292,6 +301,7 @@ test("v02 render follows TypeScript runtime checks and does not self-patch boots
assert.match(prepareSourceScript, /git_read_url="\$\(params\.git-read-url\)"/u);
assert.doesNotMatch(prepareSourceScript, /git-ssh-setup/u);
assert.match(prepareSourceScript, /git_timed source-clone 180 git clone --branch "\$\(params\.source-branch\)" "\$git_read_url"/u);
assertShellFunctionDefinedBeforeCall(prepareSourceScript, "git_timed");
assert.match(prepareSourceScript, /git_timed catalog-ls-remote 45 git ls-remote --exit-code --heads "\$gitops_read_url"/u);
assert.match(prepareSourceScript, /git remote set-url gitops-catalog "\$gitops_read_url"/u);
assert.match(prepareSourceScript, /"event":"prepare-source-dependencies","status":"skipped","reason":"renderer-dependency-install-disabled","dependency":"yaml"/u);