forked from use-ink/cargo-contract
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
207 lines (179 loc) · 7 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
# .gitlab-ci.yml
#
# cargo-contract
#
# pipelines can be triggered manually in the web
stages:
- check
- test
- build
- notify
variables:
GIT_STRATEGY: fetch
GIT_DEPTH: "100"
RUST_LIB_BACKTRACE: "0"
# this var is changed to "-:staging" when the CI image gets rebuilt
# read more https://github.com/paritytech/cargo-contract/pull/115
CI_IMAGE: "paritytech/contracts-ci-linux:production"
RUSTY_CACHIER_SINGLE_BRANCH: master
RUSTY_CACHIER_DONT_OPERATE_ON_MAIN_BRANCH: "true"
workflow:
rules:
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH
.collect-artifacts: &collect-artifacts
artifacts:
name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}"
when: on_success
expire_in: 7 days
paths:
- artifacts/
.rusty-cachier:
before_script:
- curl -s https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.parity.io/parity/infrastructure/ci_cd/rusty-cachier/client/-/raw/release/util/install.sh | bash
- rusty-cachier environment check --gracefully
- $(rusty-cachier environment inject)
- rusty-cachier project mtime
after_script:
- rusty-cachier snapshot destroy
.docker-env: &docker-env
image:
name: "${CI_IMAGE}"
entrypoint: ['bash', '-c', 'exec unshare -m -r bash']
before_script:
- cargo -vV
- rustc -vV
- rustup show
- cargo dylint --version
- bash --version
# global RUSTFLAGS overrides the linker args so this way is better to pass the flags
- printf '[build]\nrustflags = ["-C", "link-dead-code"]\n' > ${CARGO_HOME}/config
- sccache -s
- git show
- !reference [.rusty-cachier, before_script]
after_script:
- !reference [.rusty-cachier, after_script]
rules:
- if: $CI_PIPELINE_SOURCE == "web"
- if: $CI_PIPELINE_SOURCE == "schedule"
- if: $CI_COMMIT_REF_NAME == "master"
- if: $CI_COMMIT_REF_NAME == "tags"
- if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs
- if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1
dependencies: []
interruptible: true
retry:
max: 2
when:
- runner_system_failure
- unknown_failure
- api_failure
tags:
- linux-docker
#### stage: check
# be aware that the used image has cargo-contract installed
fmt:
stage: check
<<: *docker-env
script:
- cargo fmt --verbose --all -- --check
clippy:
stage: check
<<: *docker-env
script:
- cargo clippy --verbose --all-targets --all-features -- -D warnings;
#### stage: test (all features)
test-dylint:
stage: test
<<: *docker-env
script:
- rusty-cachier snapshot create
- cd ink_linting/
- mv _Cargo.toml Cargo.toml
# Installing these components here is necessary because
# `ink_linting/` has a fixed `rust-toolchain` file.
# We can't move this line to the Docker container, since
# that would then make it impossible to upgrade the
# `ink_linting/rust-toolchain` file while still having
# this CI job succeed.
- rustup component add rustfmt clippy rust-src
- cargo check --verbose
- cargo fmt --verbose --all -- --check
- cargo clippy --verbose -- -D warnings;
# Needed until https://github.com/mozilla/sccache/issues/1000 is fixed.
- unset RUSTC_WRAPPER
- cargo test --verbose --all-features
- rusty-cachier cache upload
test:
stage: test
<<: *docker-env
script:
- rusty-cachier snapshot create
- cargo test --verbose --workspace --all-features
- rusty-cachier cache upload
test-new-project-template:
stage: test
<<: *docker-env
script:
- rusty-cachier snapshot create
- cargo run -- contract new new_project
# needed because otherwise:
# `error: current package believes it's in a workspace when it's not`
- echo "[workspace]" >> new_project/Cargo.toml
- cargo run --all-features -- contract build --manifest-path new_project/Cargo.toml
- cargo run --all-features -- contract check --manifest-path new_project/Cargo.toml
- cargo run --all-features -- contract test --manifest-path new_project/Cargo.toml
- cd new_project
- cargo check --verbose
- cargo test --verbose --all
- cargo fmt --verbose --all -- --check
- cargo clippy --verbose --manifest-path Cargo.toml -- -D warnings;
- rusty-cachier cache upload
# With the introduction of `ink_linting` in `build.rs` the installation process
# is more elaborate now and as part of it the `ink_linting` crate is built locally.
# We introduced this CI job to make sure that publishing to a registry and installing
# from it will work correctly.
test-registry-publish-install:
stage: test
<<: *docker-env
before_script:
- !reference [.rusty-cachier, before_script]
# Set up a local registry.
- mkdir -p ./estuary/crates/ ./estuary/indices/
- estuary --base-url=http://0.0.0.0:7878 --crate-dir ./estuary/crates/ --index-dir ./estuary/indices &
- mkdir .cargo
- echo -e '[registries]\nestuary = { index = "http://0.0.0.0:7878/git/index" }' > .cargo/config.toml
- echo 0000 | cargo login --registry estuary
script:
- rusty-cachier snapshot create
- cargo publish --registry estuary
- cargo install cargo-contract --index http://0.0.0.0:7878/git/index
# Simple smoke testing to check if basic `check` functionality works.
- cargo run -- contract new new_project
- echo "[workspace]" >> new_project/Cargo.toml
- cargo run --all-features -- contract check --manifest-path new_project/Cargo.toml
- rusty-cachier cache upload
#### stage: build (default features)
build:
stage: build
<<: *docker-env
<<: *collect-artifacts
rules:
- if: $CI_PIPELINE_SOURCE == "web"
- if: $CI_PIPELINE_SOURCE == "schedule"
- if: $CI_COMMIT_REF_NAME == "master"
- if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1
script:
- rusty-cachier snapshot create
- cargo build --verbose --release
- rusty-cachier cache upload
after_script:
- !reference [.rusty-cachier, after_script]
- mkdir -p ./artifacts/cargo-contract/
- cp ${CARGO_TARGET_DIR}/release/cargo-contract ./artifacts/cargo-contract/
#### stage: notify (rusty-cachier notification about the latest revision)
rusty-cachier-notify:
stage: notify
<<: *docker-env
script:
- rusty-cachier cache notify