This repository has been archived by the owner on Feb 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
.gitlab-ci.yml
171 lines (152 loc) · 5.61 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
# .gitlab-ci.yml
#
# cachepot
stages:
- check
- test
- build
- publish
variables:
GIT_STRATEGY: fetch
GIT_DEPTH: 100
CARGO_INCREMENTAL: 0
RUST_BACKTRACE: 1
# this var is changed to "-:staging" when the CI image gets rebuilt
# read more https://github.com/paritytech/scripts/pull/244
CI_IMAGE: "paritytech/cachepot-ci:staging" # temporary override
workflow:
rules:
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH
.docker-env: &docker-env
image: "${CI_IMAGE}"
before_script:
- which gcc && gcc --version
- which clang && clang --version
- rustc +stable --version
- rustc +nightly --version
- sccache -s
retry:
max: 2
when:
- runner_system_failure
- unknown_failure
- api_failure
interruptible: true
tags:
- linux-docker
.kubernetes-env: &kubernetes-env
tags:
- kubernetes-parity-build
interruptible: true
.build-refs: &build-refs
rules:
- if: $CI_PIPELINE_SOURCE == "web"
- if: $CI_PIPELINE_SOURCE == "schedule"
- if: $CI_COMMIT_REF_NAME == "master"
- if: $CI_COMMIT_REF_NAME == "tags"
- if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs
- if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1
.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 == "tags"
- if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1
.collect-artifacts: &collect-artifacts
artifacts:
name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}"
when: on_success
expire_in: 7 days
paths:
- artifacts/
#### stage: check
fmt:
<<: *docker-env
stage: check
script:
- cargo fmt -- --check
allow_failure: true
clippy:
<<: *docker-env
stage: check
script:
- cargo clippy --all-targets
allow_failure: true
#### stage: test
nightly-test:
<<: *docker-env
stage: test
variables:
FEATURES: "unstable"
script:
- cargo +nightly build --verbose --features="${FEATURES}" || exit 1
- cargo +nightly test --workspace --verbose --features="${FEATURES}"
stable-test:
<<: *docker-env
stage: test
variables:
FEATURES: ""
script:
- cargo +stable build --verbose --features="${FEATURES}" || exit 1
- cargo +stable test --workspace --verbose --features="${FEATURES}"
stable-dist-test:
<<: *docker-env
stage: test
variables:
FEATURES: "dist-tests"
DIST_EXEC_STRATEGY: "spawn"
CACHEPOT_SANDBOX: "userns"
CACHEPOT_LOG: "cachepot=trace"
script:
- uname -a
# https://github.com/paritytech/ci_cd/issues/490#issuecomment-1171587793
- mkdir /tmp/dummy_proc && mount -t proc proc /tmp/dummy_proc
- cargo test --verbose --no-default-features --features="${FEATURES}" test_dist_ -- --test-threads 1
build:
<<: *docker-env
<<: *collect-artifacts
<<: *build-refs
stage: build
variables:
FEATURES: "openssl/vendored,dist-worker"
script:
- cargo +stable build --locked --release --verbose --bin cachepot-dist --target x86_64-unknown-linux-musl --features=${FEATURES}
# collect artifacts
- mkdir -p ./artifacts/cachepot/
- mv ./target/x86_64-unknown-linux-musl/release/cachepot-dist ./artifacts/cachepot/.
- mv ./systemd/Dockerfile.vendor.cachepot-dist ./artifacts/cachepot/.
.build-push-docker-image: &build-push-docker-image
<<: *kubernetes-env
image: quay.io/buildah/stable
variables: &docker-build-vars
GIT_STRATEGY: none
DOCKERFILE: Dockerfile.vendor.cachepot-dist
IMAGE_NAME: docker.io/paritytech/cachepot-dist
before_script:
- cd ./artifacts/cachepot/
- VERSION=${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}
script:
- test "$Docker_Hub_User_Parity" -a "$Docker_Hub_Pass_Parity" ||
( echo "no docker credentials provided"; exit 1 )
- buildah bud
--format=docker
--build-arg VCS_REF="${CI_COMMIT_SHA}"
--build-arg BUILD_DATE="$(date -u '+%Y-%m-%dT%H:%M:%SZ')"
--tag "$IMAGE_NAME:$VERSION"
--tag "$IMAGE_NAME:latest"
--file "$DOCKERFILE" .
- echo "$Docker_Hub_Pass_Parity" |
buildah login --username "$Docker_Hub_User_Parity" --password-stdin docker.io
- buildah info
- buildah push --format=v2s2 "$IMAGE_NAME:$VERSION"
after_script:
- buildah logout --all
publish-cachepot-dist:
stage: publish
<<: *publish-refs
<<: *build-push-docker-image
needs:
- job: build
artifacts: true