-
Notifications
You must be signed in to change notification settings - Fork 124
294 lines (256 loc) · 9.18 KB
/
ci.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
name: Build & Test & Clippy
on:
workflow_dispatch:
push:
branches: [ master, 'polkadot-v[0-9]+.[0-9]+.[0-9]+*', 'release-polkadot-v[0-9]+.[0-9]+.[0-9]+*' ]
pull_request:
branches: [ master, 'polkadot-v[0-9]+.[0-9]+.[0-9]+*', 'release-polkadot-v[0-9]+.[0-9]+.[0-9]+*' ]
schedule:
- cron: "0 0 * * *"
env:
CARGO_TERM_COLOR: always
jobs:
cancel_previous_runs:
name: Cancel Previous Runs
runs-on: ubuntu-latest
steps:
- uses: styfle/cancel-workflow-action@0.12.1
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
free-disk-space:
runs-on: ubuntu-latest
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: false
docker-images: false
swap-storage: false
build:
name: ${{ matrix.check }}
runs-on: ${{ matrix.os }}
needs: free-disk-space
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
check: [
# Test for no-std compatibility.
# `--locked` to enforce an up-to-date Cargo.lock
cargo build --release --workspace --locked --exclude test-no-std,
# We need to compile `test-no-std` separately, otherwise we have std leaks from the build-deps.
#
# `test-no-std` is only meant to check if the `substrate-api-client` compiles to `no_std`, hence
# we omit clippy and test there.
cargo build --release -p test-no-std --features api-client,
cargo build --release -p test-no-std --features compose-macros,
cargo build --release -p test-no-std --features node-api,
cargo build --release -p test-no-std --features primitives,
# Check build of stand-alone features.
cargo check --no-default-features,
cargo check --no-default-features --features sync-api,
cargo check --no-default-features --features jsonrpsee-client,
cargo check --no-default-features --features tungstenite-client,
cargo check --no-default-features --features ws-client,
cargo check --no-default-features --features staking-xt,
cargo check --no-default-features --features contracts-xt,
cargo check --no-default-features --features std,
# Test for 32 bit and wasm32-unknown-unknown compatibility
cargo build --target wasm32-unknown-unknown --no-default-features --features sync-api,
cargo build --release -p ac-examples-wasm --examples --target wasm32-unknown-unknown,
# Test for 32 bit and wasm32-wasip1 compatibility
cargo build --target wasm32-wasip1 --no-default-features --features std --features staking-xt --features contracts-xt --features sync-api,
# Compile examples and integration test separately to ensure features are not cross-imported
cargo test --release -p ac-examples-async,
cargo test --release -p ac-examples-sync,
cargo test --release -p ac-testing-async,
cargo test --release -p ac-testing-sync,
# Clippy
cargo clippy -- -D warnings,
cargo clippy --no-default-features -- -D warnings,
cargo clippy --all-features --examples -- -D warnings,
# Run unit tests
cargo test --release --all-features --workspace --exclude test-no-std --exclude "ac-examples-*" --exclude "ac-testing-*",
# Fmt
cargo fmt --all -- --check
]
steps:
- uses: actions/checkout@v4
- name: init-rust-target
run: rustup show && rustup component add rust-src
- name: Cargo update
if: ${{ github.event_name == 'schedule' }}
run: cargo update
- name: Upload Cargo.lock
uses: actions/upload-artifact@v4
# Upload the Cargo.lock from the build with --locked as this one should not update the Cargo.lock anymore
if: contains(matrix.check, '--locked')
with:
name: cargo-lock
path: Cargo.lock
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.check }}
- name: ${{ matrix.check }}
run: ${{ matrix.check }}
- name: Upload async examples
uses: actions/upload-artifact@v4
if: contains(matrix.check, 'examples-async')
with:
name: examples-async
path: |
target/release/examples/*
!target/release/examples/*.d
!target/release/examples/*-*
- name: Upload sync examples
uses: actions/upload-artifact@v4
if: contains(matrix.check, 'examples-sync')
with:
name: examples-sync
path: |
target/release/examples/*
!target/release/examples/*.d
!target/release/examples/*-*
- name: Upload wasm examples
uses: actions/upload-artifact@v4
if: contains(matrix.check, 'examples-wasm')
with:
name: examples-wasm
path: |
target/wasm32-unknown-unknown/release/examples/*.wasm
- name: Upload async testing examples
uses: actions/upload-artifact@v4
if: contains(matrix.check, 'testing-async')
with:
name: examples-testing-async
path: |
target/release/examples/*
!target/release/examples/*.d
!target/release/examples/*-*
- name: Upload sync testing examples
uses: actions/upload-artifact@v4
if: contains(matrix.check, 'testing-sync')
with:
name: examples-testing-sync
path: |
target/release/examples/*
!target/release/examples/*.d
!target/release/examples/*-*
taplo-fmt:
name: "Taplo fmt"
runs-on: ubuntu-latest
container: "tamasfe/taplo:latest"
steps:
- uses: actions/checkout@v4
- name: Run Taplo fmt
run: taplo fmt --check
license-check:
name: "License check"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install cargo-about
uses: baptiste0928/cargo-install@v3
with:
crate: cargo-about
version: "0.6"
- name: Run license check
# Explicitly use stable because otherwise cargo will trigger a download of
# the nightly version specified in rust-toolchain.toml
run: cargo +stable about generate about.hbs > license.html
- name: Archive license file
uses: actions/upload-artifact@v4
with:
name: license
path: license.html
examples:
runs-on: ${{ matrix.os }}
needs: build
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
example: [
benchmark_bulk_xt,
compose_extrinsic,
custom_nonce,
check_extrinsic_events,
get_blocks,
get_storage,
print_metadata,
subscribe_events,
sudo,
new_json_rpc_api_calls,
transfer_with_tungstenite_client,
transfer_with_ws_client,
author_tests,
chain_tests,
dispatch_errors_tests,
frame_system_tests,
jsonrpsee_tests,
keystore_tests,
pallet_balances_tests,
pallet_transaction_payment_tests,
runtime_api_tests,
tungstenite_client_test,
ws_client_test,
state_tests,
query_runtime_api,
runtime_update_sync,
runtime_update_async,
]
steps:
- uses: actions/checkout@v4
- name: Run latest node
run: |
docker run -p 9944:9944 -p 9933:9933 -p 30333:30333 parity/polkadot:latest --dev --rpc-external &
- name: Wait until node has started
run: sleep 20s
shell: bash
- name: Download examples from previous run
uses: actions/download-artifact@v4
with:
pattern: examples-*
merge-multiple: true
- name: Run Examples
timeout-minutes: 5
run: |
docker ps
nc -z -v 127.0.0.1 9944
chmod +x ${{ matrix.example }}
./${{ matrix.example }}
wasm_examples:
runs-on: ${{ matrix.os }}
needs: build
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
example: [
wasm_example,
]
steps:
- uses: actions/checkout@v4
- name: Download examples from previous run
uses: actions/download-artifact@v4
with:
pattern: examples-wasm
merge-multiple: true
- name: Setup `wasmtime`
uses: bytecodealliance/actions/wasmtime/setup@v1
- name: Run wasm example
run: wasmtime --invoke main ${{ matrix.example }}.wasm 0 0
merge:
runs-on: ubuntu-latest
needs: [examples, wasm_examples]
steps:
- name: Merge Artifacts
uses: actions/upload-artifact/merge@v4
with:
separate-directories: true
name: artifacts
delete-merged: true