.gitlab-ci.yml 8.7 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_HOME:                      "/ci-cache/${CI_PROJECT_NAME}/cargo/${CI_JOB_NAME}"
Denis_P's avatar
Denis_P committed
18
  CARGO_TARGET_DIR:                "/ci-cache/${CI_PROJECT_NAME}/targets/${CI_COMMIT_REF_NAME}/${CI_JOB_NAME}"
Denis_P's avatar
Denis_P committed
19
  CI_SERVER_NAME:                  "GitLab CI"
Denis_P's avatar
Denis_P committed
20
  REGISTRY:                        registry.parity.io/parity/infrastructure/scripts
21
  ALL_CRATES:                      "core alloc prelude primitives lang lang/macro"
Denis_P's avatar
Denis_P committed
22
23
24
25
26
27
28
29
30
31

.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
32
  image:                           ${REGISTRY}/ink-ci-linux:latest
Denis_P's avatar
Denis_P committed
33
  before_script:
Denis_P's avatar
Denis_P committed
34
35
    - cargo -vV
    - rustc -vV
Denis_P's avatar
Denis_P committed
36
    - rustup show
Denis_P's avatar
Denis_P committed
37
    - bash --version
38
39
40
41
42
43
44
45
46
    # if there is no directory for this $CI_COMMIT_REF_NAME/$CI_JOB_NAME
    # create such directory and
    # create hardlinks recursively of all the files from the master/$CI_JOB_NAME if it exists
    - if [[ ! -d $CARGO_TARGET_DIR ]]; then
        mkdir -p /ci-cache/${CI_PROJECT_NAME}/targets/${CI_COMMIT_REF_NAME};
        cp -al /ci-cache/${CI_PROJECT_NAME}/targets/${CI_DEFAULT_BRANCH}/${CI_JOB_NAME}
          /ci-cache/${CI_PROJECT_NAME}/targets/${CI_COMMIT_REF_NAME} ||
          echo "_____No such target dir, proceeding from scratch_____";
      fi
Denis_P's avatar
Denis_P committed
47
48
49
50
51
52
    - sccache -s
  only:
    - master
    - /^v[0-9]+\.[0-9]+.*$/        # i.e. v1.0, v2.1rc1
    - schedules
    - web
Denis_P's avatar
Denis_P committed
53
    - branches
Denis_P's avatar
Denis_P committed
54
55
  dependencies:                    []
  interruptible:                   true
56
57
  retry:
    max: 2
Denis_P's avatar
Denis_P committed
58
    when:
59
60
61
      - runner_system_failure
      - unknown_failure
      - api_failure
Denis_P's avatar
Denis_P committed
62
63
64
  tags:
    - linux-docker

Denis_P's avatar
Denis_P committed
65
66

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

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

Hero Bird's avatar
Hero Bird committed
76
check-wasm:
Denis_P's avatar
Denis_P committed
77
  stage:                           check
Denis_P's avatar
Denis_P committed
78
79
  <<:                              *docker-env
  script:
80
    - for crate in ${ALL_CRATES}; do
Hero Bird's avatar
Hero Bird committed
81
82
        cargo check --verbose --no-default-features --target wasm32-unknown-unknown --manifest-path ${crate}/Cargo.toml;
      done
Denis_P's avatar
Denis_P committed
83

Denis_P's avatar
Denis_P committed
84

Denis_P's avatar
Denis_P committed
85
86
#### stage:                        workspace

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

Hero Bird's avatar
Hero Bird committed
97
build-wasm:
Denis_P's avatar
Denis_P committed
98
  stage:                           workspace
Denis_P's avatar
Denis_P committed
99
  <<:                              *docker-env
Denis_P's avatar
Denis_P committed
100
  needs:
Denis_P's avatar
Denis_P committed
101
    - check-wasm
Denis_P's avatar
Denis_P committed
102
  script:
103
    - for crate in ${ALL_CRATES}; do
Hero Bird's avatar
Hero Bird committed
104
105
        cargo build --verbose --no-default-features --release --target wasm32-unknown-unknown --manifest-path ${crate}/Cargo.toml;
      done
Denis_P's avatar
Denis_P committed
106

Denis_P's avatar
Denis_P committed
107
108
test:
  stage:                           workspace
Denis_P's avatar
Denis_P committed
109
  <<:                              *docker-env
Denis_P's avatar
Denis_P committed
110
  needs:
Denis_P's avatar
Denis_P committed
111
    - check-std
Denis_P's avatar
Denis_P committed
112
  script:
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
    - 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
141

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

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

fmt:
Denis_P's avatar
Denis_P committed
163
  stage:                           workspace
Hero Bird's avatar
Hero Bird committed
164
165
  <<:                              *docker-env
  script:
Hero Bird's avatar
Hero Bird committed
166
    - cargo fmt --verbose --all -- --check
Hero Bird's avatar
Hero Bird committed
167

Denis_P's avatar
Denis_P committed
168

Denis_P's avatar
Denis_P committed
169
#### stage:                        examples
Denis_P's avatar
Denis_P committed
170

Denis_P's avatar
Denis_P committed
171
172
.update-cargo-contract:            &update-cargo-contract
  # `cargo install` returns an error if there is nothing to update, so have to supress it here temporarily
173
  - cargo install cargo-contract || echo $?
Denis_P's avatar
Denis_P committed
174
175
  - cargo contract -V

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

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

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

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

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

Denis_P's avatar
Denis_P committed
219
examples-generate-metadata:
Hero Bird's avatar
Hero Bird committed
220
221
222
  stage:                           examples
  <<:                              *docker-env
  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/ ./*