.gitlab-ci.yml 8.17 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
    - cargo test --verbose --all-features --no-fail-fast --release --workspace

codecov:
  stage:                           workspace
  <<:                              *docker-env
  needs:
    - check-std
  variables:
    # According to https://github.com/mozilla/grcov/blob/master/README.md
    # we have to use these variables.
    CARGO_INCREMENTAL:             0
    # If `-Zno-landing-pads` is enabled some some tests start to fail.
    RUSTFLAGS:                     "-Zprofile -Ccodegen-units=1 -Cinline-threshold=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.
  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
    - grcov ./target -s . -t coveralls+ --guess-directory-when-missing --llvm --branch --ignore-not-existing --ignore "/*"
        --token "$CODECOV_TOKEN" --commit-sha "$CI_COMMIT_SHA" --output-file ccov.json
    # 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.
    - bash <(curl -s https://codecov.io/bash) -t "$CODECOV_TOKEN" -X gcov -f ccov.json
Denis_P's avatar
Denis_P committed
132

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

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

fmt:
Denis_P's avatar
Denis_P committed
154
  stage:                           workspace
Hero Bird's avatar
Hero Bird committed
155
156
  <<:                              *docker-env
  script:
Hero Bird's avatar
Hero Bird committed
157
    - cargo fmt --verbose --all -- --check
Hero Bird's avatar
Hero Bird committed
158

Denis_P's avatar
Denis_P committed
159

Denis_P's avatar
Denis_P committed
160
#### stage:                        examples
Denis_P's avatar
Denis_P committed
161

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

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

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

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

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

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

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

#### stage:                        publish

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