From 5cb317e7cfdada15bfb5c03779869e6b8da36a32 Mon Sep 17 00:00:00 2001 From: MDA2AV Date: Mon, 16 Nov 2026 15:22:20 +0000 Subject: [PATCH] benchmark-pr: fail and say so on the PR when the results commit can't be pushed A rejected push used to print 'could not push to fork (permissions)' and leave the step green, so the results were lost without a word. #1783 lost its saved run that way: a commit reached the branch while the run was measuring, and the results push was refused as a non-fast-forward. Now the step fails, and comments on the PR with the reason: the branch moved (the numbers are for code it no longer has, so they are not rebased on top either), or the push was refused (a fork without maintainer edits). --- .github/workflows/benchmark-pr.yml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/benchmark-pr.yml b/.github/workflows/benchmark-pr.yml index 00e279f4a0..97b44e3f65 100644 --- a/.github/workflows/benchmark-pr.yml +++ b/.github/workflows/benchmark-pr.yml @@ -333,7 +333,26 @@ jobs: fi git commit -m "$MSG" git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${PR_REPO}.git" - git push origin HEAD:"${PR_BRANCH}" || echo "Warning: could not push to fork (permissions)" + # A push that does not land loses the results, so it fails the job + # and says so on the PR instead of passing with a warning nobody + # reads. Most often a commit reached the branch while this run was + # measuring (#1783): the numbers are for the commit checked out at + # the start, so they are not put on top of the new one either. + if ! git push origin HEAD:"${PR_BRANCH}"; then + RAN=$(git rev-parse "refs/remotes/pull/${{ inputs.pr }}/head" 2>/dev/null || true) + NOW=$(gh api "/repos/${{ github.repository }}/pulls/${{ inputs.pr }}" --jq '.head.sha' 2>/dev/null || true) + if [ -n "$RAN" ] && [ -n "$NOW" ] && [ "$RAN" != "$NOW" ]; then + WHY="the branch moved to \`${NOW:0:9}\` while this run was measuring \`${RAN:0:9}\`, so the numbers are for code the branch no longer has" + elif [ "$PR_REPO" != "${{ github.repository }}" ]; then + WHY="the push to \`${PR_REPO}\` was refused, most likely a fork that does not allow edits from maintainers" + else + WHY="the push to \`${PR_BRANCH}\` was refused" + fi + echo "::error::Results not saved: ${WHY}" + gh pr comment "${{ inputs.pr }}" --repo "${{ github.repository }}" \ + --body "⚠️ **This run's results were not saved**: ${WHY}. Nothing was committed, and the board keeps the numbers it has. Save them with a new run." + exit 1 + fi fi - name: Post results to PR