From 483738817a4088bf2c6c70d795568653e82fb7f4 Mon Sep 17 00:00:00 2001 From: Cynopolis Date: Thu, 29 May 2025 16:21:40 -0400 Subject: [PATCH] Benchmark no longer auto commits and just leaves a comment on the PR --- .gitea/workflows/Benchmark.yaml | 47 ++++++++++++++--------------- .gitea/workflows/Merge-Checker.yaml | 2 +- 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/.gitea/workflows/Benchmark.yaml b/.gitea/workflows/Benchmark.yaml index 6be6139..f387206 100644 --- a/.gitea/workflows/Benchmark.yaml +++ b/.gitea/workflows/Benchmark.yaml @@ -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" \ + "") - 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("")) | .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 diff --git a/.gitea/workflows/Merge-Checker.yaml b/.gitea/workflows/Merge-Checker.yaml index b6a30a0..e8d5237 100644 --- a/.gitea/workflows/Merge-Checker.yaml +++ b/.gitea/workflows/Merge-Checker.yaml @@ -1,7 +1,7 @@ name: Merge-Checker on: - push: + pull_request: branches: ["**"] jobs: