-
Notifications
You must be signed in to change notification settings - Fork 0
239 lines (192 loc) · 8.96 KB
/
benchmark.yml
File metadata and controls
239 lines (192 loc) · 8.96 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
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
name: Aztec Benchmark
on:
pull_request:
types: [opened, synchronize, reopened]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: write
issues: write
env:
BENCH_DIR: ./benchmarks
jobs:
check-changes:
name: Check for relevant changes
runs-on: ubuntu-latest
outputs:
should-benchmark: ${{ steps.changes.outputs.should-benchmark }}
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Check for relevant changes
id: changes
uses: actions/github-script@v8
with:
script: |
console.log('Checking for changes that would affect benchmarks...');
const { data: files } = await github.rest.pulls.listFiles({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
});
console.log('Changed files:');
files.forEach(file => console.log(`- ${file.filename}`));
// Check for Noir contracts, config, or benchmark changes
const relevantPatterns = /^(src\/nr\/|Nargo\.toml|benchmarks\/)/;
const hasRelevantChanges = files.some(file => relevantPatterns.test(file.filename));
// Check for AZTEC_VERSION change in package.json
const hasAztecVersionChange = files.some(file =>
file.filename === 'package.json' && file.patch?.includes('aztecVersion')
);
const shouldBenchmark = hasRelevantChanges || hasAztecVersionChange;
if (hasRelevantChanges) {
console.log('📝 Noir contracts, config, or benchmark files changed');
} else if (hasAztecVersionChange) {
console.log('🔄 AZTEC_VERSION changed in package.json');
} else {
console.log('⏭️ No benchmark-relevant changes detected, skipping benchmarks');
}
core.setOutput('should-benchmark', shouldBenchmark);
benchmark:
name: Run comparison
needs: check-changes
if: needs.check-changes.outputs.should-benchmark == 'true'
runs-on: ubuntu-latest
steps:
# ──────────────────────────────────────────────────────────────
# 0️⃣ SHARED TOOLING – Buildx + Aztec CLI skeleton
# ──────────────────────────────────────────────────────────────
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: '22.17.0'
- name: Install Aztec CLI
run: |
curl -s https://install.aztec.network > tmp.sh
bash tmp.sh <<< yes "yes"
- name: Update path
run: echo "/home/runner/.aztec/bin" >> $GITHUB_PATH
# ──────────────────────────────────────────────────────────────
# 1️⃣ BENCHMARK BASE COMMIT
# ──────────────────────────────────────────────────────────────
- name: Checkout BASE branch
uses: actions/checkout@v5
with:
ref: ${{ github.event.pull_request.base.sha }}
- name: Detect Aztec version (BASE)
id: basever
run: |
VER=$(node -p "require('./package.json').config.aztecVersion")
echo "ver=$VER" >> "$GITHUB_OUTPUT"
echo "Base Aztec version is $VER"
- name: Switch CLI to BASE version
run: |
VERSION=${{ steps.basever.outputs.ver }} aztec-up
- name: Manually tag the aztec version as `latest`
run: |
docker tag aztecprotocol/aztec:${{ steps.basever.outputs.ver }} aztecprotocol/aztec:latest
- name: Start sandbox (BASE, background)
run: aztec start --sandbox &
- name: Start PXE node (BASE, background)
run: |
VERSION=${{ steps.basever.outputs.ver }} aztec start \
--port 8081 --pxe --pxe.nodeUrl=http://localhost:8080/ \
--pxe.proverEnabled false &
- name: Install deps (BASE)
run: yarn --frozen-lockfile
- name: Compile contracts (BASE)
run: yarn compile
- name: Codegen wrappers (BASE)
run: yarn codegen
- name: Benchmark (BASE)
run: |
npx aztec-benchmark --suffix _base --output-dir ${{ env.BENCH_DIR }}
# This is required to avoid the benchmark results being removed by the Checkout PR step
- name: Store base benchmark results
run: |
mkdir -p ../benchmarks_base && mv ${{ env.BENCH_DIR }}/*.json ../benchmarks_base/
# ──────────────────────────────────────────────────────────────
# 2️⃣ BENCHMARK PR HEAD (github.event.pull_request.head.sha)
# ──────────────────────────────────────────────────────────────
# clean does not work correctly and is removing the benchmark results anyways
# https://github.com/actions/checkout/issues/1201
- name: Checkout PR branch
uses: actions/checkout@v5
with:
ref: ${{ github.event.pull_request.head.sha }}
clean: false
# Restore the base benchmark results to avoid the benchmark results being removed by the Checkout PR step
- name: Restore base benchmark results
run: mv ../benchmarks_base/* ${{ env.BENCH_DIR }}/
- name: Detect Aztec version (PR)
id: prver
run: |
VER=$(node -p "require('./package.json').config.aztecVersion")
echo "PR Aztec version is $VER"
if [ "${{ steps.basever.outputs.ver }}" != "$VER" ]; then
echo "ver_diff=true" >> "$GITHUB_OUTPUT"
else
echo "ver_diff=false" >> "$GITHUB_OUTPUT"
fi
echo "ver=$VER" >> "$GITHUB_OUTPUT"
- name: Kill BASE services
if: steps.prver.outputs.ver_diff == 'true'
run: |
pkill -f "aztec.*--sandbox" || true
pkill -f "aztec.*--pxe.*8081" || true
sleep 5
- name: Switch CLI to PR version
if: steps.prver.outputs.ver_diff == 'true'
run: |
VERSION=${{ steps.prver.outputs.ver }} aztec-up
- name: Manually tag the aztec version as `latest`
run: |
docker tag aztecprotocol/aztec:${{ steps.prver.outputs.ver }} aztecprotocol/aztec:latest
- name: Start sandbox (PR, background)
if: steps.prver.outputs.ver_diff == 'true'
run: aztec start --sandbox &
- name: Start PXE node (PR, background)
if: steps.prver.outputs.ver_diff == 'true'
run: |
VERSION=${{ steps.prver.outputs.ver }} aztec start \
--port 8081 --pxe --pxe.nodeUrl=http://localhost:8080/ \
--pxe.proverEnabled false &
# - name: Clean project from BASE stage
# run: rm -rf node_modules yarn.lock
- name: Install deps (PR)
run: yarn --frozen-lockfile
- name: Compile contracts (PR)
run: yarn compile
- name: Codegen wrappers (PR)
run: yarn codegen
# ──────────────────────────────────────────────────────────────
# 3️⃣ DIFF & UPLOAD ARTIFACTS
# ──────────────────────────────────────────────────────────────
- name: Generate benchmark comparison
uses: defi-wonderland/aztec-benchmark/action@main
with:
base_suffix: '_base'
current_suffix: '_pr'
# SECURITY: Upload results for secure comment workflow
- name: Upload benchmark results and metadata
uses: actions/upload-artifact@v4
with:
name: benchmark-results
path: |
benchmark-comparison.md
retention-days: 1
- name: Save PR number for comment workflow
run: |
echo "${{ github.event.number }}" > pr-number.txt
- name: Upload PR metadata
uses: actions/upload-artifact@v4
with:
name: pr-metadata
path: pr-number.txt
retention-days: 1