test(ci): explicitly reject boolean exit codes
ci/woodpecker/pr/ci Pipeline was successful

This commit is contained in:
2026-08-01 09:25:41 -05:00
parent 6e7a336deb
commit 57cae04f2b
3 changed files with 8 additions and 6 deletions
@@ -72,12 +72,12 @@ expect_exit 1 nonzero-with-artifact-text "$TMP/nonzero-artifact.json" >/dev/null
python3 - "$TMP/artifact.json" "$TMP" <<'PY'
import json, os, sys
record = json.load(open(sys.argv[1]))
for label, value in (("false", False), ("float", 0.0), ("string", "0"), ("null", None)):
for label, value in (("false", False), ("true", True), ("float", 0.0), ("string", "0"), ("null", None)):
changed = json.loads(json.dumps(record))
changed["workflows"][0]["children"][1]["exit_code"] = value
json.dump(changed, open(os.path.join(sys.argv[2], f"exit-{label}.json"), "w"))
PY
for label in false float string null; do
for label in false true float string null; do
expect_exit 1 "non-integer-exit-$label" "$TMP/exit-$label.json" >/dev/null
done
@@ -106,4 +106,4 @@ json.dump(record, open(sys.argv[2], "w"))
PY
expect_exit 1 missing-record-commit "$TMP/missing-record-commit.json" >/dev/null
printf 'terminal-green contract harness: PASS (16 cases)\n'
printf 'terminal-green contract harness: PASS (17 cases)\n'
@@ -42,12 +42,14 @@ def load_record(argument: str | None) -> dict[str, Any]:
def is_issue_1000_artifact(step: dict[str, Any]) -> bool:
error = step.get("error")
exit_code = step.get("exit_code")
return (
step.get("name") == "ci-postgres"
and step.get("type") == "service"
and step.get("state") == "failure"
and type(step.get("exit_code")) is int
and step.get("exit_code") == 0
and type(exit_code) is int
and not isinstance(exit_code, bool)
and exit_code == 0
and isinstance(error, str)
and POD_NOT_FOUND.fullmatch(error) is not None
)