From fa75e91dd2a1c043df511074864342afa289c9b2 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 9 Jul 2026 14:19:18 +0000 Subject: [PATCH] build(workflows): fix non-fast-forward push in `publish_coverage_pr` The job `Publish PR coverage results` on workflow `publish_coverage_pr` failed on develop with `! [rejected] pr- -> pr- (fetch first)` pushing to `stdlib-js/www-test-code-coverage`. Root cause: the "Checkout coverage repository branch" step ran `git fetch origin "$BRANCH_NAME" || true` followed by `git checkout "$BRANCH_NAME" || git checkout -b "$BRANCH_NAME"`. Because the repository is a fresh, narrow checkout each run, the fetch only populates FETCH_HEAD and never a local or remote-tracking ref, so the checkout always fell through to creating a new branch from the current default-branch HEAD, discarding any commits an earlier coverage run for the same PR had already pushed. The later commit-and-push step then rejected as non-fast-forward. This commit checks out FETCH_HEAD when the fetch succeeds, resuming the branch's actual remote history, and only falls back to a fresh branch when the fetch fails (first coverage run for a PR), so subsequent pushes fast-forward cleanly. Ref: https://github.com/stdlib-js/stdlib/actions/runs/28999588120 --- .github/workflows/publish_coverage_pr.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish_coverage_pr.yml b/.github/workflows/publish_coverage_pr.yml index 21c1bbff76d2..80937fbbbb70 100644 --- a/.github/workflows/publish_coverage_pr.yml +++ b/.github/workflows/publish_coverage_pr.yml @@ -157,8 +157,11 @@ jobs: run: | cd ./www-test-code-coverage BRANCH_NAME="pr-$PR_NUMBER" - git fetch origin "$BRANCH_NAME" || true - git checkout "$BRANCH_NAME" || git checkout -b "$BRANCH_NAME" + if git fetch origin "$BRANCH_NAME"; then + git checkout -B "$BRANCH_NAME" FETCH_HEAD + else + git checkout -b "$BRANCH_NAME" + fi # Remove all directories except .github and .git from branch: find . -mindepth 1 -maxdepth 1 -type d -not -name '.github' -not -name '.git' -exec git rm -rf {} + || true