test(ci): regression for core#2460 jq-install fail-closed (mc#1982 root-fix) #2626
Reference in New Issue
Block a user
Delete Branch "fix/core-2615-2460-jq-install-fail-closed-test"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
CTO-mandated regression test for the install-jq step's fail-closed contract. core#2460 (mc#1982 root-fix, commit
8caff364) removed thecontinue-on-error: truemask on the install-jq step in.gitea/workflows/review-check-tests.yml, replacing the silent::warning::+ continue with a hardexit 1+::error::. The fix landed in main with NO test.The fix was embedded in the YAML
run:block, which is not unit-testable as-is. This commit extracts the install logic into a library, refactors the workflow to call it, and adds a regression test that proves the fail-closed contract.What changed
NEW
.gitea/scripts/lib/jq-install.sh— the install logic, extracted from the YAMLrun:block. Exposes a single functioninstall_jqthat takes the same two attempts (apt-get first, GitHub-binary fallback) and emits the same log lines, but is sourced from a shell function so it can be unit-tested. Test-injection: the lib readsJQ_INSTALL_APT_GETandJQ_INSTALL_CURLenv vars to override the actual binaries, so tests can simulate install paths with tiny shell scripts (no real network / package-manager round-trip). Same pattern as cp#737's wait-for-ci-status.sh.REFACTOR
.gitea/workflows/review-check-tests.yml— the prior 14-line inlinerun:block is now 3 lines:NEW
.gitea/scripts/tests/test_jq_install.sh— 7 assertions (a-f + idempotent) that prove the post-#2460 fail-closed contract:rc=0,::notice::jq installed via apt-get, no::warning::/::error::(anti-regression)rc=0,::notice::jq binary downloaded, no::error::(only BOTH-fail is page-on-call)rc=1,::error::(NOT::warning::), names both install paths so operators see what failed. This is the post-#2460 fail-closed contract — a regression to a::warning::+ continue would re-introduce the silent-mask class.review-check.sh regression tests cannot run without jq.|| true/|| echo/|| exit 0/|| :/continue-on-errorswallow patterns and ends withreturn 1.JQ_INSTALL_DEBUG=1emits::debug::lines for ops trace diagnostics.__JQ_INSTALL_SH_SOURCEDguard).WIRED into
.gitea/workflows/review-check-tests.ymlas a new step alongside the existingreview-check.shregression suite.Acceptance criteria (from the CTO spec)
.gitea/workflows/review-check-tests.yml, theInstall jqstep. See commit8caff364(the original fix).install_jqreturns 1 + emits::error::(NOT::warning::) on both-fail. Test (c) + test (e) lock this in. Realapt-get/curlare NOT used in the test (env-override injection), so the test exercises the actual fail-closed logic with deterministic inputs.review-check-tests.ymlrunsbash .gitea/scripts/tests/test_jq_install.sh.run:block). Per the CTO's spec ("If the logic is embedded in YAML, extract the checked step into a testable script"), extracted to.gitea/scripts/lib/jq-install.sh. The YAML now sources the lib and callsinstall_jq.apt-getand realcurlin production. The test ONLY mocks the BINARY (viaJQ_INSTALL_APT_GET/JQ_INSTALL_CURLenv override, same pattern as cp#737), not the request/response semantics. The fail-closed message string, thereturn 1exit, the body of the function — all real production code being exercised.Test results
No regressions in the existing review-check suite (46/46 still green).
Refs
8caff364)🤖 Generated with Claude Code
Approved on head
4c995589e0.Status check review: collapsed /statuses by latest id. The requested required contexts are green where visible:
CI / all-requiredandE2E API Smoke Testare success; failures are advisory/pre-review governance classes (Local Provision Lifecycle E2Eadvisory, gate/review approval contexts, SOP pull_request mirror), not the new test or required branch-protection set.5-axis review:
.gitea/scripts/lib/jq-install.shand callsinstall_jq; the same function is covered by the regression test. Both install paths failing returns non-zero and emits::error::, so the #2460 continue-on-error mask regression would be caught.Local verification passed:
bash .gitea/scripts/tests/test_jq_install.sh.