Skip to content

Track PR Benchmarks #311

Track PR Benchmarks

Track PR Benchmarks #311

name: Track PR Benchmarks
on:
workflow_run:
workflows: [CI]
types: [completed]
jobs:
track_pr_benchmarks:
name: Track PR Benchmarks with Bencher
if: ${{ github.event.workflow_run.event == 'pull_request' }}
permissions:
pull-requests: write
runs-on: ubuntu-22.04
env:
BENCHMARK_RESULTS: benchmark_results.txt
PR_EVENT: event.json
steps:
- name: Download Benchmark Results
uses: dawidd6/action-download-artifact@v6
with:
name: ${{ env.BENCHMARK_RESULTS }}
run_id: ${{ github.event.workflow_run.id }}
- name: Download PR Event
uses: dawidd6/action-download-artifact@v6
with:
name: ${{ env.PR_EVENT }}
run_id: ${{ github.event.workflow_run.id }}
- name: Read PR Event Data
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const prEvent = JSON.parse(fs.readFileSync(process.env.PR_EVENT, 'utf8'));
core.exportVariable('PR_HEAD', prEvent.pull_request.head.ref);
core.exportVariable('PR_HEAD_SHA', prEvent.pull_request.head.sha);
core.exportVariable('PR_BASE', prEvent.pull_request.base.ref);
core.exportVariable('PR_BASE_SHA', prEvent.pull_request.base.sha);
core.exportVariable('PR_NUMBER', prEvent.number);
- uses: bencherdev/bencher@main
- name: Track Benchmarks with Bencher
env:
BENCHER_API_TOKEN: ${{ secrets.BENCHER_API_TOKEN }}
run: |
bencher run \
--project bencher \
--token "$BENCHER_API_TOKEN" \
--branch "$PR_HEAD" \
--hash "$PR_HEAD_SHA" \
--start-point "$PR_BASE" \
--start-point-hash "$PR_BASE_SHA" \
--start-point-clone-thresholds \
--start-point-reset \
--testbed ubuntu-22.04 \
--adapter rust_criterion \
--err \
--github-actions '${{ secrets.GITHUB_TOKEN }}' \
--ci-number "$PR_NUMBER" \
--file ./${{ env.BENCHMARK_RESULTS }}