Benchmark no longer auto commits and just leaves a comment on the PR
Some checks failed
Merge-Checker / Benchmarking (pull_request) Failing after 22s
Merge-Checker / build_and_test (pull_request) Successful in 17s

This commit is contained in:
2025-05-29 16:21:40 -04:00
parent ff427c4844
commit 483738817a
2 changed files with 23 additions and 26 deletions

View File

@@ -93,35 +93,32 @@ jobs:
echo "timings_changed=false" >> $GITHUB_OUTPUT
fi
- name: Commit and push timing results
if: steps.check_diff.outputs.timings_changed == 'true' && github.event.pull_request.head.repo.full_name == github.repository
- name: Leave PR comment with timing updates
if: steps.check_diff.outputs.timings_changed == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "ci-bot"
git config --global user.email "ci-bot@local"
echo "Preparing PR comment with new timing results..."
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
git stash
echo "Checking out source branch $BRANCH_NAME"
git fetch origin "$BRANCH_NAME"
git checkout "$BRANCH_NAME"
git pull
COMMENT_BODY=$(echo -e "### ⏱ Timing Results Changed\n\n" \
"The benchmark detected significant timing changes (≥ 0.1s).\n\n" \
"**Please review and commit the updated timing results** to:\n\`\`\`\nunit-tests/timing-results/matrix-timing-tests.txt\n\`\`\`\n\n" \
"Latest result:\n\`\`\`\n$(cat unit-tests/timing-results/matrix-timing-tests.txt)\n\`\`\`\n\n" \
"<!-- timing-bot-comment -->")
echo "Checking if last commit was a timing update"
LAST_COMMIT_MSG=$(git log -1 --pretty=%B)
PR_NUMBER="${{ github.event.pull_request.number }}"
if echo "$LAST_COMMIT_MSG" | grep -q "Update matrix-timing-tests timings"; then
echo "Last commit was a timing update, skipping commit."
exit 0
# Look for an existing bot comment
COMMENT_ID=$(gh api repos/${{ github.repository }}/issues/${PR_NUMBER}/comments \
--jq '.[] | select(.body | contains("<!-- timing-bot-comment -->")) | .id')
if [ -z "$COMMENT_ID" ]; then
echo "Creating new PR comment"
gh api repos/${{ github.repository }}/issues/${PR_NUMBER}/comments \
-f body="$COMMENT_BODY"
else
echo "Last commit name was: $LAST_COMMIT_MSG"
git stash pop
echo "Updating existing PR comment"
gh api repos/${{ github.repository }}/issues/comments/${COMMENT_ID} \
-X PATCH -F body="$COMMENT_BODY"
fi
git add unit-tests/timing-results/matrix-timing-tests.txt
if git diff --quiet --cached; then
echo "No changes to commit"
else
git commit -m "Update matrix-timing-tests timings"
git push origin "$BRANCH_NAME"
fi

View File

@@ -1,7 +1,7 @@
name: Merge-Checker
on:
push:
pull_request:
branches: ["**"]
jobs: