-
Notifications
You must be signed in to change notification settings - Fork 94
220 lines (184 loc) · 6.44 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
name: Rust CI/CD
on:
push:
branches:
- master
pull_request:
env:
IMAGE: paritytech/ci-unified:bullseye-1.73.0
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
set-image:
# GitHub Actions does not allow using 'env' in a container context.
# This workaround sets the container image for each job using 'set-image' job output.
runs-on: ubuntu-latest
outputs:
IMAGE: ${{ steps.set_image.outputs.IMAGE }}
steps:
- id: set_image
run: echo "IMAGE=${{ env.IMAGE }}" >> $GITHUB_OUTPUT
# Checks
fmt:
runs-on: ubuntu-latest
needs: [set-image]
container: ${{ needs.set-image.outputs.IMAGE }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Show Cargo version
run: cargo +nightly -vV
- name: Cargo fmt
run: cargo +nightly fmt --all -- --check
clippy:
runs-on: ubuntu-latest
needs: [set-image]
container: ${{ needs.set-image.outputs.IMAGE }}
steps:
- name: Checkout code/.
uses: actions/checkout@v4
- name: Show Rust version
run: |
cargo -vV
rustc -vV
rustup show
- name: Cache Rust dependencies
uses: swatinem/rust-cache@v2
with:
key: ${{ runner.os }}-rust-${{ hashFiles('**/Cargo.lock') }}
- name: Run Clippy
run: |
cargo +stable clippy --locked -- -Dwarnings
cargo +stable clippy --locked -p parity-scale-codec-derive -- -Dwarnings
cargo +stable clippy --locked --test clippy -- -Dwarnings
checks:
runs-on: ubuntu-latest
needs: [set-image]
container: ${{ needs.set-image.outputs.IMAGE }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Show Rust version
run: |
cargo -vV
rustc -vV
rustup show
- name: Cache Rust dependencies
uses: swatinem/rust-cache@v2
with:
key: ${{ runner.os }}-rust-${{ hashFiles('**/Cargo.lock') }}
- name: Check Rust Stable (no_derive_no_std)
run: time cargo +stable check --verbose --no-default-features --features bit-vec,bytes,generic-array
- name: Check Rust Stable (no_std-chain-error)
run: |
export RUSTFLAGS='-Cdebug-assertions=y -Dwarnings'
time cargo +stable check --verbose --no-default-features --features chain-error
- name: check-rust-stable-no_derive
run: |
export RUSTFLAGS='-Cdebug-assertions=y -Dwarnings'
time cargo +stable check --verbose --features bit-vec,bytes,generic-array
- name: check-rust-stable-only_mel
run: |
export RUSTFLAGS='-Cdebug-assertions=y -Dwarnings'
time cargo +stable check --verbose --features max-encoded-len
# Tests
tests:
runs-on: ubuntu-latest
needs: [set-image]
container: ${{ needs.set-image.outputs.IMAGE }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Show Rust version
run: |
cargo -vV
rustc -vV
rustup show
- name: Cache Rust dependencies
uses: swatinem/rust-cache@v2
with:
key: ${{ runner.os }}-rust-${{ hashFiles('**/Cargo.lock') }}
- name: Test Rust Stable
run: |
export RUSTFLAGS='-Cdebug-assertions=y -Dwarnings'
time cargo +stable test --verbose --all --features bit-vec,bytes,generic-array,derive,max-encoded-len
- name: Test Rust Stable (no_derive)
run: |
export RUSTFLAGS='-Cdebug-assertions=y -Dwarnings'
time cargo +stable test --verbose --features bit-vec,bytes,generic-array
- name: Test Rust Stable (only_mel)
run: |
export RUSTFLAGS='-Cdebug-assertions=y -Dwarnings'
time cargo +stable test --verbose --features max-encoded-len
- name: Test Rust Stable (only_mel-no_default_std)
run: |
export RUSTFLAGS='-Cdebug-assertions=y -Dwarnings'
time cargo +stable test --verbose --features max-encoded-len,std --no-default-features
# Benches
bench-rust-nightly:
runs-on: ubuntu-latest
needs: [set-image]
strategy:
matrix:
feature: [bit-vec,bytes,generic-array,derive,max-encoded-len]
container: ${{ needs.set-image.outputs.IMAGE }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cache Rust dependencies
uses: swatinem/rust-cache@v2
with:
key: ${{ runner.os }}-rust-${{ hashFiles('**/Cargo.lock') }}
- name: Bench Rust Nightly
run: |
export RUSTFLAGS='-Cdebug-assertions=y -Dwarnings'
time cargo +nightly bench --features ${{ matrix.feature }}
miri:
runs-on: ubuntu-latest
needs: [set-image]
strategy:
matrix:
feature: [bit-vec,bytes,generic-array,arbitrary]
container: ${{ needs.set-image.outputs.IMAGE }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cache Rust dependencies
uses: swatinem/rust-cache@v2
with:
key: ${{ runner.os }}-rust-${{ hashFiles('**/Cargo.lock') }}
- name: Run Miri
run: |
export RUST_BACKTRACE=1
export RUSTFLAGS='-Cdebug-assertions=y -Dwarnings'
export MIRIFLAGS='-Zmiri-disable-isolation'
time cargo +nightly miri test --features ${{ matrix.feature }} --release
# Build
build-linux-ubuntu-amd64:
runs-on: ubuntu-latest
needs: [set-image, clippy, checks, tests]
container: ${{ needs.set-image.outputs.IMAGE }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cache Rust dependencies
uses: swatinem/rust-cache@v2
with:
key: ${{ runner.os }}-rust-${{ hashFiles('**/Cargo.lock') }}
- name: Build for Linux (Ubuntu, AMD64)
run: cargo build --verbose --release --features bit-vec,bytes,generic-array,derive
publish-dry-run:
runs-on: ubuntu-latest
needs: [set-image, build-linux-ubuntu-amd64]
container: ${{ needs.set-image.outputs.IMAGE }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cache Rust dependencies
uses: swatinem/rust-cache@v2
with:
key: ${{ runner.os }}-rust-${{ hashFiles('**/Cargo.lock') }}
- name: Dry Run Publish
if: github.event_name == 'pull_request'
run: cargo publish -p parity-scale-codec --dry-run