From a1b211dd3a040d0e5b992e3ac82b383a999d5ab3 Mon Sep 17 00:00:00 2001 From: Everett Pompeii Date: Sat, 26 Sep 2026 19:48:02 +0000 Subject: [PATCH] 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. A first step prints the type of each field in the dispatch payload, and never a value, so a run shows what shape the callback's body arrived in. 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. --- .github/workflows/bare_metal_attach.yml | 52 +++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/bare_metal_attach.yml diff --git a/.github/workflows/bare_metal_attach.yml b/.github/workflows/bare_metal_attach.yml new file mode 100644 index 0000000..7425915 --- /dev/null +++ b/.github/workflows/bare_metal_attach.yml @@ -0,0 +1,52 @@ +on: + repository_dispatch: + types: [bencher_run] + +jobs: + attach_pr_benchmarks: + name: Post PR Benchmark Results from Bencher Bare Metal + permissions: + checks: write + pull-requests: write + runs-on: ubuntu-latest + steps: + - name: Show the type of each dispatch payload field, never its value + run: jq '.client_payload // {} | map_values(if type == "object" then map_values(type) else type end)' "$GITHUB_EVENT_PATH" + - name: Resolve the Bencher CLI commit + id: bencher-cli + run: | + sha="$(git ls-remote https://github.com/bencherdev/bencher refs/heads/u/ep/callback/smoke | cut -f1)" + test -n "$sha" + echo "sha=$sha" >> "$GITHUB_OUTPUT" + echo "key=bencher-cli-$ImageOS-$RUNNER_ARCH-$sha" >> "$GITHUB_OUTPUT" + - name: Restore the Bencher CLI + id: restore-bencher-cli + uses: actions/cache/restore@v5 + with: + path: ~/.bencher-cli + key: ${{ steps.bencher-cli.outputs.key }} + - name: Install the Bencher CLI + if: steps.restore-bencher-cli.outputs.cache-hit != 'true' + env: + BENCHER_SHA: ${{ steps.bencher-cli.outputs.sha }} + run: cargo install --git https://github.com/bencherdev/bencher --rev "$BENCHER_SHA" --locked --root ~/.bencher-cli bencher_cli + - name: Save the Bencher CLI + if: steps.restore-bencher-cli.outputs.cache-hit != 'true' + uses: actions/cache/save@v5 + with: + path: ~/.bencher-cli + key: ${{ steps.bencher-cli.outputs.key }} + - name: Add the Bencher CLI to the path + run: echo "$HOME/.bencher-cli/bin" >> "$GITHUB_PATH" + - name: Post PR Benchmark Results with Bencher + env: + JOB_UUID: ${{ github.event.client_payload.bencher.job }} + PROJECT_SLUG: ${{ github.event.client_payload.bencher.project }} + run: | + bencher run \ + --host https://dev.api.bencher.dev \ + --project "$PROJECT_SLUG" \ + --token '${{ secrets.DEV_BENCHER_API_TOKEN }}' \ + --job "$JOB_UUID" \ + --error-on-alert \ + --github-actions '${{ secrets.GITHUB_TOKEN }}'