forked from paritytech/parity-bridges-common
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
293 lines (262 loc) · 11.4 KB
/
.gitlab-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
stages:
- lint
- check
- test
- build
- publish
workflow:
rules:
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH
variables: &default-vars
GIT_STRATEGY: fetch
GIT_DEPTH: 100
CARGO_INCREMENTAL: 0
ARCH: "x86_64"
CI_IMAGE: "paritytech/bridges-ci:production"
RUST_BACKTRACE: full
default:
cache: {}
.collect-artifacts: &collect-artifacts
artifacts:
name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}"
when: on_success
expire_in: 7 days
paths:
- artifacts/
.kubernetes-build: &kubernetes-build
tags:
- kubernetes-parity-build
interruptible: true
.docker-env: &docker-env
image: "${CI_IMAGE}"
before_script:
- rustup show
- cargo --version
- rustup +nightly show
- cargo +nightly --version
- sccache -s
retry:
max: 2
when:
- runner_system_failure
- unknown_failure
- api_failure
interruptible: true
tags:
- linux-docker
.test-refs: &test-refs
rules:
# FIXME: This is the cause why pipelines wouldn't start. The problem might be in our custom
# mirroring. This should be investigated further, but for now let's have the working
# pipeline.
# - if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH
# changes:
# - '**.md'
# - diagrams/*
# - docs/*
# when: never
- if: $CI_PIPELINE_SOURCE == "pipeline"
- if: $CI_PIPELINE_SOURCE == "web"
- if: $CI_PIPELINE_SOURCE == "schedule"
- if: $CI_COMMIT_REF_NAME == "master"
- if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs
- if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1
.build-refs: &build-refs
rules:
# won't run on the CI image update pipeline
- if: $CI_PIPELINE_SOURCE == "pipeline"
when: never
- if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1
- if: $CI_COMMIT_REF_NAME =~ /^v[0-9]{4}-[0-9]{2}-[0-9]{2}.*$/ # i.e. v2021-09-27, v2021-09-27-1
# there are two types of nightly pipelines:
# 1. this one is triggered by the schedule with $PIPELINE == "nightly", it's for releasing.
# this job runs only on nightly pipeline with the mentioned variable, against `master` branch
- if: $CI_PIPELINE_SOURCE == "schedule" && $PIPELINE == "nightly"
.nightly-test: &nightly-test
rules:
# 2. another is triggered by scripts repo $CI_PIPELINE_SOURCE == "pipeline" it's for the CI image
# update, it also runs all the nightly checks.
- if: $CI_PIPELINE_SOURCE == "pipeline"
#### stage: lint
clippy-nightly:
stage: lint
<<: *docker-env
<<: *test-refs
variables:
RUSTFLAGS: "-D warnings"
script:
# clippy currently is raising `derive-partial-eq-without-eq` warning even if `Eq` is actually derived
- SKIP_WASM_BUILD=1 cargo +nightly clippy --all-targets -- -A clippy::redundant_closure -A clippy::derive-partial-eq-without-eq
fmt:
stage: lint
<<: *docker-env
<<: *test-refs
script:
- cargo +nightly fmt --all -- --check
spellcheck:
stage: lint
<<: *docker-env
<<: *test-refs
script:
- cargo spellcheck check --cfg=.config/spellcheck.toml --checkers hunspell -m 1
#### stage: check
check:
stage: check
<<: *docker-env
<<: *test-refs
script: &check-script
- SKIP_WASM_BUILD=1 time cargo check --locked --verbose --workspace
# Check Rialto benchmarks runtime
- SKIP_WASM_BUILD=1 time cargo check -p rialto-runtime --locked --features runtime-benchmarks --verbose
# Check Millau benchmarks runtime
- SKIP_WASM_BUILD=1 time cargo check -p millau-runtime --locked --features runtime-benchmarks --verbose
check-nightly:
stage: check
<<: *docker-env
<<: *nightly-test
script:
- rustup default nightly
- *check-script
#### stage: test
test:
stage: test
<<: *docker-env
<<: *test-refs
# variables:
# RUSTFLAGS: "-D warnings"
script: &test-script
- time cargo fetch
- time cargo fetch --manifest-path=`cargo metadata --format-version=1 | jq --compact-output --raw-output ".packages[] | select(.name == \"polkadot-test-runtime\").manifest_path"`
- time cargo fetch --manifest-path=`cargo metadata --format-version=1 | jq --compact-output --raw-output ".packages[] | select(.name == \"polkadot-runtime\").manifest_path"`
- time cargo fetch --manifest-path=`cargo metadata --format-version=1 | jq --compact-output --raw-output ".packages[] | select(.name == \"kusama-runtime\").manifest_path"`
- CARGO_NET_OFFLINE=true SKIP_POLKADOT_RUNTIME_WASM_BUILD=1 SKIP_KUSAMA_RUNTIME_WASM_BUILD=1 SKIP_POLKADOT_TEST_RUNTIME_WASM_BUILD=1 time cargo test --verbose --workspace
test-nightly:
stage: test
<<: *docker-env
<<: *nightly-test
script:
- rustup default nightly
- *test-script
deny:
stage: test
<<: *docker-env
<<: *nightly-test
<<: *collect-artifacts
script:
- cargo deny check advisories --hide-inclusion-graph
- cargo deny check bans sources --hide-inclusion-graph
after_script:
- mkdir -p ./artifacts
- echo "___Complete logs can be found in the artifacts___"
- cargo deny check advisories 2> advisories.log
- cargo deny check bans sources 2> bans_sources.log
# this job is allowed to fail, only licenses check is important
allow_failure: true
deny-licenses:
stage: test
<<: *docker-env
<<: *test-refs
<<: *collect-artifacts
script:
- cargo deny check licenses --hide-inclusion-graph
after_script:
- mkdir -p ./artifacts
- echo "___Complete logs can be found in the artifacts___"
- cargo deny check licenses 2> licenses.log
#### stage: build
build:
stage: build
<<: *docker-env
<<: *build-refs
<<: *collect-artifacts
# master
script: &build-script
- time cargo fetch
- time cargo fetch --manifest-path=`cargo metadata --format-version=1 | jq --compact-output --raw-output ".packages[] | select(.name == \"polkadot-test-runtime\").manifest_path"`
- time cargo fetch --manifest-path=`cargo metadata --format-version=1 | jq --compact-output --raw-output ".packages[] | select(.name == \"polkadot-runtime\").manifest_path"`
- time cargo fetch --manifest-path=`cargo metadata --format-version=1 | jq --compact-output --raw-output ".packages[] | select(.name == \"kusama-runtime\").manifest_path"`
- CARGO_NET_OFFLINE=true SKIP_POLKADOT_RUNTIME_WASM_BUILD=1 SKIP_KUSAMA_RUNTIME_WASM_BUILD=1 SKIP_POLKADOT_TEST_RUNTIME_WASM_BUILD=1 time cargo build --release --verbose --workspace
after_script:
# Prepare artifacts
- mkdir -p ./artifacts
- strip ./target/release/rialto-bridge-node
- mv -v ./target/release/rialto-bridge-node ./artifacts/
- strip ./target/release/rialto-parachain-collator
- mv -v ./target/release/rialto-parachain-collator ./artifacts/
- strip ./target/release/millau-bridge-node
- mv -v ./target/release/millau-bridge-node ./artifacts/
- strip ./target/release/substrate-relay
- mv -v ./target/release/substrate-relay ./artifacts/
- mv -v ./deployments/local-scripts/bridge-entrypoint.sh ./artifacts/
- mv -v ./ci.Dockerfile ./artifacts/
build-nightly:
stage: build
<<: *docker-env
<<: *collect-artifacts
<<: *nightly-test
script:
- rustup default nightly
- *build-script
#### stage: publish
.build-push-image: &build-push-image
<<: *kubernetes-build
image: quay.io/buildah/stable
<<: *build-refs
variables: &image-variables
GIT_STRATEGY: none
DOCKERFILE: ci.Dockerfile
IMAGE_NAME: docker.io/paritytech/$CI_JOB_NAME
needs:
- job: build
artifacts: true
before_script: &check-versions
- if [[ "${CI_COMMIT_TAG}" ]]; then
VERSION=${CI_COMMIT_TAG};
elif [[ "${CI_COMMIT_REF_NAME}" ]]; then
VERSION=$(echo ${CI_COMMIT_REF_NAME} | sed -r 's#/+#-#g');
fi
# When building from version tags (v1.0, v2.1rc1, ...) we'll use "production" to tag
# docker image. In all other cases, it'll be "latest".
- if [[ $CI_COMMIT_REF_NAME =~ ^v[0-9]+\.[0-9]+.*$ ]]; then
FLOATING_TAG="production";
else
FLOATING_TAG="latest";
fi
- echo "Effective tags = ${VERSION} sha-${CI_COMMIT_SHORT_SHA} ${FLOATING_TAG}"
script:
- test "${Docker_Hub_User_Parity}" -a "${Docker_Hub_Pass_Parity}" ||
( echo "no docker credentials provided"; exit 1 )
- cd ./artifacts
- buildah bud
--format=docker
--build-arg VCS_REF="${CI_COMMIT_SHORT_SHA}"
--build-arg BUILD_DATE="$(date +%d-%m-%Y)"
--build-arg PROJECT="${CI_JOB_NAME}"
--build-arg VERSION="${VERSION}"
--tag "${IMAGE_NAME}:${VERSION}"
--tag "${IMAGE_NAME}:sha-${CI_COMMIT_SHORT_SHA}"
--tag "${IMAGE_NAME}:${FLOATING_TAG}"
--file "${DOCKERFILE}" .
# The job will success only on the protected branch
- echo "${Docker_Hub_Pass_Parity}" |
buildah login --username "${Docker_Hub_User_Parity}" --password-stdin docker.io
- buildah info
- buildah push --format=v2s2 "${IMAGE_NAME}:${VERSION}"
- buildah push --format=v2s2 "${IMAGE_NAME}:sha-${CI_COMMIT_SHORT_SHA}"
- buildah push --format=v2s2 "${IMAGE_NAME}:${FLOATING_TAG}"
after_script:
- env REGISTRY_AUTH_FILE= buildah logout --all
rialto-bridge-node:
stage: publish
<<: *build-push-image
rialto-parachain-collator:
stage: publish
<<: *build-push-image
millau-bridge-node:
stage: publish
<<: *build-push-image
substrate-relay:
stage: publish
<<: *build-push-image
# FIXME: publish binaries