-
Notifications
You must be signed in to change notification settings - Fork 220
419 lines (404 loc) · 13.5 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
name: Build tests
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
jobs:
repolinter:
name: Repolinter
runs-on: solang-ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
- 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/[email protected]
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/[email protected] 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-5
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
submodules: recursive
- name: Rust stable
run: rustup default 1.70.0
- 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 llvm --bins -- -D warnings
- name: Run cargo clippy without llvm feature
run: cargo clippy --workspace --no-default-features --lib -- -D warnings
- name: Run cargo doc
run: cargo doc --workspace --bins
- name: Run cargo fmt
run: cargo fmt --all -- --check
- name: Build
if: always()
run: cargo build --verbose
- name: Run tests
if: always()
run: cargo test --verbose --workspace
- uses: actions/[email protected]
with:
name: solang-linux-x86-64
path: ./target/debug/solang
linux-arm:
name: Linux Arm
runs-on: linux-arm64
if: ${{ github.repository_owner == 'hyperledger' }}
container: ghcr.io/hyperledger/solang-llvm:ci-5
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
submodules: recursive
- name: Rust stable
run: rustup default 1.70.0
- 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@v3
with:
submodules: recursive
- name: Download LLVM
run: curl -sSL -o c:\llvm.zip https://github.com/hyperledger/solang-llvm/releases/download/llvm15-1/llvm15.0-win.zip
- name: Extract LLVM
run: unzip c:\llvm.zip -d c:/
- name: Add LLVM to Path
run: echo "c:\llvm15.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: [self-hosted, macOS, ARM64, MacStadium]
if: ${{ github.repository_owner == 'hyperledger' }}
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
submodules: recursive
- uses: dtolnay/[email protected]
- name: Get LLVM
run: curl -sSL --output llvm15.0-mac-arm.tar.xz https://github.com/hyperledger/solang-llvm/releases/download/llvm15-1/llvm15.0-mac-arm.tar.xz
- name: Extract LLVM
run: tar Jxf llvm15.0-mac-arm.tar.xz
- name: Add LLVM to Path
run: echo "$(pwd)/llvm15.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 llvm
- uses: actions/[email protected]
with:
name: solang-mac-arm
path: ./target/debug/solang
mac-intel:
name: Mac Intel
runs-on: macos-11
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
submodules: recursive
- uses: dtolnay/[email protected]
- name: Get LLVM
run: wget -q -O llvm15.0-mac-intel.tar.xz https://github.com/hyperledger/solang-llvm/releases/download/llvm15-1/llvm15.0-mac-intel.tar.xz
- name: Extract LLVM
run: tar Jxf llvm15.0-mac-intel.tar.xz
- name: Add LLVM to Path
run: echo "$(pwd)/llvm15.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-11
needs: [mac-arm, mac-intel]
steps:
- uses: actions/download-artifact@v3
with:
name: solang-mac-intel
- run: mv solang solang-mac-intel
- uses: actions/download-artifact@v3
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-multiarch:
name: Multiarch Container Image
runs-on: linux-arm64
if: ${{ github.repository_owner == 'hyperledger' }}
steps:
- name: Checkout sources
uses: actions/checkout@v3
- 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}} \
--provenance=false \
--tag ghcr.io/${GITHUB_REPOSITORY}:latest \
--platform linux/arm64,linux/amd64 \
--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-5
needs: linux-x86-64
steps:
- name: Checkout sources
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16'
- name: Rust Stable
run: rustup default stable
- name: Setup yarn
run: npm install -g yarn
- uses: actions/download-artifact@v3
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
solana:
name: Solana Integration test
runs-on: solang-ubuntu-latest
container: ghcr.io/hyperledger/solang-llvm:ci-5
needs: linux-x86-64
steps:
- name: Checkout sources
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16'
- name: Rust Stable
run: rustup default stable
- uses: actions/download-artifact@v3
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
polkadot:
name: Polkadot Integration test
runs-on: solang-ubuntu-latest
needs: linux-x86-64
steps:
- name: Checkout sources
uses: actions/checkout@v3
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:054bef6 substrate-contracts-node --dev --rpc-external) >> $GITHUB_OUTPUT
id: substrate
- uses: actions/setup-node@v3
with:
node-version: '16'
- uses: actions/download-artifact@v3
with:
name: solang-linux-x86-64
path: bin
- run: |
chmod 755 ./bin/solang
echo "$(pwd)/bin" >> $GITHUB_PATH
- 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: 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:054bef6 substrate-contracts-node --dev --rpc-external) >> $GITHUB_OUTPUT
id: substrate
- uses: actions/download-artifact@master
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}}
vscode:
name: Visual Code Extension
runs-on: solang-ubuntu-latest
needs: linux-x86-64
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/download-artifact@v3
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@v3
with:
node-version: '16'
- 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
std-lib-tests:
name: Stdlib
runs-on: solang-ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Lints for stdlib
run: |
make lint
working-directory: ./stdlib
- name: Stdlib tests
run: |
make test
./test
working-directory: ./stdlib