-
Notifications
You must be signed in to change notification settings - Fork 36
343 lines (336 loc) · 14.3 KB
/
build-and-test.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
name: Build and Test
on:
push:
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
env:
CARGO_TERM_COLOR: always
jobs:
# TODO: Add a job to run clippy
lint:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
steps:
- uses: actions/checkout@v4
- name: Check formatting
run: cargo fmt --all -- --check
cli:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
steps:
- uses: actions/checkout@v4
- name: Install cli
run: |
cd cli
cargo install --path .
mopro --help
test-ffi-halo2:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Run ffi halo2 tests
run: cd mopro-ffi && cargo test --features halo2 --no-default-features
test-ffi-circom:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Run ffi circom tests
run: cd mopro-ffi && cargo test --features circom --no-default-features
test-ffi-ashlang:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Run ffi ashlang tests
run: cd mopro-ffi && cargo test --features ashlang --no-default-features
setup-halo2-wasm-env:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
outputs:
chrome-dir: ${{ steps.parsed-chrome-chromedriver-dir.outputs.chrome-dir }}
chromedriver-dir: ${{ steps.parsed-chrome-chromedriver-dir.outputs.chromedriver-dir }}
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2024-07-18
override: true
- name: Cache wasm-pack
id: cache-wasm-pack
uses: actions/cache@v4
with:
path: ~/.cargo/bin/wasm-pack
key: ${{ runner.os }}-wasm-pack
- name: Install wasm-pack
if: steps.cache-wasm-pack.outputs.cache-hit != 'true'
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Setup Chrome and ChromeDriver
uses: browser-actions/setup-chrome@v1
id: setup-chrome-chromedriver
with:
chrome-version: 130
install-chromedriver: true
- name: Parse Chrome and ChromeDriver Directories
id: parsed-chrome-chromedriver-dir
run: |
echo "chrome-dir=$(dirname ${{ steps.setup-chrome-chromedriver.outputs.chrome-path }})" >> $GITHUB_OUTPUT
echo "chromedriver-dir=$(dirname ${{ steps.setup-chrome-chromedriver.outputs.chromedriver-path }})" >> $GITHUB_OUTPUT
- name: Cache Chrome and ChromeDriver
id: cache-chrome-chromedriver
uses: actions/cache@v4
with:
path: |
${{ steps.parsed-chrome-chromedriver-dir.outputs.chrome-dir }}
${{ steps.parsed-chrome-chromedriver-dir.outputs.chromedriver-dir }}
key: ${{ runner.os }}-cache-chrome-chromedriver
test-wasm-halo2:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
needs: setup-halo2-wasm-env
env:
CHROME_BIN: ${{ needs.setup-halo2-wasm-env.outputs.chrome-dir }}/chrome
CHROMEDRIVER_BIN: ${{ needs.setup-halo2-wasm-env.outputs.chromedriver-dir }}/chromedriver
steps:
- uses: actions/checkout@v4
- name: Restore cached wasm-pack
uses: actions/cache@v4
with:
path: ~/.cargo/bin/wasm-pack
key: ${{ runner.os }}-wasm-pack
- name: Restore cached chrome and chromedriver
uses: actions/cache@v4
with:
path: |
${{ needs.setup-halo2-wasm-env.outputs.chrome-dir }}
${{ needs.setup-halo2-wasm-env.outputs.chromedriver-dir }}
key: ${{ runner.os }}-cache-chrome-chromedriver
- name: Run wasm halo2 tests
run: |
echo "Override default chrome path for 'wasm-pack test'"
ln -sf $CHROME_BIN /usr/local/bin/google-chrome-stable
echo "Check override chrome version"
google-chrome-stable --version
cd mopro-wasm
wasm-pack test --chrome --chromedriver $CHROMEDRIVER_BIN --headless
test-e2e:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Run e2e circom tests
# TODO: Fix this custom jar thing
run: |
cd test-e2e
curl -L https://repo1.maven.org/maven2/net/java/dev/jna/jna/5.13.0/jna-5.13.0.jar -o jna-5.13.0.jar
CLASSPATH=jna-5.13.0.jar cargo test --test circom -- --nocapture
- name: Run e2e halo2 tests
run: CLASSPATH=jna-5.13.0.jar cargo test --test halo2 -- --nocapture
build-xcframework:
runs-on: macos-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Build iOS xcframework
run: cd test-e2e && cargo run --bin ios
- name: Cache xcframework
id: cache-xcframework
uses: actions/cache/save@v4
with:
path: test-e2e/MoproiOSBindings
key: ${{ github.sha }}-xcframework
build-ios-app-device:
runs-on: macos-latest
needs: build-xcframework
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Restore cached xcframework
id: cache-restore-xcframework
uses: actions/cache/restore@v4
with:
path: test-e2e/MoproiOSBindings
key: ${{ github.sha }}-xcframework
- name: Build app for device
run: xcodebuild -project ./test-e2e/ios/mopro-test.xcodeproj -scheme mopro-test -destination generic/platform=iOS build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
build-ios-app-simulator:
runs-on: macos-latest
needs: build-xcframework
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Restore cached xcframework
id: cache-restore-xcframework
uses: actions/cache/restore@v4
with:
path: test-e2e/MoproiOSBindings
key: ${{ github.sha }}-xcframework
- name: Build app for device
run: xcodebuild -project ./test-e2e/ios/mopro-test.xcodeproj -scheme mopro-test -destination generic/platform=iOS\ Simulator build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
test-ios-app-simulator:
runs-on: macos-14
needs: build-xcframework
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Restore cached xcframework
id: cache-restore-xcframework
uses: actions/cache/restore@v4
with:
path: test-e2e/MoproiOSBindings
key: ${{ github.sha }}-xcframework
# to list available simulators: xcrun simctl list devices
- name: Test app in simulator
run: xcodebuild -project ./test-e2e/ios/mopro-test.xcodeproj -scheme mopro-test -destination 'platform=iOS Simulator,name=iPhone 15' test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
build-android-lib:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Build Android bindings
run: cd test-e2e && cargo run --bin android
- name: Cache android lib
id: cache-android-lib
uses: actions/cache/save@v4
with:
path: test-e2e/MoproAndroidBindings
key: ${{ github.sha }}-android-lib
build-android-app:
runs-on: ubuntu-latest
needs: build-android-lib
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Restore cached android lib
id: cache-restore-android-lib
uses: actions/cache/restore@v4
with:
path: test-e2e/MoproAndroidBindings
key: ${{ github.sha }}-android-lib
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17
- name: Setup Android SDK
uses: android-actions/[email protected]
- name: Build android app
run: cd test-e2e/android && ./gradlew build
build-halo2-wasm-web:
runs-on: ubuntu-latest
needs: setup-halo2-wasm-env
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
steps:
- uses: actions/checkout@v4
- name: Restore cached wasm-pack
uses: actions/cache@v4
with:
path: ~/.cargo/bin/wasm-pack
key: ${{ runner.os }}-wasm-pack
- name: Cache halo2 wasm circuit
id: cache-halo2-wasm-circuit
uses: actions/cache@v4
with:
path: |
test-e2e/web/mopro-pkg
key: ${{ runner.os }}-halo2-wasm-circuit-${{ hashFiles('mopro-wasm/**/*') }}
- name: Build circuits for Wasm Web app
if: steps.cache-halo2-wasm-circuit.outputs.cache-hit != 'true'
run: |
cd mopro-wasm
wasm-pack build --target web --out-dir ../test-e2e/web/mopro-pkg -- --all-features
cd ..
mkdir -p test-e2e/web/mopro-pkg/parameters
cp test-vectors/halo2/* test-e2e/web/mopro-pkg/parameters/
test-halo2-wasm-web:
runs-on: ubuntu-latest
needs:
- setup-halo2-wasm-env
- build-halo2-wasm-web
env:
CHROME_BIN: ${{ needs.setup-halo2-wasm-env.outputs.chrome-dir }}/chrome
CHROMEDRIVER_BIN: ${{ needs.setup-halo2-wasm-env.outputs.chromedriver-dir }}/chromedriver
defaults:
run:
working-directory: test-e2e/web
steps:
- uses: actions/checkout@v4
- name: Restore cached chrome and chromedriver
uses: actions/cache@v4
with:
path: |
${{ needs.setup-halo2-wasm-env.outputs.chrome-dir }}
${{ needs.setup-halo2-wasm-env.outputs.chromedriver-dir }}
key: ${{ runner.os }}-cache-chrome-chromedriver
- name: Restore cached halo2 wasm circuit
uses: actions/cache@v4
with:
path: |
test-e2e/web/mopro-pkg
key: ${{ runner.os }}-halo2-wasm-circuit-${{ hashFiles('mopro-wasm/**/*') }}
- name: Install dependencies
run: yarn install
- name: Run halo2-wasm-app server and test it
run: |
nohup yarn start &
for i in {1..30}; do
if curl --silent http://localhost:3000 > /dev/null; then
echo "Server is ready!"
break
fi
echo "Waiting for server..."
sleep 1
done
yarn test