.gitlab-ci.yml 7.55 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
Hero Bird's avatar
Hero Bird committed
38
    - mkdir -p ${CARGO_HOME}; touch ${CARGO_HOME}/config
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
41
42
43
44
45
46
47
48
49
    # 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
50
51
52
53
54
55
    - sccache -s
  only:
    - master
    - /^v[0-9]+\.[0-9]+.*$/        # i.e. v1.0, v2.1rc1
    - schedules
    - web
Denis_P's avatar
Denis_P committed
56
    - branches
Denis_P's avatar
Denis_P committed
57
58
  dependencies:                    []
  interruptible:                   true
59
60
  retry:
    max: 2
Denis_P's avatar
Denis_P committed
61
    when:
62
63
64
      - runner_system_failure
      - unknown_failure
      - api_failure
Denis_P's avatar
Denis_P committed
65
66
67
  tags:
    - linux-docker

Denis_P's avatar
Denis_P committed
68
69

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

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

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

Denis_P's avatar
Denis_P committed
87

Denis_P's avatar
Denis_P committed
88
89
#### stage:                        workspace

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

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

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

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

Hero Bird's avatar
Hero Bird committed
130
clippy-wasm:
Denis_P's avatar
Denis_P committed
131
  stage:                           workspace
Denis_P's avatar
Denis_P committed
132
  <<:                              *docker-env
Denis_P's avatar
Denis_P committed
133
  needs:
Denis_P's avatar
Denis_P committed
134
    - check-wasm
Denis_P's avatar
Denis_P committed
135
  script:
136
    - for crate in ${ALL_CRATES}; do
Denis_P's avatar
Denis_P committed
137
        cargo clippy --verbose --no-default-features --manifest-path ${crate}/Cargo.toml --target wasm32-unknown-unknown -- -D warnings;
Hero Bird's avatar
Hero Bird committed
138
139
140
      done

fmt:
Denis_P's avatar
Denis_P committed
141
  stage:                           workspace
Hero Bird's avatar
Hero Bird committed
142
143
  <<:                              *docker-env
  script:
Hero Bird's avatar
Hero Bird committed
144
    - cargo fmt --verbose --all -- --check
Hero Bird's avatar
Hero Bird committed
145

Denis_P's avatar
Denis_P committed
146

Denis_P's avatar
Denis_P committed
147
#### stage:                        examples
Denis_P's avatar
Denis_P committed
148

Denis_P's avatar
Denis_P committed
149
150
.update-cargo-contract:            &update-cargo-contract
  # `cargo install` returns an error if there is nothing to update, so have to supress it here temporarily
151
  - cargo install cargo-contract || echo $?
Denis_P's avatar
Denis_P committed
152
153
  - cargo contract -V

Hero Bird's avatar
Hero Bird committed
154
examples-test:
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
Denis_P's avatar
Denis_P committed
159
        cargo test --verbose --manifest-path ${example}/Cargo.toml;
Denis_P's avatar
Denis_P committed
160
161
      done

Hero Bird's avatar
Hero Bird committed
162
examples-fmt:
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 fmt --verbose --manifest-path ${example}/Cargo.toml -- --check;
Denis_P's avatar
Denis_P committed
168
169
      done

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

examples-clippy-wasm:
  stage:                           examples
  <<:                              *docker-env
  script:
182
    - for example in examples/*/; do
Denis_P's avatar
Denis_P committed
183
        cargo clippy --verbose --manifest-path ${example}/Cargo.toml --no-default-features --target wasm32-unknown-unknown -- -D warnings;
Hero Bird's avatar
Hero Bird committed
184
185
186
187
188
189
      done

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

Denis_P's avatar
Denis_P committed
197
examples-generate-metadata:
Hero Bird's avatar
Hero Bird committed
198
199
200
  stage:                           examples
  <<:                              *docker-env
  script:
Denis_P's avatar
Denis_P committed
201
    - *update-cargo-contract
202
    - for example in examples/*/; do
Hero Bird's avatar
Hero Bird committed
203
        pushd $example &&
Denis_P's avatar
Denis_P committed
204
        cargo contract generate-metadata &&
Hero Bird's avatar
Hero Bird committed
205
        popd;
Denis_P's avatar
Denis_P committed
206
      done
Denis_P's avatar
Denis_P committed
207
208
209
210
211
212

#### stage:                        publish

publish-docs:
  stage:                           publish
  <<:                              *docker-env
Denis_P's avatar
Denis_P committed
213
214
  variables:
    GIT_DEPTH:                     0
Denis_P's avatar
Denis_P committed
215
216
217
218
219
  only:
    - master
    - schedules
    - tags
  script:
Denis_P's avatar
Denis_P committed
220
221
    - rm -rf /tmp/*
    - unset CARGO_TARGET_DIR
Denis_P's avatar
Denis_P committed
222
223
224
225
    # 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
226
    - git config remote.origin.url "https://${GITHUB_TOKEN}@github.com/paritytech/ink.git"
Denis_P's avatar
Denis_P committed
227
228
    - git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
    - git fetch origin gh-pages
Denis_P's avatar
Denis_P committed
229
    # Generating Docs
Denis_P's avatar
Denis_P committed
230
    - time cargo doc --no-deps --all-features
231
        -p type-metadata -p ink_abi -p ink_abi_derive -p ink_core -p ink_core_derive
Denis_P's avatar
Denis_P committed
232
        -p ink_primitives -p ink_prelude -p ink_lang -p ink_lang_macro
Denis_P's avatar
Denis_P committed
233
234
235
    # saving README and docs
    - mv target/doc/ /tmp/
    - cp README.md /tmp/doc/
Denis_P's avatar
Denis_P committed
236
    - git checkout gh-pages
Denis_P's avatar
Denis_P committed
237
238
    - mv _config.yml /tmp/doc/
    # remove everything and restore generated docs, README and Jekyll config
Denis_P's avatar
Denis_P committed
239
    - rm -rf ./*
Denis_P's avatar
Denis_P committed
240
    - mv /tmp/doc/* .
Denis_P's avatar
Denis_P committed
241
    # Upload files
Denis_P's avatar
Denis_P committed
242
    - git add --all --force
Denis_P's avatar
Denis_P committed
243
    - git status
Denis_P's avatar
Denis_P committed
244
    - git commit -m "Updated docs for ${CI_COMMIT_REF_NAME} and pushed to gh-pages"
Denis_P's avatar
Denis_P committed
245
    - git push origin gh-pages --force
Denis_P's avatar
Denis_P committed
246
247
  after_script:
    - rm -rf .git/ ./*