-
Notifications
You must be signed in to change notification settings - Fork 47
391 lines (335 loc) · 12.5 KB
/
check-code.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
name: Check codebase
on:
pull_request:
push:
branches:
- develop
- master
tags:
- '[0-9]+.[0-9]+.[0-9]+*'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
get-commit-head:
name: Get HEAD commit message
runs-on: ubuntu-latest
outputs:
headCommitMsg: ${{ steps.get-head-commit-message.outputs.headCommitMsg }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
# We use different payloads depending on whether this is a `push` or a `pull_request` event
ref: ${{ github.event.head_commit.id || github.event.pull_request.head.sha }}
- name: Get HEAD commit message
id: get-head-commit-message
run: echo "headCommitMsg=$(git show -s --format=%s)" >> "$GITHUB_OUTPUT"
cargo-clippy:
name: Run Clippy checks
runs-on: ubuntu-latest
container:
image: paritytech/ci-unified:bullseye-1.74.0
env:
# Configured by the Docker image. We can't change this unless the image does it.
CARGO_HOME: /usr/local/cargo
SKIP_WASM_BUILD: 1
needs: get-commit-head
if: ${{ !contains(needs.get-commit-head.outputs.headCommitMsg, 'ci-skip-rust') }}
strategy:
matrix:
cargo-flags:
# Generic clippy checks for all features
- --all-targets --all-features
# Generic clippy checks for no features (catches some missing `no_std`-only lints)
- --all-targets
# Clippy lints specifically for all runtime code, excluding all test and binary crates
- --target wasm32-unknown-unknown --no-default-features --workspace --exclude kilt-parachain --exclude standalone-node --exclude xcm-integration-tests --exclude 'dip-provider*' --exclude 'dip-consumer*'
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Cargo cache
uses: actions/cache@v4
with:
path: |
${{ env.CARGO_HOME }}/bin/
${{ env.CARGO_HOME }}/registry/index/
${{ env.CARGO_HOME }}/registry/cache/
${{ env.CARGO_HOME }}/git/db/
key: ${{ github.job }}-${{ github.ref }}-${{ matrix.cargo-flags }}-${{ hashFiles('**/Cargo.lock') }}
save-always: true
- name: Run `cargo clippy`
run: cargo clippy --locked --no-deps ${{ matrix.cargo-flags }}
cargo-fmt:
name: Check formatting
runs-on: ubuntu-latest
container:
image: paritytech/ci-unified:bullseye-1.74.0
env:
# Configured by the Docker image. We can't change this unless the image does it.
CARGO_HOME: /usr/local/cargo
# Latest nightly version matching the base rustc version (1.74.0).
RUSTUP_NIGHTLY_VERSION: nightly-2023-10-02
needs: get-commit-head
if: ${{ !contains(needs.get-commit-head.outputs.headCommitMsg, 'ci-skip-rust') }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Cargo cache
uses: actions/cache@v4
with:
path: |
${{ env.CARGO_HOME }}/bin/
${{ env.CARGO_HOME }}/registry/index/
${{ env.CARGO_HOME }}/registry/cache/
${{ env.CARGO_HOME }}/git/db/
key: ${{ github.job }}-${{ github.ref }}-${{ hashFiles('**/Cargo.lock') }}
save-always: true
- name: Install nightly toolchain
run: rustup toolchain add ${{ env.RUSTUP_NIGHTLY_VERSION }}
- name: Run `cargo fmt`
run: cargo +${{ env.RUSTUP_NIGHTLY_VERSION }} fmt -- --check
- name: Run `taplo`
run: taplo fmt --check
cargo-deny:
name: Check cargo-deny rules
runs-on: ubuntu-latest
needs: get-commit-head
if: ${{ !contains(needs.get-commit-head.outputs.headCommitMsg, 'ci-skip-rust') }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run `cargo deny`
uses: EmbarkStudios/cargo-deny-action@v2
with:
# All is set in the config file
arguments:
command-arguments: "--hide-inclusion-graph -c .cargo-deny.toml --show-stats -D warnings"
integration-tests:
name: Run Chopsticks tests
runs-on: ubuntu-latest
env:
working-dir: ./integration-tests/chopsticks
CI: true
PEREGRINE_WASM_OVERRIDE: ../../target/debug/wbuild/peregrine-runtime/peregrine_runtime.wasm
defaults:
run:
working-directory: ${{ env.working-dir }}
needs: get-commit-head
if: ${{ !contains(needs.get-commit-head.outputs.headCommitMsg, 'ci-skip-integration-tests') }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Free Disk Space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
- name: Setup environment
uses: actions/setup-node@v4
with:
node-version-file: "${{ env.working-dir }}/.nvmrc"
- name: Install dependencies
run: yarn --immutable
- name: Check TS
run: yarn ts-check
- name: Check lints
run: yarn lint
- name: Set up Cargo cache
uses: actions/cache@v4
with:
# Not executed in a container, so we cache the local paths as on the GH worker.
path: |
${HOME}/.cargo/bin/
${HOME}/.cargo/registry/index/
${HOME}/.cargo/registry/cache/
${HOME}/.cargo/git/db/
key: ${{ github.job }}-${{ github.ref }}-${{ hashFiles('**/Cargo.lock') }}
save-always: true
- name: Build Peregrine runtime
run: cargo build -p peregrine-runtime
- name: Run Chopsticks tests
run: yarn test:CI
cargo-test:
name: Run Cargo tests
runs-on: ubuntu-latest
env:
# Configured by the Docker image. We can't change this unless the image does it.
CARGO_HOME: /usr/local/cargo
needs: cargo-clippy
strategy:
matrix:
features:
-
- --all-features
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Free Disk Space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
- name: Set up Cargo cache
uses: actions/cache@v4
with:
# These paths are mounted inside the Docker container.
# We cannot mount the `.cargo/bin` folder since the container already contains binaries, and overriding with an empty one breaks compilation.
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
key: ${{ github.job }}-${{ github.ref }}-${{ matrix.features }}-${{ hashFiles('**/Cargo.lock') }}
save-always: true
- name: Run `cargo test`
# We cannot use the default `container:` component because it runs out of memory, so we resort to using this solution instead.
# Maybe re-evaluate this job if anything changes GH side.
run: |
docker run --rm \
-v "${GITHUB_WORKSPACE}:/workspace" \
-v "${HOME}/.cargo/registry/index:${{ env.CARGO_HOME }}/registry/index" \
-v "${HOME}/.cargo/registry/cache:${{ env.CARGO_HOME }}/registry/cache" \
-v "${HOME}/.cargo/git/db:${{ env.CARGO_HOME }}/git/db" \
-w /workspace \
paritytech/ci-unified:bullseye-1.74.0 \
bash -c "cargo test --all-targets --locked ${{ matrix.features }}"
cargo-doc:
name: Check Rustdoc
runs-on: ubuntu-latest
container:
image: paritytech/ci-unified:bullseye-1.74.0
env:
# Configured by the Docker image. We can't change this unless the image does it.
CARGO_HOME: /usr/local/cargo
SKIP_WASM_BUILD: 1
RUSTDOCFLAGS: -D warnings
needs: cargo-clippy
strategy:
matrix:
features:
-
- --all-features
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Cargo cache
uses: actions/cache@v4
with:
path: |
${{ env.CARGO_HOME }}/bin/
${{ env.CARGO_HOME }}/registry/index/
${{ env.CARGO_HOME }}/registry/cache/
${{ env.CARGO_HOME }}/git/db/
key: ${{ github.job }}-${{ github.ref }}-${{ matrix.features }}-${{ hashFiles('**/Cargo.lock') }}
save-always: true
- name: Run `cargo doc`
run: cargo doc --no-deps --locked ${{ matrix.features }}
try-runtime:
name: Run try-runtime
runs-on: ubuntu-latest
container:
image: paritytech/ci-unified:bullseye-1.74.0
env:
# Configured by the Docker image. We can't change this unless the image does it.
CARGO_HOME: /usr/local/cargo
TRY_RUNTIME_CLI_VERSION_TAG: v0.7.0
needs: cargo-clippy
strategy:
matrix:
runtime:
- peregrine
- spiritnet
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Cargo cache
uses: actions/cache@v4
with:
path: |
${{ env.CARGO_HOME }}/bin/
${{ env.CARGO_HOME }}/registry/index/
${{ env.CARGO_HOME }}/registry/cache/
${{ env.CARGO_HOME }}/git/db/
key: ${{ github.job }}-${{ github.ref }}-${{ matrix.runtime }}-${{ hashFiles('**/Cargo.lock') }}
save-always: true
- name: Install try-runtime
run: |
curl -sL https://github.com/paritytech/try-runtime-cli/releases/download/${{ env.TRY_RUNTIME_CLI_VERSION_TAG }}/try-runtime-x86_64-unknown-linux-musl -o try-runtime
chmod +x ./try-runtime
./try-runtime --version
- name: Build runtime
run: cargo build --release --locked -p ${{ matrix.runtime }}-runtime --features try-runtime
- name: Run `try-runtime`
run: |
./try-runtime \
--runtime=./target/release/wbuild/${{ matrix.runtime }}-runtime/${{ matrix.runtime }}_runtime.compact.compressed.wasm \
on-runtime-upgrade \
--disable-spec-version-check \
--checks=all \
live \
--uri=wss://${{ matrix.runtime }}.kilt.io
test-runtime-benchmarks:
name: Test runtime benchmarks
runs-on: ubuntu-latest
env:
# Configured by the Docker image. We can't change this unless the image does it.
CARGO_HOME: /usr/local/cargo
needs: cargo-clippy
if: ${{ github.event_name == 'push'}}
strategy:
matrix:
runtime:
- peregrine
- spiritnet
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Free Disk Space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
- name: Set up Cargo cache
uses: actions/cache@v4
with:
# These paths are mounted inside the Docker container.
# We cannot mount the `.cargo/bin` folder since the container already contains binaries, and overriding with an empty one breaks compilation.
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ github.job }}-${{ github.ref }}-${{ matrix.runtime }}-${{ hashFiles('**/Cargo.lock') }}
- name: Run runtime benchmarks
run: |
docker run --rm \
-v "${GITHUB_WORKSPACE}:/workspace" \
-v "${HOME}/.cargo/registry/index:${{ env.CARGO_HOME }}/registry/index" \
-v "${HOME}/.cargo/registry/cache:${{ env.CARGO_HOME }}/registry/cache" \
-v "${HOME}/.cargo/git/db:${{ env.CARGO_HOME }}/git/db" \
-w /workspace \
paritytech/ci-unified:bullseye-1.74.0 \
bash -c "bash -x scripts/run_benches_for_runtime.sh ${{ matrix.runtime }} dev"
trigger-gitlab:
name: Trigger GitLab CI
runs-on: ubuntu-latest
env:
TARGET_WORKFLOW_FILE: trigger-gitlab-pipeline.yml # Change this in case of file renamings
needs:
- cargo-doc
- cargo-test
- try-runtime
# This is only triggered on pushes, which means pushes on `master`, `develop` or of tags.
- test-runtime-benchmarks
steps:
- name: Trigger "GitLab trigger" workflow
uses: actions/github-script@v7
with:
script: |
github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: '${{ env.TARGET_WORKFLOW_FILE }}',
ref: '${{ github.ref }}',
})