forked from o1-labs/o1js
-
Notifications
You must be signed in to change notification settings - Fork 2
455 lines (395 loc) · 13.2 KB
/
build-action.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
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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
name: Build o1js
on:
push:
#branches:
# - feature/perf
# - perf-recording
# - main
# - develop
# - *
pull_request:
workflow_dispatch: {}
jobs:
Prepare:
runs-on: ubuntu-latest
outputs:
test_count: ${{ steps.count_tests.outputs.test_count }}
chunk_count: 32 # This is hardcoded to 8, but it can be changed to any number.
steps:
- name: Checkout repository with submodules
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Cache dependencies and build
uses: actions/cache@v4
id: cache
with:
path: |
~/.npm
node_modules
dist
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.ts', '**/*.js') }}
- name: Build o1js
if: steps.cache.outputs.cache-hit != 'true'
shell: bash
run: |
#!/bin/bash
npm ci
npm run build
- name: Count tests
id: count_tests
shell: bash
run: |
#!/bin/bash
TEST_COUNT=$(find ./dist/node -name "*.unit-test.js" | wc -l)
echo "test_count=${TEST_COUNT}" >> "$GITHUB_OUTPUT"
echo "Total test count: ${TEST_COUNT}"
- name: Cache repository
uses: actions/cache@v4
with:
path: .
key: repo-${{ github.sha }}
Build-And-Test-Server:
needs: Prepare
#timeout-minutes: 210
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# prof, heap, cpu,
perf: [ no, all]
node_version: [ 18,20,22 ]
test_type:
[
'Simple integration tests',
'Reducer integration tests',
'DEX integration tests',
'DEX integration test with proofs',
'Voting integration tests',
'Verification Key Regression Check 1',
'Verification Key Regression Check 2',
'CommonJS test',
]
steps:
- name: Restore repository
uses: actions/cache@v4
with:
path: .
key: repo-${{ github.sha }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Restore cache
uses: actions/cache@v4
with:
path: |
~/.npm
node_modules
dist
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.ts', '**/*.js') }}
- name: Prepare for tests
shell: bash
run: |
#!/bin/bash
touch profiling.md
- name: Sets MODIFIED_BRANCH_NAME
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
shell: bash
run: |
#!/bin/bash
MODIFIED_BRANCH_NAME=${BRANCH_NAME/\//-}
OUTPUT_DIR="profile/profile-data/${MODIFIED_BRANCH_NAME}"
OUTPUT_TEST_DIR="${OUTPUT_DIR}/profile-data-${{matrix.test_type}}-${{ matrix.perf }}-${{ matrix.node_version }}"
echo "MODIFIED_BRANCH_NAME=${MODIFIED_BRANCH_NAME}" >> "$GITHUB_ENV"
echo "OUTPUT_DIR=${OUTPUT_DIR}" >> "$GITHUB_ENV"
echo "OUTPUT_TEST_DIR=${OUTPUT_TEST_DIR}" >> "$GITHUB_ENV"
- name: create dir
shell: bash
run: |
#!/bin/bash
mkdir -p "${{env.OUTPUT_TEST_DIR}}"
- name: Execute tests
env:
TEST_TYPE: ${{ matrix.test_type }}
PERF_TYPE: ${{ matrix.perf }}
shell: bash
run: |
#!/bin/bash
sh run-ci-tests.sh || echo skip errors
mv isolate-*-v8.log "${OUTPUT_TEST_DIR}" || echo ok
mv Heap.*.heapprofile "${OUTPUT_TEST_DIR}" || echo ok
mv CPU.*.cpuprofile "${OUTPUT_TEST_DIR}" || echo ok
continue-on-error: true
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-${{env.MODIFIED_BRANCH_NAME}}-${{ matrix.chunk }}-${{ matrix.perf }}-${{ matrix.node_version }}
path: ${{env.OUTPUT_TEST_DIR}}
- name: Add to job summary
if: always()
shell: bash
run: |
#!/bin/bash
echo "### Test Results for ${{ matrix.test_type }}" >> "$GITHUB_STEP_SUMMARY"
cat profiling.md >> "$GITHUB_STEP_SUMMARY"
Run-Unit-Tests:
needs: Prepare
name: Run unit tests parallel
#timeout-minutes: 60 # lets keep the individual jobs shorter
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
#chunk: [ 13 ]
chunk: [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]
# TODO use https://www.raygesualdo.com/posts/dynamic-matrices-github-actions/
perf: [
no,
#prof, heap, cpu,
all]
node_version: [
18
#,20,22
]
steps:
- name: Restore repository
uses: actions/cache@v4
with:
path: .
key: repo-${{ github.sha }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node_version }}
- name: Restore cache
uses: actions/cache@v4
with:
path: |
~/.npm
node_modules
dist
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.ts', '**/*.js') }}
- name: Prepare for tests
shell: bash
run: |
#!/bin/bash
touch profiling.md
- name: create dir
shell: bash
run: |
#!/bin/bash
mkdir -p profile/profile-data
#- name: create dirs
# from https://stackoverflow.com/questions/75985925/how-to-replace-slashes-with-dashes-and-set-it-an-environment-variable-in-github
- name: Sets MODIFIED_BRANCH_NAME
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
shell: bash
run: |
#!/bin/bash
MODIFIED_BRANCH_NAME=${BRANCH_NAME/\//-}
OUTPUT_DIR="profile/profile-data/${MODIFIED_BRANCH_NAME}"
OUTPUT_TEST_DIR="${OUTPUT_DIR}/profile-data-${{matrix.chunk}}-${{ matrix.perf }}-${{ matrix.node_version }}"
echo "MODIFIED_BRANCH_NAME=${MODIFIED_BRANCH_NAME}" >> "$GITHUB_ENV"
echo "OUTPUT_DIR=${OUTPUT_DIR}" >> "$GITHUB_ENV"
echo "OUTPUT_TEST_DIR=${OUTPUT_TEST_DIR}" >> "$GITHUB_ENV"
- name: create dir
shell: bash
run: |
#!/bin/bash
mkdir -p "${{env.OUTPUT_TEST_DIR}}"
- name: Run unit tests
#timeout-minutes: 30
env:
TOTAL_TESTS: ${{ needs.Prepare.outputs.test_count }}
CHUNK: ${{ matrix.chunk }}
CHUNKS: 32
shell: bash
run: |
#!/bin/bash
echo "Total tests: $TOTAL_TESTS"
echo "Current chunk: $CHUNK"
echo "Total chunks: $CHUNKS"
if [ -z "$TOTAL_TESTS" ] || [ "$TOTAL_TESTS" -eq 0 ]; then
echo "Error: TOTAL_TESTS is not set or is zero. Exiting."
exit 1
fi
start_index=$(( (TOTAL_TESTS * (CHUNK - 1) / CHUNKS) ))
end_index=$(( (TOTAL_TESTS * CHUNK / CHUNKS) ))
echo "Running tests from index $start_index to $end_index"
shopt -s globstar
test_files=(./dist/node/**/*.unit-test.js)
#set -o pipefail
for ((i=start_index; i<end_index && i<${#test_files[@]}; i++)); do
echo "Running test: ${test_files[$i]}"
# NO prof
if [ "${{ matrix.perf }}" == "no" ]; then
echo no prof
(node --enable-source-maps "${test_files[$i]}" | tee -a profiling.md) || echo skip errors
fi
# cpu prof
if [ "${{ matrix.perf }}" == "cpu" ]; then
echo cpu
(node --cpu-prof --expose-gc --enable-source-maps "${test_files[$i]}" | tee -a profiling.md) || echo skip errors
fi
# HEAP
if [ "${{ matrix.perf }}" == "heap" ]; then
echo heap prof
(node --heap-prof --expose-gc --enable-source-maps "${test_files[$i]}" | tee -a profiling.md) || echo skip errors
fi
# PROF
if [ "${{ matrix.perf }}" == "prof" ]; then
echo prof
(node --prof --expose-gc --enable-source-maps "${test_files[$i]}" | tee -a profiling.md) || echo skip errors
fi
# ALL
if [ "${{ matrix.perf }}" == "all" ]; then
echo all prof
(node "${test_files[$i]}" | tee -a profiling.md) || echo skip errors
fi
# sweep up results
mv isolate-*-v8.log "${OUTPUT_TEST_DIR}" || echo ok
mv Heap.*.heapprofile "${OUTPUT_TEST_DIR}" || echo ok
mv CPU.*.cpuprofile "${OUTPUT_TEST_DIR}" || echo ok
done
continue-on-error: true
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-${{env.MODIFIED_BRANCH_NAME}}-${{ matrix.chunk }}-${{ matrix.perf }}-${{ matrix.node_version }}
path: ${{env.OUTPUT_TEST_DIR}}
- name: Add to job summary
if: always()
shell: bash
run: |
#!/bin/bash
echo "### Test Results for Unit Tests Chunk ${{ matrix.chunk }}" >> "$GITHUB_STEP_SUMMARY"
cat profiling.md >> "$GITHUB_STEP_SUMMARY"
Build-And-Test-Server-Unit-Tests:
name: Build-And-Test-Server (Unit tests)
needs: [Run-Unit-Tests]
runs-on: ubuntu-latest
steps:
- run: |
#!/bin/bash
echo "All unit tests completed successfully"
shell: bash
Build-And-Test-Web:
needs: Prepare
#timeout-minutes: 90
runs-on: ubuntu-latest
steps:
- name: Restore repository
uses: actions/cache@v4
with:
path: .
key: repo-${{ github.sha }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Restore npm cache
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
- name: Cache Playwright browsers
uses: actions/cache@v4
id: playwright-cache
with:
path: ~/.cache/ms-playwright
key: ${{ runner.OS }}-playwright-${{ hashFiles('**/package-lock.json') }}
- name: Install Playwright browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: |
#!/bin/bash
npm run e2e:install
shell: bash
- name: Build o1js and prepare the web server
shell: bash
run: |
#!/bin/bash
npm run build:web
npm run e2e:prepare-server
- name: Execute E2E tests
shell: bash
run: |
#!/bin/bash
npm run test:e2e
- name: Upload E2E test artifacts
uses: actions/upload-artifact@v4
continue-on-error: true
if: always()
with:
if-no-files-found: ignore
name: e2e-tests-report
# playwrite data
path: tests/report/
retention-days: 30
Release-on-NPM:
if: github.ref == 'refs/heads/main'
#timeout-minutes: 180
runs-on: ubuntu-latest
needs: [Build-And-Test-Server, Run-Unit-Tests, Build-And-Test-Web]
steps:
- name: Restore repository
uses: actions/cache@v4
with:
path: .
key: repo-${{ github.sha }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Build o1js
shell: bash
run: |
#!/bin/bash
npm ci
npm run prepublishOnly
- name: Publish to NPM if version has changed
uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}
strategy: upgrade
env:
INPUT_TOKEN: ${{ secrets.NPM_TOKEN }}
Release-mina-signer-on-NPM:
if: github.ref == 'refs/heads/main'
#timeout-minutes: 180
runs-on: ubuntu-latest
needs: [Build-And-Test-Server, Run-Unit-Tests, Build-And-Test-Web]
steps:
- name: Restore repository
uses: actions/cache@v4
with:
path: .
key: repo-${{ github.sha }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Build mina-signer
shell: bash
run: |
#!/bin/bash
npm ci
cd src/mina-signer || exit
npm ci
npm run prepublishOnly
- name: Publish to NPM if version has changed
uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}
package: './src/mina-signer/package.json'
strategy: upgrade
env:
INPUT_TOKEN: ${{ secrets.NPM_TOKEN }}