forked from paritytech/parity-processbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
128 lines (112 loc) · 3.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
variables:
KUBE_NAMESPACE: "processbot"
CI_REGISTRY: "paritytech"
GIT_STRATEGY: fetch
GIT_DEPTH: 3
CARGO_TARGET_DIR: "/ci-cache/${CI_PROJECT_NAME}/targets/${CI_COMMIT_REF_NAME}/${CI_JOB_NAME}"
GITHUB_ORGANIZATION: "paritytech"
default:
image: paritytech/ci-linux:production
retry:
max: 2
when:
- runner_system_failure
- unknown_failure
- api_failure
tags:
- linux-docker
stages:
- check
- test
- build
- dockerize
- deploy
#### stage: check
check:
stage: check
script:
- cargo fmt --all -- --check
- cargo check --all-targets --workspace
- cargo clippy --all-targets --workspace -- -Dwarnings
#### stage: test
integration-tests:
stage: test
script:
- ./scripts/run_integration_tests.sh
tests:
stage: test
script:
- cargo test --lib
#### stage: build
build:
stage: build
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_and_push: &build_and_push
image: quay.io/buildah/stable
variables:
GIT_STRATEGY: none
DOCKER_IMAGE: "${CI_REGISTRY}/${KUBE_NAMESPACE}"
interruptible: true
script:
- cd ./artifacts
- buildah bud
--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 push --format=v2s2 "$DOCKER_IMAGE:$CI_COMMIT_REF_NAME"
tags:
- kubernetes-parity-build
dockerize-processbot:
stage: dockerize
<<: *build_and_push
needs:
- job: build
artifacts: true
only:
- tags
#### 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=${GITHUB_ORGANIZATION}"
--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}"
deploy-staging:
stage: deploy
<<: *deploy-k8s
environment:
name: staging
tags:
- kubernetes-parity-build
only:
- /^pre-v[0-9]+\.[0-9]+.*$/
deploy-production:
stage: deploy
<<: *deploy-k8s
environment:
name: parity-prod
tags:
- kubernetes-parity-build
only:
- /^v[0-9]+\.[0-9]+.*$/