Skip to content

Commit a5dfaa0

Browse files
committed
pr_benchmarks
1 parent 7872260 commit a5dfaa0

File tree

5 files changed

+111
-48
lines changed

5 files changed

+111
-48
lines changed

.github/workflows/benchmarks.yml

Lines changed: 10 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -10,63 +10,29 @@ jobs:
1010
track_benchmarks:
1111
name: Track Benchmarks with Bencher
1212
permissions:
13-
pull-requests: write
13+
checks: write
1414
runs-on: ubuntu-22.04
1515
env:
1616
BENCHMARK_RESULTS: benchmark_results.txt
17-
PR_EVENT: event.json
1817
steps:
1918
- name: Download Benchmark Results
20-
id: download_results
21-
uses: dawidd6/action-download-artifact@v6
22-
continue-on-error: true
19+
uses: actions/download-artifact@v4
2320
with:
2421
name: ${{ env.BENCHMARK_RESULTS }}
25-
run_id: ${{ github.event.workflow_run.id }}
26-
- name: Download PR Event
27-
id: download_event
28-
uses: dawidd6/action-download-artifact@v6
29-
continue-on-error: true
30-
with:
31-
name: ${{ env.PR_EVENT }}
32-
run_id: ${{ github.event.workflow_run.id }}
33-
- name: Check if Fork PR Benchmarks
34-
id: check_fork
35-
run: |
36-
if [[ "${{ steps.download_results.outcome }}" == "success" && "${{ steps.download_event.outcome }}" == "success" ]]; then
37-
echo "is_fork_pr=true" >> "$GITHUB_OUTPUT"
38-
else
39-
echo "is_fork_pr=false" >> "$GITHUB_OUTPUT"
40-
fi
41-
- name: Export PR Event Data
42-
if: steps.check_fork.outputs.is_fork_pr == 'true'
43-
uses: actions/github-script@v6
44-
with:
45-
script: |
46-
let fs = require('fs');
47-
let prEvent = JSON.parse(fs.readFileSync(process.env.PR_EVENT, {encoding: 'utf8'}));
48-
core.exportVariable("PR_HEAD", prEvent.pull_request.head.ref);
49-
core.exportVariable("PR_HEAD_SHA", prEvent.pull_request.head.sha);
50-
core.exportVariable("PR_BASE", prEvent.pull_request.base.ref);
51-
core.exportVariable("PR_BASE_SHA", prEvent.pull_request.base.sha);
52-
core.exportVariable("PR_NUMBER", prEvent.number);
5322
- uses: bencherdev/bencher@main
54-
if: steps.check_fork.outputs.is_fork_pr == 'true'
55-
- name: Track Benchmarks with Bencher
56-
if: steps.check_fork.outputs.is_fork_pr == 'true'
23+
- name: Track benchmarks with Bencher
5724
run: |
5825
bencher run \
5926
--project bencher \
6027
--token '${{ secrets.BENCHER_API_TOKEN }}' \
61-
--branch "$PR_HEAD" \
62-
--hash "$PR_HEAD_SHA" \
63-
--start-point "$PR_BASE" \
64-
--start-point-hash "$PR_BASE_SHA" \
65-
--start-point-clone-thresholds \
66-
--start-point-reset \
28+
--branch ${{ github.ref_name }} \
6729
--testbed ubuntu-22.04 \
68-
--adapter rust_criterion \
30+
--threshold-measure latency \
31+
--threshold-test t_test \
32+
--threshold-max-sample-size 64 \
33+
--threshold-upper-boundary 0.9999 \
34+
--thresholds-reset \
6935
--err \
36+
--adapter rust_criterion \
7037
--github-actions '${{ secrets.GITHUB_TOKEN }}' \
71-
--ci-number "$PR_NUMBER" \
7238
--file ./benchmark_results.txt

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ jobs:
134134
with:
135135
mold-version: "2.34.1"
136136

137-
# Summary job for required status checks
138137
ci-success:
139138
name: CI Success
140139
if: always()

.github/workflows/test.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,11 @@ jobs:
102102
name: event.json
103103
path: ${{ github.event_path }}
104104

105-
benchmarks:
106-
name: Benchmarks
105+
track_benchmarks:
106+
name: Track Benchmarks
107+
if: ${{ github.ref == 'refs/heads/devel' || github.ref == 'refs/heads/cloud' || github.ref == 'refs/heads/main' }}
107108
needs: cargo_bench
108-
uses: ./.github/workflows/benchmarks.yml
109+
uses: ./.github/workflows/track_benchmarks.yml
109110
secrets:
110111
BENCHER_API_TOKEN: ${{ secrets.BENCHER_API_TOKEN }}
111112

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Track Benchmarks
2+
3+
on:
4+
workflow_call:
5+
secrets:
6+
BENCHER_API_TOKEN:
7+
required: true
8+
9+
jobs:
10+
track_benchmarks:
11+
name: Track Benchmarks with Bencher
12+
permissions:
13+
checks: write
14+
runs-on: ubuntu-22.04
15+
env:
16+
BENCHMARK_RESULTS: benchmark_results.txt
17+
steps:
18+
- name: Download Benchmark Results
19+
uses: dawidd6/action-download-artifact@v6
20+
with:
21+
name: ${{ env.BENCHMARK_RESULTS }}
22+
- uses: bencherdev/bencher@main
23+
- name: Track benchmarks with Bencher
24+
run: |
25+
bencher run \
26+
--project bencher \
27+
--token '${{ secrets.BENCHER_API_TOKEN }}' \
28+
--branch ${{ github.ref_name }} \
29+
--testbed ubuntu-22.04 \
30+
--threshold-measure latency \
31+
--threshold-test t_test \
32+
--threshold-max-sample-size 64 \
33+
--threshold-upper-boundary 0.9999 \
34+
--thresholds-reset \
35+
--err \
36+
--adapter rust_criterion \
37+
--github-actions '${{ secrets.GITHUB_TOKEN }}' \
38+
--file ./benchmark_results.txt
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Track PR Benchmarks
2+
3+
on:
4+
workflow_run:
5+
workflows: [CI]
6+
types: [completed]
7+
8+
jobs:
9+
track_pr_benchmarks:
10+
name: Track PR Benchmarks with Bencher
11+
if: ${{ github.event.workflow_run.event == 'pull_request' }}
12+
permissions:
13+
pull-requests: write
14+
runs-on: ubuntu-22.04
15+
env:
16+
BENCHMARK_RESULTS: benchmark_results.txt
17+
PR_EVENT: event.json
18+
steps:
19+
- name: Download Benchmark Results
20+
uses: dawidd6/action-download-artifact@v6
21+
with:
22+
name: ${{ env.BENCHMARK_RESULTS }}
23+
run_id: ${{ github.event.workflow_run.id }}
24+
- name: Download PR Event
25+
uses: dawidd6/action-download-artifact@v6
26+
with:
27+
name: ${{ env.PR_EVENT }}
28+
run_id: ${{ github.event.workflow_run.id }}
29+
- name: Read PR Event Data
30+
uses: actions/github-script@v7
31+
with:
32+
script: |
33+
const fs = require('fs');
34+
const prEvent = JSON.parse(fs.readFileSync(process.env.PR_EVENT, 'utf8'));
35+
core.exportVariable('PR_HEAD', prEvent.pull_request.head.ref);
36+
core.exportVariable('PR_HEAD_SHA', prEvent.pull_request.head.sha);
37+
core.exportVariable('PR_BASE', prEvent.pull_request.base.ref);
38+
core.exportVariable('PR_BASE_SHA', prEvent.pull_request.base.sha);
39+
core.exportVariable('PR_NUMBER', prEvent.number);
40+
- uses: bencherdev/bencher@main
41+
- name: Track Benchmarks with Bencher
42+
env:
43+
BENCHER_API_TOKEN: ${{ secrets.BENCHER_API_TOKEN }}
44+
run: |
45+
bencher run \
46+
--project bencher \
47+
--token "$BENCHER_API_TOKEN" \
48+
--branch "$PR_HEAD" \
49+
--hash "$PR_HEAD_SHA" \
50+
--start-point "$PR_BASE" \
51+
--start-point-hash "$PR_BASE_SHA" \
52+
--start-point-clone-thresholds \
53+
--start-point-reset \
54+
--testbed ubuntu-22.04 \
55+
--adapter rust_criterion \
56+
--err \
57+
--github-actions '${{ secrets.GITHUB_TOKEN }}' \
58+
--ci-number "$PR_NUMBER" \
59+
--file ./${{ env.BENCHMARK_RESULTS }}

0 commit comments

Comments
 (0)