-
Notifications
You must be signed in to change notification settings - Fork 125
180 lines (155 loc) · 5.42 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
name: Build & Test & Clippy
on:
workflow_dispatch:
push:
branches: [ master, 'polkadot-v[0-9]+.[0-9]+.[0-9]+*' ]
pull_request:
branches: [ master, 'polkadot-v[0-9]+.[0-9]+.[0-9]+*' ]
env:
CARGO_TERM_COLOR: always
jobs:
cancel_previous_runs:
name: Cancel Previous Runs
runs-on: ubuntu-20.04
steps:
- uses: styfle/[email protected]
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
build:
name: ${{ matrix.check }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
# 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.
check: [
# Test for no-std compatibility.
# `--locked` to enforce an up-to-date Cargo.lock
cargo build --release --workspace --locked --exclude test-no-std,
# Test for no-std compatibility.
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,
# Test for 32 bit and wasm32-unknown-unknown compatibility
cargo build --target wasm32-unknown-unknown --no-default-features --features sync-api,
# Test for async compilation
cargo build --no-default-features --features "std jsonrpsee-client",
# Compile async examples separately to enable async-mode
cargo build --release -p ac-examples --example get_blocks_async --no-default-features,
cargo build --release -p ac-examples --example runtime_update_async --no-default-features,
# Clippy
cargo clippy --workspace --exclude test-no-std -- -D warnings,
cargo clippy --all-features --examples -- -D warnings,
# Run tests and build examples
cargo test --release --workspace --all-features --exclude test-no-std,
# Fmt
cargo fmt --all -- --check
]
steps:
- uses: actions/checkout@v3
- name: init-rust-target
run: rustup show
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.check }}
- name: ${{ matrix.check }}
run: ${{ matrix.check }}
- name: Upload sync examples
uses: actions/upload-artifact@v3
if: contains(matrix.check, 'cargo test')
with:
name: examples
path: |
target/release/examples/*
!target/release/examples/*async*
!target/release/examples/*.d
!target/release/examples/*-*
- name: Upload async examples
uses: actions/upload-artifact@v3
if: contains(matrix.check, 'async')
with:
name: examples
path: |
target/release/examples/*async
taplo-fmt:
name: "Taplo fmt"
runs-on: ubuntu-latest
container: "tamasfe/taplo:0.7.0-alpine"
steps:
- uses: actions/checkout@v3
- name: Run Taplo fmt
run: taplo fmt --check
license-check:
name: "License check"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install cargo-about
uses: baptiste0928/cargo-install@v2
with:
crate: cargo-about
version: "0.5"
- 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@v3
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_offline,
custom_nonce,
check_extrinsic_events,
get_account_identity,
get_blocks_async,
get_storage,
print_metadata,
staking_batch_payout,
subscribe_events,
sudo,
transfer_with_tungstenite_client,
transfer_with_ws_client,
author_tests,
chain_tests,
dispatch_errors_tests,
frame_system_tests,
pallet_balances_tests,
pallet_transaction_payment_tests,
state_tests,
runtime_update_sync,
runtime_update_async,
]
steps:
- uses: actions/checkout@v3
- name: Run latest node
run: |
docker run -p 9944:9944 -p 9933:9933 -p 30333:30333 parity/substrate:latest --dev --rpc-external &
- name: Wait until node has started
run: sleep 20s
shell: bash
- name: Download example from previous run
uses: actions/download-artifact@v3
with:
name: examples
- name: Run Examples
timeout-minutes: 5
run: |
docker ps
nc -z -v 127.0.0.1 9944
chmod +x ${{ matrix.example }}
./${{ matrix.example }}