Skip to content

ci: fix coverage badge publish to use git worktree#23669

Open
Surabhi-1605 wants to merge 1 commit into
mainfrom
ci/fix-coverage-badge-worktree
Open

ci: fix coverage badge publish to use git worktree#23669
Surabhi-1605 wants to merge 1 commit into
mainfrom
ci/fix-coverage-badge-worktree

Conversation

@Surabhi-1605

@Surabhi-1605 Surabhi-1605 commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Problem

The Update coverage badge step in reusable-coverage-report.yml writes coverage.svg into the working tree and then runs git checkout -B badges origin/badges. On the second and subsequent runs (once the badges branch already tracks coverage.svg), this aborts with:

error: The following untracked working tree files would be overwritten by checkout:
  coverage.svg

The first run succeeds via the orphan-branch path, so the bug only surfaces on later main pushes.

Fix

  • Generate the SVG to /tmp/coverage.svg (never an untracked file in the working tree)
  • Publish via an isolated git worktree add /tmp/badges-wt — the main checkout never switches branches
  • Skip the commit when the badge is unchanged (git diff --staged --quiet)
  • Tag the commit [skip ci] so it doesn't trigger another run

The badge step is now byte-for-byte identical to consul-dataplane's. Only the "Update coverage badge" step changes; no other logic is touched.

Verification

  • Badge step diff vs consul-dataplane: empty (identical)
  • YAML validated
  • Same fix verified end-to-end on consul-ecs (merged) — the worktree approach published the badge cleanly on the previously-crashing 2nd run.

The badge step wrote coverage.svg into the working tree and then ran
'git checkout -B badges', which aborts on the second+ run because the
badges branch already tracks coverage.svg (untracked file would be
overwritten). Align with the consul-dataplane reference: generate the
SVG outside the tree and publish via a separate git worktree, so the
main checkout never switches branches. Restores the empty-commit skip
and [skip ci] tag.
@Surabhi-1605 Surabhi-1605 requested review from a team as code owners June 17, 2026 11:04
@github-actions github-actions Bot added type/ci Relating to continuous integration (CI) tooling for testing or releases theme/contributing Additions and enhancements to community contributing materials labels Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

theme/contributing Additions and enhancements to community contributing materials type/ci Relating to continuous integration (CI) tooling for testing or releases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant