.gitlab-ci.yml 6.57 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:                       "3"
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
Hero Bird's avatar
Hero Bird committed
38
    - mkdir -p ${CARGO_HOME}; touch ${CARGO_HOME}/config
Denis_P's avatar
Denis_P committed
39
    - mkdir -p ${CARGO_TARGET_DIR}
Denis_P's avatar
Denis_P committed
40
41
    # global RUSTFLAGS overrides the linker args so this way is better to pass the flags
    - printf '[build]\nrustflags = ["-C", "link-dead-code"]\n' | tee ${CARGO_HOME}/config
Denis_P's avatar
Denis_P committed
42
43
44
45
46
47
48
    - sccache -s
  only:
    - master
    - /^v[0-9]+\.[0-9]+.*$/        # i.e. v1.0, v2.1rc1
    - schedules
    - web
    - /^[0-9]+$/                   # PRs
Denis_P's avatar
Denis_P committed
49
50
  dependencies:                    []
  interruptible:                   true
51
52
  retry:
    max: 2
Denis_P's avatar
Denis_P committed
53
    when:
54
55
56
      - runner_system_failure
      - unknown_failure
      - api_failure
Denis_P's avatar
Denis_P committed
57
58
59
  tags:
    - linux-docker

Denis_P's avatar
Denis_P committed
60
61

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

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

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

Denis_P's avatar
Denis_P committed
79

Denis_P's avatar
Denis_P committed
80
81
#### stage:                        workspace

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

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

Denis_P's avatar
Denis_P committed
102
103
test:
  stage:                           workspace
Denis_P's avatar
Denis_P committed
104
  <<:                              *docker-env
Denis_P's avatar
Denis_P committed
105
  needs:
Denis_P's avatar
Denis_P committed
106
    - check-std
Denis_P's avatar
Denis_P committed
107
  script:
Hero Bird's avatar
Hero Bird committed
108
    - for crate in ${ALL_CRATES}; do
Hero Bird's avatar
Hero Bird committed
109
        cargo test --verbose --all-features --release --manifest-path ${crate}/Cargo.toml;
Hero Bird's avatar
Hero Bird committed
110
      done
Denis_P's avatar
Denis_P committed
111

Hero Bird's avatar
Hero Bird committed
112
clippy-std:
Denis_P's avatar
Denis_P committed
113
  stage:                           workspace
Denis_P's avatar
Denis_P committed
114
  <<:                              *docker-env
Denis_P's avatar
Denis_P committed
115
  needs:
Denis_P's avatar
Denis_P committed
116
    - check-std
Denis_P's avatar
Denis_P committed
117
  script:
Hero Bird's avatar
Hero Bird committed
118
    - for crate in ${ALL_CRATES}; do
Hero Bird's avatar
Hero Bird committed
119
        cargo clippy --verbose --all-features --manifest-path ${crate}/Cargo.toml -- -D warnings;
Hero Bird's avatar
Hero Bird committed
120
      done
Denis_P's avatar
Denis_P committed
121

Hero Bird's avatar
Hero Bird committed
122
clippy-wasm:
Denis_P's avatar
Denis_P committed
123
  stage:                           workspace
Denis_P's avatar
Denis_P committed
124
  <<:                              *docker-env
Denis_P's avatar
Denis_P committed
125
  needs:
Denis_P's avatar
Denis_P committed
126
    - check-wasm
Denis_P's avatar
Denis_P committed
127
  script:
128
    - for crate in ${ALL_CRATES}; do
Hero Bird's avatar
Hero Bird committed
129
        cargo clippy --verbose --no-default-features --manifest-path ${crate}/Cargo.toml --target wasm32-unknown-unknown -- -D warnings;
Hero Bird's avatar
Hero Bird committed
130
131
132
      done

fmt:
Denis_P's avatar
Denis_P committed
133
  stage:                           workspace
Hero Bird's avatar
Hero Bird committed
134
135
  <<:                              *docker-env
  script:
Hero Bird's avatar
Hero Bird committed
136
    - cargo fmt --verbose --all -- --check
Hero Bird's avatar
Hero Bird committed
137

Denis_P's avatar
Denis_P committed
138

Denis_P's avatar
Denis_P committed
139
#### stage:                        examples
Denis_P's avatar
Denis_P committed
140

Denis_P's avatar
Denis_P committed
141
142
143
144
145
.update-cargo-contract:            &update-cargo-contract
  # `cargo install` returns an error if there is nothing to update, so have to supress it here temporarily
  - cargo install --git https://github.com/paritytech/cargo-contract || echo $?
  - cargo contract -V

Hero Bird's avatar
Hero Bird committed
146
examples-test:
Denis_P's avatar
Denis_P committed
147
  stage:                           examples
Denis_P's avatar
Denis_P committed
148
149
  <<:                              *docker-env
  script:
150
    - for example in examples/*/; do
Denis_P's avatar
Denis_P committed
151
        cargo test --verbose --manifest-path ${example}/Cargo.toml;
Denis_P's avatar
Denis_P committed
152
153
      done

Hero Bird's avatar
Hero Bird committed
154
examples-fmt:
Denis_P's avatar
Denis_P committed
155
  stage:                           examples
Denis_P's avatar
Denis_P committed
156
157
  <<:                              *docker-env
  script:
158
    - for example in examples/*/; do
Hero Bird's avatar
Hero Bird committed
159
        cargo fmt --verbose --manifest-path ${example}/Cargo.toml -- --check;
Denis_P's avatar
Denis_P committed
160
161
      done

Hero Bird's avatar
Hero Bird committed
162
examples-clippy-std:
Denis_P's avatar
Denis_P committed
163
  stage:                           examples
Denis_P's avatar
Denis_P committed
164
165
  <<:                              *docker-env
  script:
166
    - for example in examples/*/; do
Hero Bird's avatar
Hero Bird committed
167
        cargo clippy --verbose --manifest-path ${example}/Cargo.toml -- -D warnings;
Hero Bird's avatar
Hero Bird committed
168
169
170
171
172
173
      done

examples-clippy-wasm:
  stage:                           examples
  <<:                              *docker-env
  script:
174
    - for example in examples/*/; do
Hero Bird's avatar
Hero Bird committed
175
        cargo clippy --verbose --manifest-path ${example}/Cargo.toml --no-default-features --target wasm32-unknown-unknown -- -D warnings;
Hero Bird's avatar
Hero Bird committed
176
177
178
179
180
181
      done

examples-contract-build:
  stage:                           examples
  <<:                              *docker-env
  script:
Denis_P's avatar
Denis_P committed
182
    - *update-cargo-contract
183
    - for example in examples/*/; do
Hero Bird's avatar
Hero Bird committed
184
185
186
187
188
        pushd $example &&
        cargo contract build &&
        popd;
      done

Denis_P's avatar
Denis_P committed
189
examples-generate-metadata:
Hero Bird's avatar
Hero Bird committed
190
191
192
  stage:                           examples
  <<:                              *docker-env
  script:
Denis_P's avatar
Denis_P committed
193
    - *update-cargo-contract
194
    - for example in examples/*/; do
Hero Bird's avatar
Hero Bird committed
195
        pushd $example &&
Denis_P's avatar
Denis_P committed
196
        cargo contract generate-metadata &&
Hero Bird's avatar
Hero Bird committed
197
        popd;
Denis_P's avatar
Denis_P committed
198
      done
Denis_P's avatar
Denis_P committed
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

#### stage:                        publish

publish-docs:
  stage:                           publish
  <<:                              *docker-env
  only:
    - master
    - schedules
    - tags
  script:
    # Set github
    - git config --global user.email "devops-team@parity.io"
    - git config --global user.name "${GITHUB_USER}"
    - git config remote.origin.url "https://${GITHUB_TOKEN}@github.com/paritytech/ink.git"
    # Generating Docs
    - cargo doc --no-deps --all
    - git checkout -b gh-pages || git checkout gh-pages
    # Symbolic link because these files live in cache
    - mkdir -p target/doc
    - ln -s "${CARGO_TARGET_DIR}"/doc/ target/doc/
    # Upload files
    - git add -f target/doc/
    - git commit -m "Update docs to ${CI_COMMIT_REF_NAME}"
    - git push origin gh-pages --force