This repository has been archived by the owner on Jul 6, 2022. It is now read-only.
forked from paritytech/ss58-registry
-
Notifications
You must be signed in to change notification settings - Fork 5
/
.gitlab-ci.yml
176 lines (156 loc) · 5.49 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
stages:
- lint
- test
- build
- tag
- publish
variables: &default-vars
GIT_STRATEGY: fetch
GIT_DEPTH: 100
CARGO_INCREMENTAL: 0
CARGO_TARGET_DIR: "/ci-cache/${CI_PROJECT_NAME}/targets/${CI_COMMIT_REF_NAME}/${CI_JOB_NAME}"
CI_IMAGE: "paritytech/ci-linux:production"
CARGO_UNLEASH_INSTALL_PARAMS: "--version 1.0.0-alpha.12"
CARGO_UNLEASH_PKG_DEF: ""
VAULT_SERVER_URL: "https://vault.parity-mgmt-vault.parity.io"
VAULT_AUTH_PATH: "gitlab-parity-io-jwt"
VAULT_AUTH_ROLE: "cicd_gitlab_parity_${CI_PROJECT_NAME}"
.publish-refs: &publish-refs
rules:
- if: $CI_PIPELINE_SOURCE == "web"
- if: $CI_PIPELINE_SOURCE == "schedule"
- if: $CI_COMMIT_REF_NAME == "master"
- if: $CI_COMMIT_REF_NAME == "main"
- if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1
#### Vault secrets
.vault-secrets: &vault-secrets
secrets:
CRATES_TOKEN:
vault: cicd/gitlab/$CI_PROJECT_PATH/CRATES_TOKEN@kv
file: false
GITHUB_TOKEN:
vault: cicd/gitlab/$CI_PROJECT_PATH/GITHUB_TOKEN@kv
file: false
GITHUB_USER:
vault: cicd/gitlab/$CI_PROJECT_PATH/GITHUB_USER@kv
file: false
.rust-info-script: &rust-info-script
- rustup show
- cargo --version
- rustup +nightly show
- cargo +nightly --version
- bash --version
- sccache -s
.docker-env: &docker-env
image: "${CI_IMAGE}"
before_script:
- *rust-info-script
- ./scripts/ci/pre_cache.sh
- sccache -s
retry:
max: 2
when:
- runner_system_failure
- unknown_failure
- api_failure
interruptible: true
tags:
- linux-docker
.kubernetes-env: &kubernetes-env
image: "${CI_IMAGE}"
retry:
max: 2
when:
- runner_system_failure
- unknown_failure
- api_failure
interruptible: true
tags:
- kubernetes-parity-build
.collect-artifacts: &collect-artifacts
artifacts:
name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}"
when: on_success
expire_in: 28 days
paths:
- ./artifacts/
#### stage: lint
fmt:
stage: lint
<<: *kubernetes-env
script:
- cargo +nightly fmt --all -- --check
clippy:
stage: lint
<<: *docker-env
script:
- cargo +nightly clippy --all --verbose
#### stage: test
deny:
stage: test
<<: *docker-env
<<: *collect-artifacts
script:
- cargo deny check --hide-inclusion-graph -c .maintain/deny.toml
after_script:
- mkdir -p ./artifacts
- echo "___Complete logs can be found in the artifacts___"
- cargo deny check --hide-inclusion-graph 2> cargo_deny.log
test:
stage: test
<<: *docker-env
script:
- cargo test --all --verbose
#### stage: build
build:
stage: build
<<: *docker-env
script:
- cargo build --no-default-features --target wasm32-unknown-unknown --verbose
#### stage: tag
# this stage will only create a tag in the repo, not release
tag-job:
stage: tag
<<: *kubernetes-env
<<: *vault-secrets
<<: *publish-refs
script:
- export CURRENT_TAG=$(git describe --tags --abbrev=0)
- export PKG_VER=v$(cat Cargo.toml | grep -A 5 package] | grep version | cut -d '=' -f 2 | tr -d '"' | tr -d " ")
- echo "Current tag $CURRENT_TAG"
- echo "Package version $PKG_VER"
- git config user.name "${GITHUB_USER}"
- git config user.email "[email protected]"
- git config remote.origin.url "https://${GITHUB_TOKEN}@github.com/paritytech/${CI_PROJECT_NAME}.git"
- git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
- if [ $CURRENT_TAG == $PKG_VER ];
then
echo "Tag is up to date. Nothing to do.";
export TAG=old;
else
echo "Tag was updated.";
git tag -a $PKG_VER -m "new tag";
git log --tags --simplify-by-decoration --pretty="format:%ci %d";
git push origin --tags;
export TAG=new;
fi
- echo "TAG=$TAG" > tag.env;
artifacts:
reports:
dotenv: tag.env
#### stage: publish
unleash-to-crates-io:
stage: publish
<<: *docker-env
<<: *vault-secrets
<<: *publish-refs
script:
- echo $TAG
- if [ $TAG == "new" ];
then
echo "Publishing to crates.io";
cargo install cargo-unleash ${CARGO_UNLEASH_INSTALL_PARAMS};
cargo unleash em-dragons --no-check --owner github:paritytech:core-devs ${CARGO_UNLEASH_PKG_DEF};
else
echo "Tag was not updated. Not releasing.";
fi