-
Notifications
You must be signed in to change notification settings - Fork 413
151 lines (129 loc) · 4.3 KB
/
benchmark-rust.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
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: Benchmarks Rust
on:
push:
branches:
- 'main' # or "master"
paths:
- '**/*.rs'
- '**/*.toml'
- '.github/workflows/**'
- 'Cargo.lock'
- 'rust-toolchain.toml'
pull_request:
types: [opened, synchronize]
paths:
- '**/*.rs'
- '**/*.toml'
- '.github/workflows/**'
- 'Cargo.lock'
- 'rust-toolchain.toml'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: ${{ github.ref_name != 'main' }}
jobs:
codspeed-benchmark:
name: Codspeed Benchmark
runs-on: ubuntu-latest
steps:
- name: Checkout Branch
uses: actions/checkout@v4
with:
# Whether Pull submodules for additional files
submodules: false
- name: Install Rust
uses: moonrepo/setup-rust@v1
with:
bins: just, cargo-codspeed
cache-base: main
cache-target: release
- name: Install pnpm
uses: pnpm/action-setup@v3
- name: Install node
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Setup benchmark
run: just setup-bench
- name: Build the benchmark target(s)
run: cargo codspeed build -p bench --features codspeed
- name: Run the benchmarks
uses: CodSpeedHQ/action@v2
with:
run: cargo codspeed run -p bench
token: ${{ secrets.CODSPEED_TOKEN }}
env:
# ensure that `root_dir()` from `crates/rolldown_testing/src/workspace.rs` works during the benchmark
# see https://github.com/adriencaccia/rolldown/pull/1 for explanation
CARGO_MANIFEST_DIR: ${{ github.workspace }}/target/codspeed
benchmark-rust:
name: Benchmark Rust
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Checkout PR Branch
uses: actions/checkout@v4
with:
# Whether Pull submodules for additional files
submodules: false
- name: Install Rust
uses: moonrepo/setup-rust@v1
with:
bins: just, critcmp
cache-base: main
cache-target: release
- name: Install pnpm
uses: pnpm/action-setup@v3
- name: Install node
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Setup benchmark
run: just setup-bench
- name: Run Bench on PR Branch
run: cargo bench -p bench -- --save-baseline pr
- name: Checkout Target Branch
uses: actions/checkout@v4
with:
clean: false
ref: ${{ github.event.pull_request.base.ref }}
- name: Run Bench on Target Branch
run: cargo bench -p bench -- --save-baseline target
- name: Compare Bench Results
id: bench_comparison
shell: bash
run: |
echo "### Benchmarks Rust" > output
echo "- target: \`${{ github.event.pull_request.base.ref }}\`(${{ github.event.pull_request.base.sha }})" >> output
echo "- pr: \`${{ github.event.pull_request.head.ref }}\`(${{ github.event.pull_request.head.sha }})" >> output
echo "\`\`\`" >> output
critcmp target pr >> output
echo "\`\`\`" >> output
cat output
comment="$(cat output)"
comment="${comment//'%'/%25}"
comment="${comment//$'\n'/%0A}"
comment="${comment//$'\r'/%0D}"
echo "::set-output name=comment::$comment"
- name: Find Comment
uses: peter-evans/find-comment@v3
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Benchmarks Rust
- name: Write a new comment
uses: peter-evans/create-or-update-comment@v4.0.0
continue-on-error: true
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: ${{ steps.bench_comparison.outputs.comment }}
reactions-edit-mode: 'replace'
edit-mode: replace