This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
Copy pathtest.yml
437 lines (417 loc) · 17.2 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
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
# This file is part of .gitlab-ci.yml
# Here are all jobs that are executed during "test" stage
cargo-deny:
stage: test
extends:
- .docker-env
- .nightly-pipeline
script:
- rusty-cachier snapshot create
- cargo deny check --hide-inclusion-graph -c ./scripts/ci/deny.toml
- rusty-cachier cache upload
after_script:
- !reference [.rusty-cachier, after_script]
- echo "___The complete log is in the artifacts___"
- cargo deny check -c ./scripts/ci/deny.toml 2> deny.log
artifacts:
name: $CI_COMMIT_SHORT_SHA
expire_in: 3 days
when: always
paths:
- deny.log
# FIXME: Temporarily allow to fail.
allow_failure: true
cargo-fmt:
stage: test
variables:
RUSTY_CACHIER_TOOLCHAIN: nightly
extends:
- .docker-env
- .test-refs
script:
- rusty-cachier snapshot create
- cargo +nightly fmt --all -- --check
- rusty-cachier cache upload
cargo-clippy:
stage: test
# this is an artificial job dependency, for pipeline optimization using GitLab's DAGs
needs:
- job: cargo-fmt
artifacts: false
variables:
RUSTY_CACHIER_TOOLCHAIN: nightly
extends:
- .docker-env
- .test-refs
script:
- rusty-cachier snapshot create
- SKIP_WASM_BUILD=1 env -u RUSTFLAGS cargo +nightly clippy --all-targets
- rusty-cachier cache upload
cargo-check-benches:
stage: test
variables:
# Override to use nightly toolchain
RUSTY_CACHIER_TOOLCHAIN: "nightly"
CI_JOB_NAME: "cargo-check-benches"
extends:
- .docker-env
- .test-refs-check-benches
- .collect-artifacts
- .pipeline-stopper-artifacts
before_script:
# perform rusty-cachier operations before any further modifications to the git repo to make cargo feel cheated not so much
- !reference [.rust-info-script, script]
- !reference [.rusty-cachier, before_script]
- !reference [.pipeline-stopper-vars, script]
# merges in the master branch on PRs
- |
export BASE=$(curl -s -H "Authorization: Bearer ${GITHUB_PR_TOKEN}" https://api.github.com/repos/paritytech/substrate/pulls/${$CI_COMMIT_REF_NAME} | jq .base.ref)
- if [ $CI_COMMIT_REF_NAME != "master" ]; then
git fetch origin +${BASE}:${BASE};
git fetch origin +$CI_COMMIT_REF_NAME:$CI_COMMIT_REF_NAME;
git checkout ${BASE};
git config user.email "[email protected]";
git merge $CI_COMMIT_REF_NAME --verbose --no-edit;
fi
parallel: 2
script:
- rusty-cachier snapshot create
- mkdir -p ./artifacts/benches/$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA
# this job is executed in parallel on two runners
- echo "___Running benchmarks___";
- case ${CI_NODE_INDEX} in
1)
SKIP_WASM_BUILD=1 time cargo +nightly check --locked --benches --all;
cargo run --locked --release -p node-bench -- ::trie::read::small --json
| tee ./artifacts/benches/$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA/::trie::read::small.json;
echo "___Uploading cache for rusty-cachier___";
rusty-cachier cache upload
;;
2)
cargo run --locked --release -p node-bench -- ::node::import::native::sr25519::transfer_keep_alive::paritydb::small --json
| tee ./artifacts/benches/$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA/::node::import::native::sr25519::transfer_keep_alive::paritydb::small.json
;;
esac
tags:
- linux-docker-benches
node-bench-regression-guard:
# it's not belong to `build` semantically, but dag jobs can't depend on each other
# within the single stage - https://gitlab.com/gitlab-org/gitlab/-/issues/30632
# more: https://github.com/paritytech/substrate/pull/8519#discussion_r608012402
stage: build
extends:
- .docker-env
- .test-refs-no-trigger-prs-only
needs:
# this is a DAG
- job: cargo-check-benches
artifacts: true
# polls artifact from master to compare with current result
# need to specify both parallel jobs from master because of the bug
# https://gitlab.com/gitlab-org/gitlab/-/issues/39063
- project: $CI_PROJECT_PATH
job: "cargo-check-benches 1/2"
ref: master
artifacts: true
- project: $CI_PROJECT_PATH
job: "cargo-check-benches 2/2"
ref: master
artifacts: true
variables:
CI_IMAGE: "paritytech/node-bench-regression-guard:latest"
before_script: [""]
script:
- echo "------- IMPORTANT -------"
- echo "node-bench-regression-guard depends on the results of a cargo-check-benches job"
- echo "In case of this job failure, check your pipeline's cargo-check-benches"
- 'node-bench-regression-guard --reference artifacts/benches/master-*
--compare-with artifacts/benches/$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA'
after_script: [""]
cargo-check-subkey:
stage: test
extends:
- .docker-env
- .test-refs
- .pipeline-stopper-artifacts
script:
- rusty-cachier snapshot create
- cd ./bin/utils/subkey
- SKIP_WASM_BUILD=1 time cargo check --locked --release
- rusty-cachier cache upload
cargo-check-try-runtime:
stage: test
# this is an artificial job dependency, for pipeline optimization using GitLab's DAGs
needs:
- job: cargo-check-subkey
artifacts: false
extends:
- .docker-env
- .test-refs
script:
- rusty-cachier snapshot create
- time cargo check --locked --features try-runtime
- rusty-cachier cache upload
cargo-check-wasmer-sandbox:
stage: test
# this is an artificial job dependency, for pipeline optimization using GitLab's DAGs
needs:
- job: cargo-check-try-runtime
artifacts: false
extends:
- .docker-env
- .test-refs
script:
- rusty-cachier snapshot create
- time cargo check --locked --features wasmer-sandbox
- rusty-cachier cache upload
test-deterministic-wasm:
stage: test
# this is an artificial job dependency, for pipeline optimization using GitLab's DAGs
needs:
- job: cargo-check-wasmer-sandbox
artifacts: false
extends:
- .docker-env
- .test-refs
variables:
WASM_BUILD_NO_COLOR: 1
# this variable gets overriden by "rusty-cachier environment inject", use the value as default
CARGO_TARGET_DIR: "$CI_PROJECT_DIR/target"
script:
- rusty-cachier snapshot create
# build runtime
- cargo build --locked --verbose --release -p kitchensink-runtime
# make checksum
- sha256sum $CARGO_TARGET_DIR/release/wbuild/kitchensink-runtime/target/wasm32-unknown-unknown/release/kitchensink_runtime.wasm > checksum.sha256
# clean up
- rm -rf $CARGO_TARGET_DIR/release/wbuild
# build again
- cargo build --locked --verbose --release -p kitchensink-runtime
# confirm checksum
- sha256sum -c ./checksum.sha256
# clean up again, don't put release binaries into the cache
- rm -rf $CARGO_TARGET_DIR/release/wbuild
- rusty-cachier cache upload
test-linux-stable:
stage: test
extends:
- .docker-env
- .test-refs
- .pipeline-stopper-artifacts
variables:
# Enable debug assertions since we are running optimized builds for testing
# but still want to have debug assertions.
RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings"
RUST_BACKTRACE: 1
WASM_BUILD_NO_COLOR: 1
WASM_BUILD_RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings"
# Ensure we run the UI tests.
RUN_UI_TESTS: 1
# needed for rusty-cachier to keep cache in test-linux-stable folder and not in test-linux-stable-1/3
CI_JOB_NAME: "test-linux-stable"
parallel: 3
script:
- rusty-cachier snapshot create
# this job runs all tests in former runtime-benchmarks, frame-staking and wasmtime tests
# tests are partitioned by nextest and executed in parallel on $CI_NODE_TOTAL runners
# node-cli is excluded until https://github.com/paritytech/substrate/issues/11321 fixed
- echo "Node index - ${CI_NODE_INDEX}. Total amount - ${CI_NODE_TOTAL}"
- time cargo nextest run --workspace
--locked
--release
--verbose
--features runtime-benchmarks
--manifest-path ./bin/node/cli/Cargo.toml
--exclude node-cli
--partition count:${CI_NODE_INDEX}/${CI_NODE_TOTAL}
# we need to update cache only from one job
- if [ ${CI_NODE_INDEX} == 1 ]; then rusty-cachier cache upload; fi
test-frame-support:
stage: test
extends:
- .docker-env
- .test-refs
variables:
# Enable debug assertions since we are running optimized builds for testing
# but still want to have debug assertions.
RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings"
RUST_BACKTRACE: 1
WASM_BUILD_NO_COLOR: 1
WASM_BUILD_RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings"
# Ensure we run the UI tests.
RUN_UI_TESTS: 1
script:
- rusty-cachier snapshot create
- time cargo test --locked -p frame-support-test --features=frame-feature-testing,no-metadata-docs --manifest-path ./frame/support/test/Cargo.toml --test pallet # does not reuse cache 1 min 44 sec
- time cargo test --locked -p frame-support-test --features=frame-feature-testing,frame-feature-testing-2,no-metadata-docs --manifest-path ./frame/support/test/Cargo.toml --test pallet # does not reuse cache 1 min 44 sec
- SUBSTRATE_TEST_TIMEOUT=1 time cargo test -p substrate-test-utils --release --verbose --locked -- --ignored timeout
- rusty-cachier cache upload
# This job runs tests that don't work with cargo-nextest in test-linux-stable
test-linux-stable-extra:
stage: test
extends:
- .docker-env
- .test-refs
variables:
# Enable debug assertions since we are running optimized builds for testing
# but still want to have debug assertions.
RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings"
RUST_BACKTRACE: 1
WASM_BUILD_NO_COLOR: 1
WASM_BUILD_RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings"
# Ensure we run the UI tests.
RUN_UI_TESTS: 1
script:
- rusty-cachier snapshot create
# Run node-cli tests
# TODO: add to test-linux-stable-nextest after fix https://github.com/paritytech/substrate/issues/11321
- time cargo test node-cli --workspace --locked --release --verbose --features runtime-benchmarks --manifest-path ./bin/node/cli/Cargo.toml
# Run doctests
# TODO: add to test-linux-stable-nextest after fix https://github.com/nextest-rs/nextest/issues/16
- time cargo test --doc --workspace --locked --release --verbose --features runtime-benchmarks --manifest-path ./bin/node/cli/Cargo.toml
- rusty-cachier cache upload
# This job runs all benchmarks defined in the `/bin/node/runtime` once to check that there are no errors.
quick-benchmarks:
stage: test
extends:
- .docker-env
- .test-refs
variables:
# Enable debug assertions since we are running optimized builds for testing
# but still want to have debug assertions.
RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings"
RUST_BACKTRACE: "full"
WASM_BUILD_NO_COLOR: 1
WASM_BUILD_RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings"
script:
- rusty-cachier snapshot create
- time cargo run --locked --release --features runtime-benchmarks -- benchmark pallet --execution wasm --wasm-execution compiled --chain dev --pallet "*" --extrinsic "*" --steps 2 --repeat 1
- rusty-cachier cache upload
test-frame-examples-compile-to-wasm:
# into one job
stage: test
variables:
RUSTY_CACHIER_TOOLCHAIN: nightly
extends:
- .docker-env
- .test-refs
variables:
# Enable debug assertions since we are running optimized builds for testing
# but still want to have debug assertions.
RUSTFLAGS: "-Cdebug-assertions=y"
RUST_BACKTRACE: 1
script:
- rusty-cachier snapshot create
- cd ./frame/examples/offchain-worker/
- cargo +nightly build --locked --target=wasm32-unknown-unknown --no-default-features
- cd ../basic
- cargo +nightly build --locked --target=wasm32-unknown-unknown --no-default-features
- rusty-cachier cache upload
test-linux-stable-int:
stage: test
extends:
- .docker-env
- .test-refs
- .pipeline-stopper-artifacts
variables:
# Enable debug assertions since we are running optimized builds for testing
# but still want to have debug assertions.
RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings"
RUST_BACKTRACE: 1
WASM_BUILD_NO_COLOR: 1
WASM_BUILD_RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings"
# Ensure we run the UI tests.
RUN_UI_TESTS: 1
script:
- rusty-cachier snapshot create
- WASM_BUILD_NO_COLOR=1
RUST_LOG=sync=trace,consensus=trace,client=trace,state-db=trace,db=trace,forks=trace,state_db=trace,storage_cache=trace
time cargo test -p node-cli --release --verbose --locked -- --ignored
- rusty-cachier cache upload
# more information about this job can be found here:
# https://github.com/paritytech/substrate/pull/6916
check-tracing:
stage: test
# this is an artificial job dependency, for pipeline optimization using GitLab's DAGs
needs:
- job: test-linux-stable-int
artifacts: false
variables:
RUSTY_CACHIER_TOOLCHAIN: nightly
extends:
- .docker-env
- .test-refs
- .pipeline-stopper-artifacts
script:
- rusty-cachier snapshot create
# with-tracing must be explicitly activated, we run a test to ensure this works as expected in both cases
- time cargo +nightly test --locked --manifest-path ./primitives/tracing/Cargo.toml --no-default-features
- time cargo +nightly test --locked --manifest-path ./primitives/tracing/Cargo.toml --no-default-features --features=with-tracing
- rusty-cachier cache upload
# more information about this job can be found here:
# https://github.com/paritytech/substrate/pull/3778
test-full-crypto-feature:
stage: test
# this is an artificial job dependency, for pipeline optimization using GitLab's DAGs
needs:
- job: check-tracing
artifacts: false
variables:
RUSTY_CACHIER_TOOLCHAIN: nightly
extends:
- .docker-env
- .test-refs
variables:
# Enable debug assertions since we are running optimized builds for testing
# but still want to have debug assertions.
RUSTFLAGS: "-Cdebug-assertions=y"
RUST_BACKTRACE: 1
script:
- rusty-cachier snapshot create
- cd primitives/core/
- time cargo +nightly build --locked --verbose --no-default-features --features full_crypto
- cd ../application-crypto
- time cargo +nightly build --locked --verbose --no-default-features --features full_crypto
- rusty-cachier cache upload
test-wasmer-sandbox:
stage: test
extends:
- .docker-env
- .test-refs-wasmer-sandbox
variables:
RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings"
RUST_BACKTRACE: 1
WASM_BUILD_NO_COLOR: 1
WASM_BUILD_RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings"
CI_JOB_NAME: "test-wasmer-sandbox"
parallel: 3
script:
- rusty-cachier snapshot create
- echo "Node index - ${CI_NODE_INDEX}. Total amount - ${CI_NODE_TOTAL}"
- time cargo nextest run --locked --release --features runtime-benchmarks,wasmer-sandbox,disable-ui-tests --partition count:${CI_NODE_INDEX}/${CI_NODE_TOTAL}
- if [ ${CI_NODE_INDEX} == 1 ]; then rusty-cachier cache upload; fi
cargo-check-macos:
stage: test
extends: .test-refs-no-trigger
before_script:
- !reference [.rust-info-script, script]
variables:
SKIP_WASM_BUILD: 1
script:
- time cargo check --locked --release
tags:
- osx
check-rustdoc:
stage: test
variables:
RUSTY_CACHIER_TOOLCHAIN: nightly
extends:
- .docker-env
- .test-refs
variables:
SKIP_WASM_BUILD: 1
RUSTDOCFLAGS: "-Dwarnings"
script:
- rusty-cachier snapshot create
- time cargo +nightly doc --locked --workspace --all-features --verbose --no-deps
- rusty-cachier cache upload