Skip to content

Commit b94dad2

Browse files
committed
ci: comment on completion of /bench regression run
1 parent 6ca30cd commit b94dad2

2 files changed

Lines changed: 46 additions & 2 deletions

File tree

.github/scripts/resolve-regression-trigger.cjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module.exports = async ({ github, context, core }) => {
1515
const { owner, repo } = context.repo;
1616
const fullName = `${owner}/${repo}`;
1717
const eventName = context.eventName;
18+
const runUrl = `${context.serverUrl}/${owner}/${repo}/actions/runs/${context.runId}`;
1819

1920
let shouldRun = false;
2021
let edrRef = "";
@@ -130,8 +131,8 @@ module.exports = async ({ github, context, core }) => {
130131
if (green) {
131132
shouldRun = true;
132133
await postComment(
133-
`🚀 Starting regression benchmark for \`${edrRef.slice(0, 12)}\` ` +
134-
`against Hardhat \`${hardhatRef}\`.`
134+
`🚀 [Starting regression benchmark](${runUrl}) for ` +
135+
`\`${edrRef.slice(0, 12)}\` against Hardhat \`${hardhatRef}\`.`
135136
);
136137
} else {
137138
await postComment(

.github/workflows/hh3-regression-benchmark.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,3 +336,46 @@ jobs:
336336
"workflow_name": "${{ github.workflow }}",
337337
"run_url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
338338
}
339+
340+
report:
341+
name: Report result to PR
342+
needs: [setup, regression-benchmark]
343+
# 1. run on benchmark failure but skip when the run is superseded (concurrency)
344+
# 2. Only report back to the PR for `/bench` comment triggers
345+
# 3. Only report back if the benchmark actually started
346+
# prettier-ignore
347+
if: >-
348+
!cancelled()
349+
&& github.event_name == 'issue_comment'
350+
&& needs.setup.outputs.should_run == 'true'
351+
runs-on: ubuntu-latest
352+
permissions:
353+
issues: write # post the result comment on the PR
354+
steps:
355+
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
356+
env:
357+
RESULT: ${{ needs.regression-benchmark.result }}
358+
EDR_REF: ${{ needs.setup.outputs.edr_ref }}
359+
HARDHAT_REF: ${{ needs.setup.outputs.hardhat_ref }}
360+
with:
361+
script: |
362+
const { RESULT, EDR_REF, HARDHAT_REF } = process.env;
363+
const runUrl =
364+
`${context.serverUrl}/${context.repo.owner}/${context.repo.repo}` +
365+
`/actions/runs/${context.runId}`;
366+
const target =
367+
`\`${EDR_REF.slice(0, 12)}\` against Hardhat \`${HARDHAT_REF}\``;
368+
const body =
369+
RESULT === "success"
370+
? `✅ Regression benchmark passed for ${target}.\n\n` +
371+
`[View workflow run](${runUrl})`
372+
: `❌ Regression benchmark failed for ${target}. This is either ` +
373+
`a detected performance regression or an infrastructure ` +
374+
`failure — see the run for details.\n\n` +
375+
`[View workflow run](${runUrl})`;
376+
await github.rest.issues.createComment({
377+
owner: context.repo.owner,
378+
repo: context.repo.repo,
379+
issue_number: context.payload.issue.number,
380+
body,
381+
});

0 commit comments

Comments
 (0)