Skip to content

Commit aa11b31

Browse files
committed
Add a workflow that attaches to Bencher bare metal jobs
When a detached bare metal run finishes, its callback sends a `bencher_run` repository_dispatch. This workflow attaches to that Job with `bencher run --job`, then completes the GitHub Check the detached run started and posts the pull request comment. GitHub only runs repository_dispatch workflows from the default branch, so this file has to live on main. Until job callbacks ship, it installs the CLI from the job callbacks branch, cached by commit, and talks to the dev API.
1 parent 4d70af1 commit aa11b31

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
on:
2+
repository_dispatch:
3+
types: [bencher_run]
4+
5+
jobs:
6+
attach_pr_benchmarks:
7+
name: Post PR Benchmark Results from Bencher Bare Metal
8+
permissions:
9+
checks: write
10+
pull-requests: write
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Resolve the Bencher CLI commit
14+
id: bencher-cli
15+
run: |
16+
sha="$(git ls-remote https://github.com/bencherdev/bencher refs/heads/u/ep/callback/smoke | cut -f1)"
17+
test -n "$sha"
18+
echo "sha=$sha" >> "$GITHUB_OUTPUT"
19+
echo "key=bencher-cli-$ImageOS-$RUNNER_ARCH-$sha" >> "$GITHUB_OUTPUT"
20+
- name: Restore the Bencher CLI
21+
id: restore-bencher-cli
22+
uses: actions/cache/restore@v5
23+
with:
24+
path: ~/.bencher-cli
25+
key: ${{ steps.bencher-cli.outputs.key }}
26+
- name: Install the Bencher CLI
27+
if: steps.restore-bencher-cli.outputs.cache-hit != 'true'
28+
env:
29+
BENCHER_SHA: ${{ steps.bencher-cli.outputs.sha }}
30+
run: cargo install --git https://github.com/bencherdev/bencher --rev "$BENCHER_SHA" --locked --root ~/.bencher-cli bencher_cli
31+
- name: Save the Bencher CLI
32+
if: steps.restore-bencher-cli.outputs.cache-hit != 'true'
33+
uses: actions/cache/save@v5
34+
with:
35+
path: ~/.bencher-cli
36+
key: ${{ steps.bencher-cli.outputs.key }}
37+
- name: Add the Bencher CLI to the path
38+
run: echo "$HOME/.bencher-cli/bin" >> "$GITHUB_PATH"
39+
- name: Post PR Benchmark Results with Bencher
40+
env:
41+
JOB_UUID: ${{ github.event.client_payload.bencher.job }}
42+
PROJECT_SLUG: ${{ github.event.client_payload.bencher.project }}
43+
run: |
44+
bencher run \
45+
--host https://dev.api.bencher.dev \
46+
--project "$PROJECT_SLUG" \
47+
--token '${{ secrets.DEV_BENCHER_API_TOKEN }}' \
48+
--job "$JOB_UUID" \
49+
--error-on-alert \
50+
--github-actions '${{ secrets.GITHUB_TOKEN }}'

0 commit comments

Comments
 (0)