2525 type : number
2626 default : 30
2727 description : How many times to repeat each benchmark
28+ post-comment :
29+ type : boolean
30+ description : Post a comment linking to the run, with the aggregated result once known.
31+ token :
32+ type : string
33+ description : A GitHub token to post comments cross repository (not recommended)
2834
2935permissions :
3036 contents : read
3137
3238jobs :
39+ post-comment :
40+ if : inputs.post-comment
41+ outputs :
42+ body : ${{ steps.comment.outputs.COMMENT_BODY }}
43+ url : ${{ steps.comment.outputs.COMMENT_URL }}
44+ runs-on : ubuntu-slim
45+ permissions :
46+ pull-requests : write
47+ steps :
48+ - name : Mark token input as sensitive
49+ if : inputs.token != ''
50+ run : echo "::add-mask::${{ inputs.token }}"
51+ - name : Add link to the current run
52+ id : comment
53+ run : |
54+ FILTER_IF_SET=
55+ [ -z "$FILTER" ] || FILTER_IF_SET=" / $FILTER"
56+ COMMENT_BODY="Benchmark GHA (${CATEGORIES}${FILTER_IF_SET}): ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
57+ echo "COMMENT_BODY=$COMMENT_BODY" >> "$GITHUB_OUTPUT"
58+ echo "COMMENT_URL=$(gh pr comment -R "${REPO:-$GITHUB_REPOSITORY}" "$PR_ID" --body "$COMMENT_BODY")" >> "$GITHUB_OUTPUT"
59+ env :
60+ CATEGORIES : ${{ inputs.category }}
61+ FILTER : ${{ inputs.filter }}
62+ GH_TOKEN : ${{ inputs.token || github.token }}
63+ REPO : ${{ inputs.repo }}
64+ PR_ID : ${{ inputs.pr_id }}
3365 build :
3466 strategy :
3567 fail-fast : true
6092 env :
6193 EXPECTED_SHA : ${{ inputs.commit }}
6294
63- - uses : cachix/install-nix-action@8aa03977d8d733052d78f4e008a241fd1dbf36b3 # v31.10.6
95+ - uses : cachix/install-nix-action@630ae543ea3a38a9a4166f03376c02c50f408342 # v31.11.0
6496 with :
6597 extra_nix_config : sandbox = true
6698
@@ -109,7 +141,7 @@ jobs:
109141 --arg devTools '[]' \
110142 --arg benchmarkTools '[]' \
111143 --run '
112- make -j4 V=1
144+ make build-ci -j4 V=1
113145 '
114146
115147 - name : Run benchmark
@@ -155,9 +187,13 @@ jobs:
155187 path : ${{ matrix.system }}.csv
156188
157189 aggregate-results :
158- needs : build
190+ needs : [build, post-comment]
191+ if : ${{ always() && needs.build.result == 'success' && needs.post-comment.result == (inputs.post-comment && 'success' || 'skipped') }}
159192 name : Aggregate benchmark results
160193 runs-on : ubuntu-slim
194+ permissions :
195+ contents : read
196+ pull-requests : write
161197 steps :
162198 - uses : actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
163199 with :
@@ -175,7 +211,7 @@ jobs:
175211 merge-multiple : true
176212 path : raw-results
177213
178- - uses : cachix/install-nix-action@8aa03977d8d733052d78f4e008a241fd1dbf36b3 # v31.10.6
214+ - uses : cachix/install-nix-action@630ae543ea3a38a9a4166f03376c02c50f408342 # v31.11.0
179215 with :
180216 extra_nix_config : sandbox = true
181217
@@ -200,4 +236,30 @@ jobs:
200236 echo "> [!WARNING] "
201237 echo "> Do not take GHA benchmark results as face value, always confirm them"
202238 echo "> using a dedicated machine, e.g. Jenkins CI."
203- ' | tee /dev/stderr >> "$GITHUB_STEP_SUMMARY"
239+ ' | tee /dev/stderr ${{ inputs.post-comment && 'body.txt' || '' }} >> "$GITHUB_STEP_SUMMARY"
240+ - name : Mark token input as sensitive
241+ if : inputs.token != ''
242+ run : echo "::add-mask::${{ inputs.token }}"
243+ - name : Edit comment
244+ if : inputs.post-comment
245+ run : |
246+ {
247+ echo "$COMMENT_BODY"
248+ echo
249+ echo '<details><summary>Results</summary>'
250+ echo
251+ cat body.txt
252+ echo
253+ echo '</details>'
254+ } | jq -Rrcs '{ body: . }' | gh api \
255+ --method PATCH \
256+ -H "Accept: application/vnd.github+json" \
257+ -H "X-GitHub-Api-Version: 2026-03-10" \
258+ "/repos/${REPO:-$GITHUB_REPOSITORY}/issues/comments/${COMMENT_URL##*-}" \
259+ --input -
260+ env :
261+ GH_TOKEN : ${{ inputs.token || github.token }}
262+ REPO : ${{ inputs.repo }}
263+ COMMENT_BODY : ${{ needs.post-comment.outputs.body }}
264+ COMMENT_URL : ${{ needs.post-comment.outputs.url }}
265+ PR_ID : ${{ inputs.pr_id }}
0 commit comments