forked from etemesi254/zune-image
-
Notifications
You must be signed in to change notification settings - Fork 0
110 lines (87 loc) · 2.72 KB
/
Copy pathcriterion_benchmarks.yml
File metadata and controls
110 lines (87 loc) · 2.72 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: Benchmark Regression
on:
pull_request:
push:
branches: [ "dev" ]
workflow_dispatch:
permissions:
contents: read
pull-requests: write
jobs:
bench:
name: Criterion Bench (${{ matrix.os }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install criterion dependencies
run: cargo install cargo-criterion
# ----------------------------
# Run benchmarks (current ref)
# ----------------------------
- name: Run benchmarks
run: |
cargo criterion --message-format=json | tee bench.json
- name: Upload benchmark results
uses: actions/upload-artifact@v4
with:
name: bench-${{ github.sha }}
path: bench.json
compare:
name: Benchmark Diff (PR vs dev)
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install criterion
run: cargo install cargo-criterion
# ----------------------------
# Benchmark PR branch
# ----------------------------
- name: Run PR benchmarks
run: cargo criterion --message-format=json > pr.json
# ----------------------------
# Fetch base branch benchmark
# ----------------------------
- name: Fetch dev branch benchmark
run: |
git fetch origin dev
git checkout origin/dev
cargo criterion --message-format=json > dev.json
git checkout ${{ github.sha }}
# ----------------------------
# Compare results
# ----------------------------
- name: Install critcmp
run: cargo install critcmp
- name: Compare benchmarks
run: |
critcmp dev.json pr.json | tee diff.txt
# ----------------------------
# Comment PR
# ----------------------------
- name: Comment PR with benchmark diff
if: github.event.pull_request.head.repo.full_name == github.repository
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const diff = fs.readFileSync('diff.txt', 'utf8');
const body = `## Benchmark Regression Report
\`\`\`
${diff}
\`\`\`
_Generated by Criterion CI bot_`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body
});