Newer
Older
default:
interruptible: true
retry:
max: 2
when:
- runner_system_failure
- unknown_failure
- api_failure
stages:
- lint
- test
- benchmark
- 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"
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}"
.vault-secrets: &vault-secrets
secrets:
GITHUB_SSH_PRIV_KEY:
vault: cicd/gitlab/parity/${CI_PROJECT_NAME}/GITHUB_SSH_PRIV_KEY@kv
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
file: false
GITHUB_USER:
vault: cicd/gitlab/parity/GITHUB_USER@kv
file: false
.common-refs: &common-refs
rules:
- if: $CI_PIPELINE_SOURCE == "web"
- if: $CI_COMMIT_REF_NAME == "main"
- if: $CI_COMMIT_REF_NAME == "master"
- if: $CI_PIPELINE_SOURCE == "schedule"
when: never
- if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs
# run nightly by schedule
.schedule-refs: &schedule-refs
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
.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
- sccache -s
tags:
- linux-docker
.kubernetes-env: &kubernetes-env
image: "${CI_IMAGE}"
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/
reports:
dotenv: runner.env
#### stage: lint
fmt:
stage: lint
<<: *docker-env
<<: *common-refs
script:
# FIXME: remove component add after https://github.com/paritytech/substrate/issues/10411 is fixed
- rustup component add rustfmt
- cargo fmt --all -- --check
clippy:
stage: lint
<<: *docker-env
<<: *common-refs
script:
# FIXME: remove component add after https://github.com/paritytech/substrate/issues/10411 is fixed
- rustup component add clippy
- cargo clippy --all-targets
check-rustdoc-links:
stage: lint
<<: *docker-env
<<: *common-refs
script:
- RUSTDOCFLAGS="--deny broken_intra_doc_links" cargo doc --workspace --no-deps --document-private-items
#### stage: test
check-code:
stage: test
<<: *docker-env
<<: *common-refs
script:
- cargo install cargo-hack
- cargo hack check --workspace --each-feature
test:
stage: test
<<: *docker-env
<<: *common-refs
script:
- cargo test
benchmarks:
stage: benchmark
<<: *docker-env
<<: *collect-artifacts
<<: *schedule-refs
script:
- cargo bench -p jsonrpsee-benchmarks -- --output-format bencher | tee output.txt
- mkdir artifacts
- cp output.txt artifacts/
- echo ${CI_RUNNER_DESCRIPTION}
- echo "RUNNER_NAME=${CI_RUNNER_DESCRIPTION}" > runner.env
tags:
- linux-docker-benches
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
publish-ghpages:
stage: publish
variables:
CI_IMAGE: "paritytech/tools:latest"
<<: *kubernetes-env
<<: *schedule-refs
<<: *vault-secrets
needs:
- job: benchmarks
artifacts: true
script:
- mv artifacts/output.txt /tmp/output.txt
# setup ssh
- eval $(ssh-agent)
- ssh-add - <<< ${GITHUB_SSH_PRIV_KEY}
- mkdir ~/.ssh && touch ~/.ssh/known_hosts
- ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
# Set git config
- rm -rf .git/config
- git config user.email "[email protected]"
- git config user.name "${GITHUB_USER}"
- git config remote.origin.url "[email protected]:/paritytech/${CI_PROJECT_NAME}.git"
- git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
- git fetch origin gh-pages
# Push result to github
- git checkout gh-pages
- mkdir bench/$(date +%d-%m-%Y) || echo "Directory exists"
- mv /tmp/output.txt bench/$(date +%d-%m-%Y)/
- git add --all
- git commit -m "Add output.txt with benchmark results for ${CI_COMMIT_REF_NAME}"
- git push origin gh-pages
allow_failure: true
publish-bench:
stage: publish
variables:
CI_IMAGE: "paritytech/tools:latest"
<<: *kubernetes-env
<<: *schedule-refs
needs:
- job: benchmarks
artifacts: true
script:
- echo $RUNNER_NAME
- .scripts/ci/push_bench_results.sh artifacts/output.txt