Fix GitHub Actions coverage badge workflow git operations#276
Fix GitHub Actions coverage badge workflow git operations#276talgalili wants to merge 1 commit intofacebookresearch:mainfrom
Conversation
Summary: The coverage badge workflow was failing in GitHub Actions when the remote `badges` branch didn't exist. The flawed conditional logic would create an orphan branch but then fail on the subsequent checkout. This fix uses an idempotent approach that always creates a fresh orphan branch and force-pushes to the remote, avoiding racy conditional checks and working reliably whether the remote branch exists or not. Differential Revision: D90937254
|
@talgalili has exported this pull request. If you are a Meta employee, you can view the originating Diff in D90937254. |
There was a problem hiding this comment.
Pull request overview
This PR fixes a flawed conditional in the coverage badge GitHub Actions workflow that would fail when the remote badges branch didn't exist. The solution replaces racy conditional checks with an idempotent approach: always create a fresh orphan branch locally and force-push it to the remote.
Changes:
- Replace conditional fetch/create logic with unconditional orphan branch creation
- Add a README.md to the badges branch for documentation
- Use force-push to reliably update the remote badges branch regardless of its prior state
| git diff --staged --quiet || git commit -m "Update coverage badge [skip ci]" | ||
| git push origin badges | ||
| git add . | ||
| git commit -m "Update coverage badge to ${COVERAGE}% [skip ci]" |
There was a problem hiding this comment.
The commit message uses variable interpolation syntax ${COVERAGE} but it's inside single quotes in the git commit command, which prevents shell variable expansion. The commit message will literally contain the string "${COVERAGE}%" instead of the actual coverage percentage value. Either use double quotes around the entire message or use "Update coverage badge to $COVERAGE% [skip ci]" to ensure proper variable expansion.
|
This pull request has been merged in fe135c3. |
Summary:
The coverage badge workflow was failing in GitHub Actions when the remote
badgesbranch didn't exist. The flawed conditional logic would create an orphan branch but then fail on the subsequent checkout.This fix uses an idempotent approach that always creates a fresh orphan branch and force-pushes to the remote, avoiding racy conditional checks and working reliably whether the remote branch exists or not.
Differential Revision: D90937254