fix(badges): surface git-fetch errors, guard malformed matrix entries, add tests#35
Merged
Merged
Conversation
write-badges.sh swallowed all git-fetch failures via '|| true' and fell through to the orphan-rebuild path, and had no guard for malformed matrix entries (which would write ci-null-null-null.json). Detect an absent badge branch up front with 'git ls-remote --exit-code' so only that benign case rebuilds the orphan; let real fetch failures abort. Reject non-array coverage-data/matrix-data and entries missing required fields with a loud ::error::. Add test/write-badges_test.sh pinning the filename contract, null-percent skip, and fail-loud paths, wired into build-and-test. Closes #24
Signed-off-by: monsieurleberre <monsieurleberre@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #24.
No-silent-failure hardening of
scripts/write-badges.sh, plus a test suite. (PRs #30/#32 addressed unrelated areas — #30 = badge status-token validation in the Python helpers, #32 = csharp-ci cobertura glob — so all three checklist items were still outstanding and are done here.)Changes
git fetch origin "$badge_branch" || true(which swallowed auth/network failures and silently fell through to the orphan-rebuild path) with an up-frontgit ls-remote --exit-code origin refs/heads/$badge_branchguard: missing ref (rc 2) → orphan rebuild; any other non-zero (128 auth/network) → loud::error::+ abort; existing branch → explicit fetch whose real failures now abort.require_fieldhelper (matrix:lang/os/arch/passed; coverage:slug/label), plus arequire_json_arrayguard rejecting non-array input. Prevents theci-null-null-null.jsonwrite.test/write-badges_test.sh(33+ checks) against ephemeral bare-repo remotes: filename contract, null-percent skip, fresh/existing/unchanged branch paths, unreachable-origin abort, and every fail-loud guard. Hermetic (local bare origin,GIT_CONFIG_GLOBAL/SYSTEM=/dev/null, no network). Follows the existing plain-bashcheck/check_rc/check_containsharness (no bats in repo). Wired into thebuild-and-testself-test job.Verification
shellcheckclean on the committed script; test suite 34/34 green; clean worktree; YAML parses.ls-remote --exit-codereturns exactly 2 for a missing ref (only that treated as benign), refs are safely quoted, guards fire before the filename is built, and tests are substantive/hermetic. One cosmetic non-blocking nit (a harmlessgit clonestderr warning in test seeding).