This repository has been archived by the owner on Oct 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy path.gitlab-ci.yml
195 lines (171 loc) · 6.24 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
variables:
KUBE_NAMESPACE: "processbot"
CI_REGISTRY: "paritytech"
BUILDAH_IMAGE: "quay.io/buildah/stable:v1.29"
BUILDAH_COMMAND: "buildah --storage-driver overlay2"
CI_IMAGE: "paritytech/ci-linux@sha256:0fe9d110a29ec77ac6fa6507e4af968ea6aced6f6b7ce4deb231696ffc19b715" # 1.70.0-bullseye 2023-06-20
GIT_STRATEGY: fetch
GIT_DEPTH: 3
CARGO_TARGET_DIR: "/ci-cache/${CI_PROJECT_NAME}/targets/${CI_COMMIT_REF_NAME}/${CI_JOB_NAME}"
GITLAB_URL: https://gitlab.parity.io
default:
image: $CI_IMAGE
interruptible: true
retry:
max: 2
when:
- runner_system_failure
- unknown_failure
- api_failure
tags:
- linux-docker-vm-c2
.test-refs: &test-refs
rules:
- if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs
.publish-refs: &publish-refs
rules:
- if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1
- if: $CI_COMMIT_REF_NAME =~ /^stg-v[0-9]+\.[0-9]+.*$/ # i.e. stg-v1.0, stg-v2.1rc1
- if: $CI_COMMIT_REF_NAME == "master"
.common-refs: &common-refs
rules:
- !reference [.test-refs, rules]
- !reference [.publish-refs, rules]
.production-refs: &production-refs
rules:
- if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1
- if: $CI_COMMIT_REF_NAME == "master"
when: manual
stages:
- check
- test
- build
- dockerize
- deploy
#### stage: check
check:
stage: check
<<: *test-refs
script:
- cargo +nightly fmt --all -- --check
- cargo check --all-targets --workspace
- cargo clippy --all-targets --workspace -- -Dwarnings
#### stage: test
integration-tests:
stage: test
<<: *test-refs
script:
- ./scripts/run_integration_tests.sh
tests:
stage: test
<<: *test-refs
script:
- cargo test --lib
#### stage: build
build:
stage: build
<<: *common-refs
script:
- cargo build --release
- mkdir -p ./artifacts/
- cp ${CARGO_TARGET_DIR}/release/parity-processbot ./artifacts/
- cp ./Dockerfile ./artifacts/
artifacts:
name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}"
when: on_success
expire_in: 1 hour
paths:
- ./artifacts/
#### stage: dockerize
# build only
docker-build:
stage: dockerize
image: $BUILDAH_IMAGE
<<: *test-refs
variables:
GIT_STRATEGY: none
DOCKER_IMAGE: "${CI_REGISTRY}/${KUBE_NAMESPACE}"
interruptible: true
script:
- cd ./artifacts
- $BUILDAH_COMMAND build
--format=docker
--tag "$DOCKER_IMAGE:$CI_COMMIT_REF_NAME" .
needs:
- job: build
artifacts: true
tags:
- kubernetes-parity-build
docker-build-push:
stage: dockerize
image: $BUILDAH_IMAGE
<<: *publish-refs
variables:
GIT_STRATEGY: none
DOCKER_IMAGE: "${CI_REGISTRY}/${KUBE_NAMESPACE}"
interruptible: true
script:
- cd ./artifacts
- $BUILDAH_COMMAND build
--format=docker
--tag "$DOCKER_IMAGE:$CI_COMMIT_REF_NAME" .
- echo "$Docker_Hub_Pass_Parity" |
buildah login --username "$Docker_Hub_User_Parity" --password-stdin docker.io
- $BUILDAH_COMMAND push --format=v2s2 "$DOCKER_IMAGE:$CI_COMMIT_REF_NAME"
needs:
- job: build
artifacts: true
tags:
- kubernetes-parity-build
publish-docker-image-description:
stage: dockerize
variables:
CI_IMAGE: paritytech/dockerhub-description
DOCKERHUB_REPOSITORY: ${CI_REGISTRY}/${KUBE_NAMESPACE}
DOCKER_USERNAME: $Docker_Hub_User_Parity
DOCKER_PASSWORD: $Docker_Hub_Pass_Parity
README_FILEPATH: $CI_PROJECT_DIR/Dockerfile.README.md
SHORT_DESCRIPTION: "parity-processbot is a GitHub App which drives the Companion Build System's merge process"
rules:
- if: $CI_COMMIT_REF_NAME == "master"
changes:
- Dockerfile.README.md
script:
- cd / && sh entrypoint.sh
tags:
- kubernetes-parity-build
#### stage: deploy
.deploy-k8s: &deploy-k8s
image: paritytech/kubetools:3.5.3
interruptible: true
# PROCESSBOT_KEY should be base64 encoded
script:
- helm upgrade processbot ./helm
--install
--namespace "${KUBE_NAMESPACE}"
--values "helm/values-${CI_ENVIRONMENT_NAME}.yaml"
--set "app.INSTALLATION_LOGIN=${INSTALLATION_LOGIN}"
--set "app.KUBE_NAMESPACE=${KUBE_NAMESPACE}"
--set "app.DOCKER_TAG=${CI_COMMIT_REF_NAME}"
--set "app.PROCESSBOT_KEY=${PROCESSBOT_KEY}"
--set "app.GITHUB_APP_ID=${GITHUB_APP_ID}"
--set "app.WEBHOOK_SECRET=${WEBHOOK_SECRET}"
--set "app.GITLAB_URL=${GITLAB_URL}"
--set "app.GITLAB_ACCESS_TOKEN=${GITLAB_ACCESS_TOKEN}"
--set "app.DEPENDENCY_UPDATE_CONFIGURATION=${DEPENDENCY_UPDATE_CONFIGURATION}"
deploy-staging:
stage: deploy
<<: *deploy-k8s
<<: *publish-refs
environment:
name: staging
tags:
- parity-processbot-stg
deploy-production:
stage: deploy
<<: *deploy-k8s
<<: *production-refs
environment:
name: parity-prod
tags:
- parity-processbot-prod