Skip to content

chore(ci): append run number to refresh-counts branch name#608

Merged
amavashev merged 1 commit intomainfrom
chore/refresh-counts-unique-branch-name
May 9, 2026
Merged

chore(ci): append run number to refresh-counts branch name#608
amavashev merged 1 commit intomainfrom
chore/refresh-counts-unique-branch-name

Conversation

@amavashev
Copy link
Copy Markdown
Contributor

Summary

Same-day re-dispatches of the unified refresh-counts.yml workflow collide on a date-only branch name chore/refresh-counts-YYYYMMDD. Today's smoke test of the per-package HWM migration (PR #607) caught it — the dispatch failed at git push with:

! [rejected]  chore/refresh-counts-20260509 -> chore/refresh-counts-20260509 (fetch first)
error: failed to push some refs

PR #605 (closed without merging earlier today) had pushed chore/refresh-counts-20260509 to the remote with one commit; the new dispatch created a different commit on the same branch name locally, and git push correctly refused the non-fast-forward.

Fix

Append GITHUB_RUN_NUMBER to the branch name:

- BRANCH="chore/refresh-counts-$(date -u +%Y%m%d)"
+ BRANCH="chore/refresh-counts-$(date -u +%Y%m%d)-${GITHUB_RUN_NUMBER}"

Each run gets a unique branch. No more push collisions.

Why not force-push instead

git push --force would have worked, but:

  • Bad PR semantics on closed/superseded PRs. Force-pushing rewrites the head SHA of a closed PR, so PR chore: refresh counts 2026-05-09 #605's "Files changed" tab would show the new content, not the data state at the time it was reviewed and closed. That's confusing for anyone reading PR history later.
  • gh pr create would still error if a closed PR exists for the same head→base pair, requiring an additional reopen-or-create branch in the workflow.

A unique branch per run avoids both issues with a single-line change. The PR-noise filter from PR #606 still suppresses no-op runs, so this won't multiply daily PRs — only runs with material data changes create a PR.

Test plan

  • YAML parses (5 steps, branch line confirmed)
  • Live test: dispatch the workflow once merged, confirm:
    • Branch name includes the run number suffix
    • Push succeeds (no collision with the stale chore/refresh-counts-20260509)
    • PR opens with the per-package HWM migration data (npmByPackage, pypiByPackage, cratesByPackage populated)

Cleanup of stale branches

The orphan branches chore/refresh-counts-20260509 (from PR #605) and the failed local-only state from today's run can be deleted manually after this lands. Future runs use unique names so this category of orphan is bounded — only material-data PRs leave a branch behind, and once merged or closed those branches are typically auto-deleted.

Same-day re-dispatches collided on the date-only branch name
chore/refresh-counts-YYYYMMDD. PR #605 on 2026-05-09 was closed
without merging, leaving its branch on the remote; today's manual
dispatch (run 25599788412) failed at `git push` because the remote
already had a branch with that name and a different history (the
fast-forward check rejected the push).

Append GITHUB_RUN_NUMBER so each dispatch creates a unique branch.
The PR-noise filter from PR #606 already prevents no-op runs from
opening PRs at all, so this won't multiply daily PRs — only material
runs result in a PR.
@amavashev amavashev merged commit 5e75e10 into main May 9, 2026
5 checks passed
@amavashev amavashev deleted the chore/refresh-counts-unique-branch-name branch May 9, 2026 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant