-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
82 lines (80 loc) · 3.16 KB
/
track_benches.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
on:
workflow_run:
workflows: [Run and Cache Benchmarks]
types:
- completed
name: Track Benchmarks
jobs:
track_benchmarks:
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
backend: ["postgres", "sqlite", "mysql"]
env:
BENCHER_PROJECT: diesel
BENCHER_ADAPTER: rust_criterion
BENCHER_TESTBED: ubuntu-latest-${{ matrix.backend }}
PR_BENCHMARK_RESULTS: pr_${{ matrix.backend }}.txt
BASE_BENCHMARK_RESULTS: base_${{ matrix.backend }}.txt
GITHUB_EVENT: event_${{ matrix.backend }}.json
# This is the percentage that the PR can be slower than the base benchmark
# Adjust this value to lower to make the test more sensitive to changes
# Adjust this value to higher to make the test less sensitive to changes
# https://bencher.dev/docs/explanation/thresholds/#percentage-upper-boundary
UPPER_BOUNDARY: 1.0
steps:
- name: Download PR Benchmark Results
uses: dawidd6/action-download-artifact@v6
with:
name: ${{ env.PR_BENCHMARK_RESULTS }}
run_id: ${{ github.event.workflow_run.id }}
- name: Download Base Benchmark Results
uses: dawidd6/action-download-artifact@v6
with:
name: ${{ env.BASE_BENCHMARK_RESULTS }}
run_id: ${{ github.event.workflow_run.id }}
- name: Download GitHub Event
uses: dawidd6/action-download-artifact@v6
with:
name: ${{ env.GITHUB_EVENT }}
run_id: ${{ github.event.workflow_run.id }}
- name: Export GitHub Event Data
uses: actions/github-script@v6
with:
script: |
let fs = require('fs');
let githubEvent = JSON.parse(fs.readFileSync("event.json", {encoding: 'utf8'}));
console.log(githubEvent);
core.exportVariable("PR_HEAD", githubEvent.pull_request.head.ref);
core.exportVariable("PR_HEAD_SHA", githubEvent.pull_request.head.sha);
core.exportVariable("PR_BASE", githubEvent.pull_request.base.ref);
core.exportVariable("PR_BASE_SHA", githubEvent.pull_request.base.sha);
core.exportVariable("PR_NUMBER", githubEvent.number);
- uses: bencherdev/bencher@main
- name: Track PR Base Benchmarks
run: |
bencher run \
--token "${{ secrets.BENCHER_API_TOKEN }}" \
--branch "$PR_BASE" \
--hash "$PR_BASE_SHA" \
--start-point-reset \
--file "$BASE_BENCHMARK_RESULTS"
- name: Track PR Head Benchmarks
run: |
bencher run \
--token "${{ secrets.BENCHER_API_TOKEN }}" \
--branch "$PR_HEAD" \
--hash "$PR_HEAD_SHA" \
--start-point "$PR_BASE" \
--start-point-hash "$PR_BASE_SHA" \
--start-point-reset \
--threshold-measure latency \
--threshold-test percentage \
--threshold-upper-boundary ${{ env.UPPER_BOUNDARY }} \
--thresholds-reset \
--github-actions "${{ secrets.GITHUB_TOKEN }}" \
--ci-number "$PR_NUMBER" \
--err \
--file "$PR_BENCHMARK_RESULTS"