Upload bencher PR results #714
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Upload bencher PR results | |
on: | |
workflow_run: | |
workflows: [Benchmark] | |
types: [completed] | |
jobs: | |
upload_bencher_results: | |
if: github.event.workflow_run.conclusion == 'success' | |
runs-on: ubuntu-latest | |
env: | |
BENCHMARK_RESULTS: bencher.json | |
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 }} | |
if_no_artifact_found: ignore | |
- name: Download PR Event | |
uses: dawidd6/action-download-artifact@v6 | |
with: | |
name: ${{ env.PR_EVENT }} | |
run_id: ${{ github.event.workflow_run.id }} | |
if_no_artifact_found: ignore | |
- name: Check for PR data | |
id: check_files | |
run: | | |
if [ ! -f "${{ env.BENCHMARK_RESULTS }}" ] || [ ! -f "${{ env.PR_EVENT }}" ]; then | |
echo "Files do not exist. Exiting." | |
exit 0 | |
else | |
echo "data=available" >> $GITHUB_ENV | |
fi | |
- name: Export PR Event Data | |
if: env.data == 'available' | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
let fs = require('fs'); | |
let prEvent = JSON.parse(fs.readFileSync(process.env.PR_EVENT, {encoding: 'utf8'})); | |
core.exportVariable("PR_HEAD", prEvent.pull_request.head.ref); | |
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 | |
if: env.data == 'available' | |
- name: Track Benchmarks with Bencher | |
if: env.data == 'available' | |
run: | | |
bencher run \ | |
--project laze \ | |
--token "${{ secrets.BENCHER_API_TOKEN }}" \ | |
--branch "$PR_HEAD" \ | |
--start-point "$PR_BASE" \ | |
--start-point-hash "$PR_BASE_SHA" \ | |
--start-point-clone-thresholds \ | |
--start-point-reset \ | |
--testbed github-actions \ | |
--err \ | |
--adapter json \ | |
--github-actions '${{ secrets.GITHUB_TOKEN }}' \ | |
--ci-number "$PR_NUMBER" \ | |
--file "$BENCHMARK_RESULTS" |