From b942ff3123b01be94c7b9e569347b7d3a5732b6e Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Thu, 9 Jul 2026 16:54:44 +0200 Subject: [PATCH 1/4] tools: add option for `benchmark.yml` to post comment on PR Signed-off-by: Antoine du Hamel --- .github/workflows/benchmark.yml | 61 +++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 2 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index b989dd1faaef45..37bb68fec7ad79 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -25,11 +25,37 @@ on: type: number default: 30 description: How many times to repeat each benchmark + post-comment: + type: boolean + description: Post a comment linking to the run, with the aggregated result once known. + token: + type: string + description: A GitHub token to post comments cross repository (not recommended) permissions: contents: read jobs: + post-comment: + if: inputs.post-comment + outputs: + url: ${{ steps.comment.outputs.COMMENT_URL }} + runs-on: ubuntu-slim + permissions: + pull-requests: write + steps: + - name: Mark token input as sensitive + if: inputs.token != '' + run: echo "::add-mask::${{ inputs.token }}" + - name: Add link to the current run + id: comment + run: | + echo "COMMENT_URL=$(gh pr comment -R "${REPO:-$GITHUB_REPOSITORY}" "$PR_ID" \ + --body "Benchmark GHA: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}")" >> "$GITHUB_OUTPUT" + env: + GH_TOKEN: ${{ inputs.token || github.token }} + REPO: ${{ inputs.repo }} + PR_ID: ${{ inputs.pr_id }} build: strategy: fail-fast: true @@ -155,9 +181,13 @@ jobs: path: ${{ matrix.system }}.csv aggregate-results: - needs: build + needs: [build, post-comment] + if: ${{ always() && needs.build.result == 'success' && needs.post-comment.result == (inputs.post-comment && 'success' || 'skipped') }} name: Aggregate benchmark results runs-on: ubuntu-slim + permissions: + contents: read + pull-requests: write steps: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 with: @@ -200,4 +230,31 @@ jobs: echo "> [!WARNING] " echo "> Do not take GHA benchmark results as face value, always confirm them" echo "> using a dedicated machine, e.g. Jenkins CI." - ' | tee /dev/stderr >> "$GITHUB_STEP_SUMMARY" + ' | tee /dev/stderr body.txt >> "$GITHUB_STEP_SUMMARY" + - name: Mark token input as sensitive + if: inputs.token != '' + run: echo "::add-mask::${{ inputs.token }}" + - name: Edit comment + if: inputs.post-comment + run: | + { + echo "Benchmark GHA: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" + echo + echo '
Results' + echo + cat body.txt + echo + echo '
' + } | jq -Rrcs '{ body: . }' | gh api \ + --method PATCH \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2026-03-10" \ + "/repos/${REPO:-$GITHUB_REPOSITORY}/issues/comments/${COMMENT_URL##*-}" \ + --input - + env: + GH_TOKEN: ${{ inputs.token || github.token }} + REPO: ${{ inputs.repo }} + COMMENT_URL: ${{ needs.post-comment.outputs.url }} + PR_ID: ${{ inputs.pr_id }} + + From 5b75af4a96853e3d1ceb383ce514bc297048800f Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Thu, 9 Jul 2026 20:35:01 +0200 Subject: [PATCH 2/4] fixup! tools: add option for `benchmark.yml` to post comment on PR --- .github/workflows/benchmark.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 37bb68fec7ad79..bd27bf29e8d3c7 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -256,5 +256,3 @@ jobs: REPO: ${{ inputs.repo }} COMMENT_URL: ${{ needs.post-comment.outputs.url }} PR_ID: ${{ inputs.pr_id }} - - From 4d38447719b749f54d90cece2a14f4fff9982c6d Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Fri, 10 Jul 2026 07:42:36 +0200 Subject: [PATCH 3/4] fixup! tools: add option for `benchmark.yml` to post comment on PR add category / filter in the automatic comment --- .github/workflows/benchmark.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index bd27bf29e8d3c7..331d18aadabbed 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -39,6 +39,7 @@ jobs: post-comment: if: inputs.post-comment outputs: + body: ${{ steps.comment.outputs.COMMENT_BODY }} url: ${{ steps.comment.outputs.COMMENT_URL }} runs-on: ubuntu-slim permissions: @@ -50,9 +51,14 @@ jobs: - name: Add link to the current run id: comment run: | - echo "COMMENT_URL=$(gh pr comment -R "${REPO:-$GITHUB_REPOSITORY}" "$PR_ID" \ - --body "Benchmark GHA: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}")" >> "$GITHUB_OUTPUT" + FILTER_IF_SET= + [ -z "$FILTER" ] || FILTER_IF_SET="/ $FILTER" + COMMENT_BODY="Benchmark GHA (${CATEGORIES}${FILTER_IF_SET}): ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" + echo "COMMENT_BODY=$COMMENT_BODY" >> "$GITHUB_OUTPUT" + echo "COMMENT_URL=$(gh pr comment -R "${REPO:-$GITHUB_REPOSITORY}" "$PR_ID" --body "$COMMENT_BODY")" >> "$GITHUB_OUTPUT" env: + CATEGORIES: ${{ inputs.category }} + FILTER: ${{ inputs.filter }} GH_TOKEN: ${{ inputs.token || github.token }} REPO: ${{ inputs.repo }} PR_ID: ${{ inputs.pr_id }} @@ -230,7 +236,7 @@ jobs: echo "> [!WARNING] " echo "> Do not take GHA benchmark results as face value, always confirm them" echo "> using a dedicated machine, e.g. Jenkins CI." - ' | tee /dev/stderr body.txt >> "$GITHUB_STEP_SUMMARY" + ' | tee /dev/stderr ${{ inputs.post-comment && 'body.txt' || '' }} >> "$GITHUB_STEP_SUMMARY" - name: Mark token input as sensitive if: inputs.token != '' run: echo "::add-mask::${{ inputs.token }}" @@ -238,7 +244,7 @@ jobs: if: inputs.post-comment run: | { - echo "Benchmark GHA: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" + echo "$COMMENT_BODY" echo echo '
Results' echo @@ -254,5 +260,6 @@ jobs: env: GH_TOKEN: ${{ inputs.token || github.token }} REPO: ${{ inputs.repo }} + COMMENT_BODY: ${{ needs.post-comment.outputs.body }} COMMENT_URL: ${{ needs.post-comment.outputs.url }} PR_ID: ${{ inputs.pr_id }} From ae1e2ad64b31eb530f1759a0d3a9170aa61c6af7 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Fri, 10 Jul 2026 07:48:41 +0200 Subject: [PATCH 4/4] fixup! tools: add option for `benchmark.yml` to post comment on PR --- .github/workflows/benchmark.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 331d18aadabbed..48b3f1d6125975 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -52,7 +52,7 @@ jobs: id: comment run: | FILTER_IF_SET= - [ -z "$FILTER" ] || FILTER_IF_SET="/ $FILTER" + [ -z "$FILTER" ] || FILTER_IF_SET=" / $FILTER" COMMENT_BODY="Benchmark GHA (${CATEGORIES}${FILTER_IF_SET}): ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" echo "COMMENT_BODY=$COMMENT_BODY" >> "$GITHUB_OUTPUT" echo "COMMENT_URL=$(gh pr comment -R "${REPO:-$GITHUB_REPOSITORY}" "$PR_ID" --body "$COMMENT_BODY")" >> "$GITHUB_OUTPUT"