.gitlab-ci.yml 8.42 KB
Newer Older
Denis_P's avatar
Denis_P committed
1
2
3
4
5
6
7
8
# .gitlab-ci.yml
#
# ink
#
# pipelines can be triggered manually in the web


stages:
Denis_P's avatar
Denis_P committed
9
10
  - check
  - workspace
Denis_P's avatar
Denis_P committed
11
  - examples
Denis_P's avatar
Denis_P committed
12
  - publish
Denis_P's avatar
Denis_P committed
13
14
15

variables:
  GIT_STRATEGY:                    fetch
Denis_P's avatar
Denis_P committed
16
  GIT_DEPTH:                       100
Denis_P's avatar
Denis_P committed
17
  CARGO_TARGET_DIR:                "/ci-cache/${CI_PROJECT_NAME}/targets/${CI_COMMIT_REF_NAME}/${CI_JOB_NAME}"
Denis_P's avatar
Denis_P committed
18
  CI_SERVER_NAME:                  "GitLab CI"
Denis_P's avatar
Denis_P committed
19
  REGISTRY:                        registry.parity.io/parity/infrastructure/scripts
20
  ALL_CRATES:                      "core alloc prelude primitives lang lang/macro"
Denis_P's avatar
Denis_P committed
21
22
23
24
25
26
27
28
29
30

.collect-artifacts:                &collect-artifacts
  artifacts:
    name:                          "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}"
    when:                          on_success
    expire_in:                     7 days
    paths:
      - artifacts/

.docker-env:                       &docker-env
Denis_P's avatar
Denis_P committed
31
  image:                           ${REGISTRY}/ink-ci-linux:latest
Denis_P's avatar
Denis_P committed
32
  before_script:
Denis_P's avatar
Denis_P committed
33
34
    - cargo -vV
    - rustc -vV
Denis_P's avatar
Denis_P committed
35
    - rustup show
Denis_P's avatar
Denis_P committed
36
    - bash --version
Denis_P's avatar
Denis_P committed
37
    - ./scripts/pre_cache.sh
Denis_P's avatar
Denis_P committed
38
39
40
41
42
43
    - sccache -s
  only:
    - master
    - /^v[0-9]+\.[0-9]+.*$/        # i.e. v1.0, v2.1rc1
    - schedules
    - web
Denis_P's avatar
Denis_P committed
44
    - branches
Denis_P's avatar
Denis_P committed
45
46
  dependencies:                    []
  interruptible:                   true
47
48
  retry:
    max: 2
Denis_P's avatar
Denis_P committed
49
    when:
50
51
52
      - runner_system_failure
      - unknown_failure
      - api_failure
Denis_P's avatar
Denis_P committed
53
54
55
  tags:
    - linux-docker

Denis_P's avatar
Denis_P committed
56
57

#### stage:                        check
Denis_P's avatar
Denis_P committed
58

Hero Bird's avatar
Hero Bird committed
59
check-std:
Denis_P's avatar
Denis_P committed
60
  stage:                           check
Denis_P's avatar
Denis_P committed
61
62
  <<:                              *docker-env
  script:
Hero Bird's avatar
Hero Bird committed
63
    - for crate in ${ALL_CRATES}; do
Hero Bird's avatar
Hero Bird committed
64
        cargo check --verbose --all-features --manifest-path ${crate}/Cargo.toml;
Hero Bird's avatar
Hero Bird committed
65
      done
Denis_P's avatar
Denis_P committed
66

Hero Bird's avatar
Hero Bird committed
67
check-wasm:
Denis_P's avatar
Denis_P committed
68
  stage:                           check
Denis_P's avatar
Denis_P committed
69
70
  <<:                              *docker-env
  script:
71
    - for crate in ${ALL_CRATES}; do
Hero Bird's avatar
Hero Bird committed
72
73
        cargo check --verbose --no-default-features --target wasm32-unknown-unknown --manifest-path ${crate}/Cargo.toml;
      done
Denis_P's avatar
Denis_P committed
74

Denis_P's avatar
Denis_P committed
75

Denis_P's avatar
Denis_P committed
76
77
#### stage:                        workspace

Hero Bird's avatar
Hero Bird committed
78
build-std:
Denis_P's avatar
Denis_P committed
79
  stage:                           workspace
Denis_P's avatar
Denis_P committed
80
  <<:                              *docker-env
Denis_P's avatar
Denis_P committed
81
  needs:
Denis_P's avatar
Denis_P committed
82
    - check-std
Denis_P's avatar
Denis_P committed
83
  script:
Hero Bird's avatar
Hero Bird committed
84
    - for crate in ${ALL_CRATES}; do
Hero Bird's avatar
Hero Bird committed
85
        cargo build --verbose --all-features --release --manifest-path ${crate}/Cargo.toml;
Hero Bird's avatar
Hero Bird committed
86
      done
Denis_P's avatar
Denis_P committed
87

Hero Bird's avatar
Hero Bird committed
88
build-wasm:
Denis_P's avatar
Denis_P committed
89
  stage:                           workspace
Denis_P's avatar
Denis_P committed
90
  <<:                              *docker-env
Denis_P's avatar
Denis_P committed
91
  needs:
Denis_P's avatar
Denis_P committed
92
    - check-wasm
Denis_P's avatar
Denis_P committed
93
  script:
94
    - for crate in ${ALL_CRATES}; do
Hero Bird's avatar
Hero Bird committed
95
96
        cargo build --verbose --no-default-features --release --target wasm32-unknown-unknown --manifest-path ${crate}/Cargo.toml;
      done
Denis_P's avatar
Denis_P committed
97

Denis_P's avatar
Denis_P committed
98
99
test:
  stage:                           workspace
Denis_P's avatar
Denis_P committed
100
  <<:                              *docker-env
Denis_P's avatar
Denis_P committed
101
  needs:
Denis_P's avatar
Denis_P committed
102
    - check-std
Denis_P's avatar
Denis_P committed
103
  script:
104
105
106
107
108
109
110
111
    - cargo test --verbose --all-features --no-fail-fast --release --workspace

codecov:
  stage:                           workspace
  <<:                              *docker-env
  needs:
    - check-std
  variables:
Denis_P's avatar
Denis_P committed
112
    # Variables partly came from https://github.com/mozilla/grcov/blob/master/README.md
113
    CARGO_INCREMENTAL:             0
Denis_P's avatar
Denis_P committed
114
115
116
117
118
    RUSTFLAGS:                     "-Zprofile -Zmir-opt-level=0 -Zpanic_abort_tests -Ccodegen-units=1
                                      -Cinline-threshold=0 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off"
    # The `cargo-taurpalin` coverage reporting tool seems to have better code instrumentation and thus
    # produces better results for Rust codebases in general. However, unlike `grcov` it requires
    # running docker with `--security-opt seccomp=unconfined` which is why we use `grcov` instead.
119
120
121
122
123
124
  script:
    # RUSTFLAGS are the cause target cache can't be used here
    - unset "CARGO_TARGET_DIR"
    - cargo clean
    - cargo test --verbose --all-features --no-fail-fast --workspace
    - cargo build --verbose --all-features --workspace
Denis_P's avatar
Denis_P committed
125
126
127
    # coverage with branches
    - grcov ./target -s . -t lcov --llvm --branch --ignore-not-existing --ignore "/*" --ignore "tests/*" -o lcov-w-branch.info
    - rust-covfix -o lcov-w-branch.info lcov-w-branch.info
128
129
    # We'd like to not use a remote bash script for uploading the coverage reports,
    # however this job seems to be more tricky than we hoped.
Denis_P's avatar
Denis_P committed
130
131
132
133
134
    - bash <(curl -s https://codecov.io/bash) -t "$CODECOV_P_TOKEN" -f lcov-w-branch.info
    # lines coverage
    - grcov ./target -s . -t lcov --llvm --ignore-not-existing --ignore "/*" --ignore "tests/*" -o lcov-lines.info
    - rust-covfix -o lcov-lines.info lcov-lines.info
    - bash <(curl -s https://codecov.io/bash) -f lcov-lines.info
Denis_P's avatar
Denis_P committed
135

Hero Bird's avatar
Hero Bird committed
136
clippy-std:
Denis_P's avatar
Denis_P committed
137
  stage:                           workspace
Denis_P's avatar
Denis_P committed
138
  <<:                              *docker-env
Denis_P's avatar
Denis_P committed
139
  needs:
Denis_P's avatar
Denis_P committed
140
    - check-std
Denis_P's avatar
Denis_P committed
141
  script:
Hero Bird's avatar
Hero Bird committed
142
    - for crate in ${ALL_CRATES}; do
Denis_P's avatar
Denis_P committed
143
        cargo clippy --verbose --all-features --manifest-path ${crate}/Cargo.toml -- -D warnings;
Hero Bird's avatar
Hero Bird committed
144
      done
Denis_P's avatar
Denis_P committed
145

Hero Bird's avatar
Hero Bird committed
146
clippy-wasm:
Denis_P's avatar
Denis_P committed
147
  stage:                           workspace
Denis_P's avatar
Denis_P committed
148
  <<:                              *docker-env
Denis_P's avatar
Denis_P committed
149
  needs:
Denis_P's avatar
Denis_P committed
150
    - check-wasm
Denis_P's avatar
Denis_P committed
151
  script:
152
    - for crate in ${ALL_CRATES}; do
Denis_P's avatar
Denis_P committed
153
        cargo clippy --verbose --no-default-features --manifest-path ${crate}/Cargo.toml --target wasm32-unknown-unknown -- -D warnings;
Hero Bird's avatar
Hero Bird committed
154
155
156
      done

fmt:
Denis_P's avatar
Denis_P committed
157
  stage:                           workspace
Hero Bird's avatar
Hero Bird committed
158
159
  <<:                              *docker-env
  script:
Hero Bird's avatar
Hero Bird committed
160
    - cargo fmt --verbose --all -- --check
Hero Bird's avatar
Hero Bird committed
161

Denis_P's avatar
Denis_P committed
162

Denis_P's avatar
Denis_P committed
163
#### stage:                        examples
Denis_P's avatar
Denis_P committed
164

Denis_P's avatar
Denis_P committed
165
166
.update-cargo-contract:            &update-cargo-contract
  # `cargo install` returns an error if there is nothing to update, so have to supress it here temporarily
167
  - cargo install cargo-contract || echo $?
Denis_P's avatar
Denis_P committed
168
169
  - cargo contract -V

Hero Bird's avatar
Hero Bird committed
170
examples-test:
Denis_P's avatar
Denis_P committed
171
  stage:                           examples
Denis_P's avatar
Denis_P committed
172
  <<:                              *docker-env
Denis_P's avatar
Denis_P committed
173
174
  needs:
    - clippy-std
Denis_P's avatar
Denis_P committed
175
  script:
176
    - for example in examples/*/; do
Denis_P's avatar
Denis_P committed
177
        cargo test --verbose --manifest-path ${example}/Cargo.toml;
Denis_P's avatar
Denis_P committed
178
179
      done

Hero Bird's avatar
Hero Bird committed
180
examples-fmt:
Denis_P's avatar
Denis_P committed
181
  stage:                           examples
Denis_P's avatar
Denis_P committed
182
183
  <<:                              *docker-env
  script:
184
    - for example in examples/*/; do
Hero Bird's avatar
Hero Bird committed
185
        cargo fmt --verbose --manifest-path ${example}/Cargo.toml -- --check;
Denis_P's avatar
Denis_P committed
186
187
      done

Hero Bird's avatar
Hero Bird committed
188
examples-clippy-std:
Denis_P's avatar
Denis_P committed
189
  stage:                           examples
Denis_P's avatar
Denis_P committed
190
  <<:                              *docker-env
Denis_P's avatar
Denis_P committed
191
192
  needs:
    - clippy-std
Denis_P's avatar
Denis_P committed
193
  script:
194
    - for example in examples/*/; do
Denis_P's avatar
Denis_P committed
195
        cargo clippy --verbose --manifest-path ${example}/Cargo.toml -- -D warnings;
Hero Bird's avatar
Hero Bird committed
196
197
198
199
200
201
      done

examples-clippy-wasm:
  stage:                           examples
  <<:                              *docker-env
  script:
202
    - for example in examples/*/; do
Denis_P's avatar
Denis_P committed
203
        cargo clippy --verbose --manifest-path ${example}/Cargo.toml --no-default-features --target wasm32-unknown-unknown -- -D warnings;
Hero Bird's avatar
Hero Bird committed
204
205
206
207
208
209
      done

examples-contract-build:
  stage:                           examples
  <<:                              *docker-env
  script:
Denis_P's avatar
Denis_P committed
210
    - *update-cargo-contract
211
    - for example in examples/*/; do
Hero Bird's avatar
Hero Bird committed
212
213
214
215
216
        pushd $example &&
        cargo contract build &&
        popd;
      done

Denis_P's avatar
Denis_P committed
217
examples-generate-metadata:
Hero Bird's avatar
Hero Bird committed
218
219
  stage:                           examples
  <<:                              *docker-env
Denis_P's avatar
Denis_P committed
220
221
  needs:
    - build-wasm
Hero Bird's avatar
Hero Bird committed
222
  script:
Denis_P's avatar
Denis_P committed
223
    - *update-cargo-contract
224
    - for example in examples/*/; do
Hero Bird's avatar
Hero Bird committed
225
        pushd $example &&
Denis_P's avatar
Denis_P committed
226
        cargo contract generate-metadata &&
Hero Bird's avatar
Hero Bird committed
227
        popd;
Denis_P's avatar
Denis_P committed
228
      done
Denis_P's avatar
Denis_P committed
229
230
231
232
233
234

#### stage:                        publish

publish-docs:
  stage:                           publish
  <<:                              *docker-env
Denis_P's avatar
Denis_P committed
235
236
  variables:
    GIT_DEPTH:                     0
Denis_P's avatar
Denis_P committed
237
238
239
240
241
  only:
    - master
    - schedules
    - tags
  script:
Denis_P's avatar
Denis_P committed
242
243
    - rm -rf /tmp/*
    - unset CARGO_TARGET_DIR
Denis_P's avatar
Denis_P committed
244
245
246
247
    # Set git config
    - rm .git/config
    - git config user.email "devops-team@parity.io"
    - git config user.name "${GITHUB_USER}"
Denis_P's avatar
Denis_P committed
248
    - git config remote.origin.url "https://${GITHUB_TOKEN}@github.com/paritytech/ink.git"
Denis_P's avatar
Denis_P committed
249
250
    - git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
    - git fetch origin gh-pages
Denis_P's avatar
Denis_P committed
251
    # Generating Docs
Denis_P's avatar
Denis_P committed
252
    - time cargo doc --no-deps --all-features
253
        -p type-metadata -p ink_abi -p ink_abi_derive -p ink_core -p ink_core_derive
Denis_P's avatar
Denis_P committed
254
        -p ink_primitives -p ink_prelude -p ink_lang -p ink_lang_macro
Denis_P's avatar
Denis_P committed
255
256
257
    # saving README and docs
    - mv target/doc/ /tmp/
    - cp README.md /tmp/doc/
Denis_P's avatar
Denis_P committed
258
    - git checkout gh-pages
Denis_P's avatar
Denis_P committed
259
260
    - mv _config.yml /tmp/doc/
    # remove everything and restore generated docs, README and Jekyll config
Denis_P's avatar
Denis_P committed
261
    - rm -rf ./*
Denis_P's avatar
Denis_P committed
262
    - mv /tmp/doc/* .
Denis_P's avatar
Denis_P committed
263
    # Upload files
Denis_P's avatar
Denis_P committed
264
    - git add --all --force
Denis_P's avatar
Denis_P committed
265
    - git status
Denis_P's avatar
Denis_P committed
266
    - git commit -m "Updated docs for ${CI_COMMIT_REF_NAME} and pushed to gh-pages"
Denis_P's avatar
Denis_P committed
267
    - git push origin gh-pages --force
Denis_P's avatar
Denis_P committed
268
269
  after_script:
    - rm -rf .git/ ./*