-
Notifications
You must be signed in to change notification settings - Fork 220
584 lines (565 loc) · 19.2 KB
/
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
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
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
name: Build tests
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
env:
LLVM_PROFILE_FILE: ${{ github.workspace }}/target/solang-%p-%10m.profraw
jobs:
repolinter:
name: Repolinter
runs-on: solang-ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Run repolinter
run: npx repolinter --rulesetUrl https://raw.githubusercontent.com/hyperledger-labs/hyperledger-community-management-tools/master/repo_structure/repolint.json
- uses: enarx/spdx@master
with:
licenses: Apache-2.0 MIT
docs:
name: Docs
runs-on: solang-ubuntu-latest
container: ubuntu:22.04
steps:
- name: Install Python and git
run: |
apt-get update
apt-get install -y python3-pip git pkg-config libcairo-dev latexmk
- name: Checkout sources
uses: actions/checkout@v4
with:
# docs/conf.py uses `git describe --tags` which requires full history
fetch-depth: 0
- name: Build docs
working-directory: ./docs
run: |
# Without the --add safe.directory we get the following error:
# fatal: detected dubious ownership in repository at '/__w/solang/solang'
# actions/checkout@v4 is supposed to fix this, but it does not work
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
pip install -r requirements.txt
make html epub
linux-x86-64:
name: Linux x86-64
runs-on: solang-ubuntu-latest
container: ghcr.io/hyperledger/solang-llvm:ci-7
env:
RUSTFLAGS: -C instrument-coverage -C llvm-args=--instrprof-atomic-counter-update-all --cfg=coverage --cfg=trybuild_no_target
CARGO_INCREMENTAL: 0
CARGO_LLVM_COV: 1
CARGO_LLVM_COV_TARGET_DIR: ${{ github.workspace }}/target
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.81.0
components: |
llvm-tools
clippy
rustfmt
- name: cargo install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Run cargo clippy
run: cargo clippy --workspace --tests --bins -- -D warnings
- name: Run cargo clippy without wasm_opt feature
run: cargo clippy --workspace --no-default-features --features language_server,llvm,soroban --bins -- -D warnings
- name: Run cargo clippy without llvm feature
run: cargo clippy --workspace --no-default-features --lib -- -D warnings
- name: Run cargo clippy with only soroban feature
run: cargo clippy --workspace --no-default-features --features soroban,llvm --lib -- -D warnings
- name: Run cargo doc
run: cargo doc --workspace --bins
- name: Run cargo fmt
run: cargo fmt --all -- --check
- name: Configure llvm-cov and build
if: always()
run: |
cargo llvm-cov clean --workspace
cargo build
- name: Run tests
if: always()
run: cargo llvm-cov --all-features --workspace --no-report --jobs 2
- name: Upload binary
uses: actions/[email protected]
with:
name: solang-linux-x86-64
path: ./target/debug/solang
- name: Compress test coverage files
run: |
rm -r bpf wasm tmp cxxbridge CACHEDIR.TAG
rm -r debug/build debug/deps debug/examples debug/incremental
tar -czvf rust-tests.tar.gz *
working-directory: ./target
- name: Upload test coverage files
uses: actions/[email protected]
with:
name: rust-tests.tar.gz
path: ./target/rust-tests.tar.gz
linux-arm:
name: Linux Arm
runs-on: solang-arm
if: ${{ github.repository_owner == 'hyperledger-solang' }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
submodules: recursive
- name: Basic build tools
run: |
sudo apt-get update
sudo apt-get install -y gcc g++ make
- uses: dtolnay/[email protected]
- name: Get LLVM
run: curl -sSL --output llvm16.0-linux-arm64.tar.xz https://github.com/hyperledger-solang/solang-llvm/releases/download/llvm16-0/llvm16.0-linux-arm64.tar.xz
- name: Extract LLVM
run: tar Jxf llvm16.0-linux-arm64.tar.xz
- name: Add LLVM to Path
run: echo "$(pwd)/llvm16.0/bin" >> $GITHUB_PATH
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose --workspace
- uses: actions/[email protected]
with:
name: solang-linux-arm64
path: ./target/debug/solang
windows:
name: Windows
runs-on: windows-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
submodules: recursive
- name: Download LLVM
run: curl -sSL -o c:\llvm.zip https://github.com/hyperledger-solang/solang-llvm/releases/download/llvm16-0/llvm16.0-win.zip
- name: Extract LLVM
run: unzip c:\llvm.zip -d c:/
- name: Add LLVM to Path
run: echo "c:\llvm16.0\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
# Use C:\ as D:\ might run out of space
- name: "Use C: for rust temporary files"
run: echo "CARGO_TARGET_DIR=C:\target" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
- uses: dtolnay/[email protected]
with:
components: clippy
# We run clippy on Linux in the lint job above, but this does not check #[cfg(windows)] items
- name: Run cargo clippy
run: cargo clippy --workspace --tests --bins -- -D warnings -D clippy::inconsistent-struct-constructor
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose --workspace
- uses: actions/[email protected]
with:
name: solang.exe
path: C:/target/debug/solang.exe
# Print disk usage to debug disk space problems
- run: Get-PSDrive
if: always()
mac-arm:
name: Mac Arm
runs-on: macos-13-xlarge
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
submodules: recursive
- uses: dtolnay/[email protected]
- name: Get LLVM
run: curl -sSL --output llvm16.0-mac-arm.tar.xz https://github.com/hyperledger-solang/solang-llvm/releases/download/llvm16-0/llvm16.0-mac-arm.tar.xz
- name: Extract LLVM
run: tar Jxf llvm16.0-mac-arm.tar.xz
- name: Add LLVM to Path
run: echo "$(pwd)/llvm16.0/bin" >> $GITHUB_PATH
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose --workspace
- name: Run tests without wasm_opt
run: cargo test --verbose --workspace --no-default-features --features language_server,llvm,soroban
- uses: actions/[email protected]
with:
name: solang-mac-arm
path: ./target/debug/solang
mac-intel:
name: Mac Intel
runs-on: macos-12
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
submodules: recursive
- uses: dtolnay/[email protected]
- name: Get LLVM
run: wget -q -O llvm16.0-mac-intel.tar.xz https://github.com/hyperledger-solang/solang-llvm/releases/download/llvm16-0/llvm16.0-mac-intel.tar.xz
- name: Extract LLVM
run: tar Jxf llvm16.0-mac-intel.tar.xz
- name: Add LLVM to Path
run: echo "$(pwd)/llvm16.0/bin" >> $GITHUB_PATH
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose --workspace
- uses: actions/[email protected]
with:
name: solang-mac-intel
path: ./target/debug/solang
mac-universal:
name: Mac Universal Binary
runs-on: macos-12
needs: [mac-arm, mac-intel]
steps:
- uses: actions/[email protected]
with:
name: solang-mac-intel
- run: mv solang solang-mac-intel
- uses: actions/[email protected]
with:
name: solang-mac-arm
- run: mv solang solang-mac-arm
- run: lipo -create -output solang-mac solang-mac-intel solang-mac-arm
- uses: actions/[email protected]
with:
name: solang-mac
path: solang-mac
container:
name: Container Image
runs-on: solang-ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- run: echo "push=--push" >> $GITHUB_OUTPUT
id: push
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
- run: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
docker buildx build . \
${{steps.push.outputs.push}} \
--tag ghcr.io/${GITHUB_REPOSITORY}:latest \
--label org.opencontainers.image.description="Solidity Compiler for Solana and Polkadot version $(git describe --tags)"
anchor:
name: Anchor Integration test
runs-on: solang-ubuntu-latest
container: ghcr.io/hyperledger/solang-llvm:ci-7
needs: linux-x86-64
steps:
- name: Checkout sources
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '16'
- uses: dtolnay/[email protected]
- name: Setup yarn
run: npm install -g yarn
- uses: actions/[email protected]
with:
name: solang-linux-x86-64
path: bin
- name: Solang Compiler
run: |
chmod 755 ./bin/solang
echo "$(pwd)/bin" >> $GITHUB_PATH
# Ensure nohup writes output to a file, not the terminal.
# If we don't, solana-test-validator might not be able to write its
# output and exit
- run: nohup solana-test-validator -q > validator.out &
- name: Build Anchor test program
run: |
yarn install
anchor build
working-directory: ./integration/anchor
- name: Deploy Anchor program
run: |
solana -ul airdrop -k id.json 10
anchor deploy
working-directory: ./integration/anchor
- name: Create Solidity interface file for Anchor
run: yarn parse-idl
working-directory: ./integration/anchor
- name: Build Solang contracts
run: yarn build
working-directory: ./integration/anchor
- name: Test Anchor
run: anchor test --skip-local-validator
working-directory: ./integration/anchor
- name: Upload test coverage files
uses: actions/[email protected]
with:
name: anchor-tests
path: ./target/*.profraw
soroban:
name: Soroban Integration test
runs-on: solang-ubuntu-latest
container: ghcr.io/hyperledger/solang-llvm:ci-7
needs: linux-x86-64
steps:
- name: Checkout sources
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '16'
- uses: dtolnay/[email protected]
- uses: actions/[email protected]
with:
name: solang-linux-x86-64
path: bin
- name: Solang Compiler
run: |
chmod 755 ./bin/solang
echo "$(pwd)/bin" >> $GITHUB_PATH
- name: Install Soroban
run: cargo install --locked soroban-cli --version 22.0.0
- name: Add cargo install location to PATH
run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- run: npm install
working-directory: ./integration/soroban
- name: Build Solang contracts
run: npm run build
working-directory: ./integration/soroban
- name: Setup Soroban enivronment
run: npm run setup
working-directory: ./integration/soroban
- name: Deploy and test contracts
run: npm run test
working-directory: ./integration/soroban
- name: Upload test coverage files
uses: actions/[email protected]
with:
name: soroban-tests
path: ./target/*.profraw
solana:
name: Solana Integration test
runs-on: solang-ubuntu-latest
container: ghcr.io/hyperledger/solang-llvm:ci-7
needs: linux-x86-64
steps:
- name: Checkout sources
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '16'
- uses: dtolnay/[email protected]
- uses: actions/[email protected]
with:
name: solang-linux-x86-64
path: bin
- name: Solang Compiler
run: |
chmod 755 ./bin/solang
echo "$(pwd)/bin" >> $GITHUB_PATH
# Ensure nohup writes output to a file, not the terminal.
# If we don't, solana-test-validator might not be able to write its
# output and exit
- run: nohup solana-test-validator -q > validator.out &
- run: npm install
working-directory: ./integration/solana
- name: Build Solang contracts
run: npm run build
working-directory: ./integration/solana
- name: Deploy and test contracts
run: npm run test
working-directory: ./integration/solana
- name: Upload test coverage files
uses: actions/[email protected]
with:
name: solana-tests
path: ./target/*.profraw
polkadot:
name: Polkadot Integration test
runs-on: solang-ubuntu-latest
needs: linux-x86-64
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
submodules: recursive
# We can't run substrate node as a github actions service, since it requires
# command line arguments. See https://github.com/actions/runner/pull/1152
- name: Start substrate contracts node
run: echo id=$(docker run -d -p 9944:9944 ghcr.io/hyperledger/solang-substrate-ci:62a8a6c substrate-contracts-node --dev --rpc-external -lwarn,runtime::contracts=trace) >> $GITHUB_OUTPUT
id: substrate
- uses: actions/[email protected]
with:
name: solang-linux-x86-64
path: bin
- run: |
chmod 755 ./bin/solang
echo "$(pwd)/bin" >> $GITHUB_PATH
- uses: actions/setup-node@v4
with:
node-version: '16'
- run: npm install
working-directory: ./integration/polkadot
- name: Build ink! contracts
run: npm run build-ink
working-directory: ./integration/polkadot
- name: Build Solang contracts
run: npm run build
working-directory: ./integration/polkadot
- name: Deploy and test contracts
run: npm run test
working-directory: ./integration/polkadot
- name: Upload test coverage files
uses: actions/[email protected]
with:
name: polkadot-tests
path: ./target/*.profraw
- name: cleanup
if: always()
run: docker kill ${{steps.substrate.outputs.id}}
polkadot-subxt:
name: Polkadot Integration test with subxt
runs-on: ubuntu-22.04
needs: linux-x86-64
steps:
- name: Checkout sources
uses: actions/checkout@v4
# We can't run substrate node as a github actions service, since it requires
# command line arguments. See https://github.com/actions/runner/pull/1152
- name: Start substrate
run: echo id=$(docker run -d -p 9944:9944 ghcr.io/hyperledger/solang-substrate-ci:62a8a6c substrate-contracts-node --dev --rpc-external -lwarn,runtime::contracts=trace) >> $GITHUB_OUTPUT
id: substrate
- uses: actions/[email protected]
with:
name: solang-linux-x86-64
path: bin
- run: |
chmod 755 ./bin/solang
echo "$(pwd)/bin" >> $GITHUB_PATH
- name: Install latest rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- run: 'parallel solang compile -v --target polkadot --wasm-opt z -o ./contracts/ ::: ../polkadot/*.sol ../polkadot/test/*.sol'
working-directory: ./integration/subxt-tests
- name: Deploy and test contracts
run: cargo test -- --test-threads=1
working-directory: ./integration/subxt-tests
- name: cleanup
if: always()
run: docker kill ${{steps.substrate.outputs.id}}
- name: Upload test coverage files
uses: actions/[email protected]
with:
name: polkadot-subxt-tests
path: ./target/*.profraw
vscode:
name: Visual Code Extension
runs-on: solang-ubuntu-latest
needs: linux-x86-64
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/[email protected]
with:
name: solang-linux-x86-64
path: bin
- run: |
chmod 755 ./bin/solang
echo "$(pwd)/bin" >> $GITHUB_PATH
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '>=18.17'
- run: npm install
working-directory: ./vscode
- run: npm run compile
working-directory: ./vscode
- name: Run headless test
run: xvfb-run npm test
working-directory: ./vscode
- run: npm install -g vsce
working-directory: ./vscode
- run: vsce package
working-directory: ./vscode
- name: Upload test coverage files
uses: actions/[email protected]
with:
name: vscode-tests
path: ./target/*.profraw
std-lib-tests:
name: Stdlib
runs-on: solang-ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Lints for stdlib
run: |
make lint
working-directory: ./stdlib
- name: Stdlib tests
run: |
make test
./test
working-directory: ./stdlib
coverage:
runs-on: ubuntu-latest
name: Coverage report
container: ghcr.io/hyperledger/solang-llvm:ci-7
needs: [linux-x86-64, solana, anchor, polkadot, polkadot-subxt, vscode]
env:
RUSTFLAGS: -C instrument-coverage -C llvm-args=--instrprof-atomic-counter-update-all --cfg=coverage --cfg=trybuild_no_target
CARGO_INCREMENTAL: 0
CARGO_LLVM_COV: 1
CARGO_LLVM_COV_TARGET_DIR: ${{ github.workspace }}/target
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.81.0
components: llvm-tools
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Download Rust coverage files
uses: actions/[email protected]
with:
name: rust-tests.tar.gz
path: ./target
- name: Download Solana coverage files
uses: actions/[email protected]
with:
name: solana-tests
path: ./target
- name: Download Polkadot coverage files
uses: actions/[email protected]
with:
name: polkadot-tests
path: ./target
- name: Download Polkadot subxt coverage files
uses: actions/[email protected]
with:
name: polkadot-subxt-tests
path: ./target
- name: Download Anchor coverage files
uses: actions/[email protected]
with:
name: anchor-tests
path: ./target
- name: Download VSCode coverage files
uses: actions/[email protected]
with:
name: vscode-tests
path: ./target
- name: Unpack test coverage files
run: tar -xf rust-tests.tar.gz
working-directory: ./target
- name: Generate code report
run: cargo llvm-cov report --lcov --output-path lcov.info
- name: Upload coverage report to codecov.io
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
fail_ci_if_error: false