.gitlab-ci.yml 5.79 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
13
14

variables:
  GIT_STRATEGY:                    fetch
Denis_P's avatar
Denis_P committed
15
  GIT_DEPTH:                       "3"
Denis_P's avatar
Denis_P committed
16
  CARGO_HOME:                      "/ci-cache/${CI_PROJECT_NAME}/cargo/${CI_JOB_NAME}"
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 utils lang2 lang2/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
Hero Bird's avatar
Hero Bird committed
37
    - mkdir -p ${CARGO_HOME}; touch ${CARGO_HOME}/config
Denis_P's avatar
Denis_P committed
38
    - mkdir -p ${CARGO_TARGET_DIR}
Denis_P's avatar
Denis_P committed
39
40
    # 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
41
42
43
44
45
46
47
    - 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
48
49
  dependencies:                    []
  interruptible:                   true
50
51
  retry:
    max: 2
Denis_P's avatar
Denis_P committed
52
    when:
53
54
55
      - runner_system_failure
      - unknown_failure
      - api_failure
Denis_P's avatar
Denis_P committed
56
57
58
  tags:
    - linux-docker

Denis_P's avatar
Denis_P committed
59
60

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

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

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

Denis_P's avatar
Denis_P committed
78

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

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

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

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

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

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

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

Denis_P's avatar
Denis_P committed
137

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

Denis_P's avatar
Denis_P committed
140
141
142
143
144
.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
145
examples-test:
Denis_P's avatar
Denis_P committed
146
  stage:                           examples
Denis_P's avatar
Denis_P committed
147
148
  <<:                              *docker-env
  script:
Denis_P's avatar
Denis_P committed
149
150
    - for example in examples/lang2/*; do
        cargo test --verbose --manifest-path ${example}/Cargo.toml;
Denis_P's avatar
Denis_P committed
151
152
      done

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

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

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

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

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