-
Notifications
You must be signed in to change notification settings - Fork 308
/
.gitlab-ci.yml
222 lines (203 loc) · 6.99 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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
include:
- local: .gitlab/.gitlab-ci-base-docker-build.yml
- local: backend/.gitlab-ci.yml
- local: epf/.gitlab-ci.yml
- local: images/experiment/.gitlab-ci.yml
- local: nautilus/.gitlab-ci.yml
- local: web/.gitlab-ci.yml
stages:
- build
- deploy
- post-deploy # Till https://gitlab.com/gitlab-org/gitlab/-/issues/30632 gets resolved
- test
- staging
- maintenance
variables:
S3_DATA_BUCKET: "mlreef-application-data" # see also ec2 startup script
DATA_ARCHIVE: "mlreef-data-master.zip"
.except-docu-branches: &except-docu-branches
except:
variables:
# $CI_COMMIT_REF_NAME is the complete branch name e.g. "feature/my-cool-new-branch"
- $CI_COMMIT_REF_NAME =~ /^doc\// # match every branch "doc/**"
- $CI_COMMIT_REF_NAME =~ /^docs\// # match every branch "docs/**"
- $CI_COMMIT_REF_NAME =~ /^docu\// # match every branch "docu/**"
- $CI_COMMIT_REF_NAME =~ /^documentation\// # match every branch "documentation/**"
- $CI_COMMIT_REF_NAME =~ /^site\// # match every branch "site/**"
.only-on-code-changes: &run-on-all-code-changes
only:
changes:
- backend/**/*
- bin/ci-deploy
- bin/install
- bin/resources/runner-config*
- epf/**/*
- images/**/*
- k8s/**/*
- web/**/*
- .gitlab-ci.yml
- docker-compose.yml
.pages-code-changes: &run-on-pages-relevant-changes
only:
changes:
- backend/**/*
- docs/**/*
- README.md
deploy_review:
stage: deploy
<<: *run-on-all-code-changes
<<: *except-docu-branches
image:
name: registry.gitlab.com/mlreef/devops/k8s-images/k8s-kubectl:latest
entrypoint: ["/bin/bash", "-c"]
environment:
name: review/$CI_BUILD_REF_NAME
url: https://$CI_ENVIRONMENT_SLUG.$KUBE_INGRESS_BASE_DOMAIN
on_stop: stop_review
auto_stop_in: 2 weeks
script:
- bin/k8s-review-deploy
artifacts:
paths:
- out/instance.info # pass instance url to later stages (see k8s/includes/ci-environment)
post-deploy:
stage: post-deploy
<<: *run-on-all-code-changes
<<: *except-docu-branches
image: docker:19.03.12
services:
- name: docker:19.03.12-dind
entrypoint: ["sh", "-c", "dockerd-entrypoint.sh $DOCKER_DAEMON_OPTIONS"]
variables:
DOCKER_HOST: "tcp://docker:2375"
DOCKER_TLS_CERTDIR: ""
DOCKER_DAEMON_OPTIONS: "--insecure-registry=0.0.0.0/0"
script:
- echo $DOCKER_DAEMON_OPTIONS
- k8s/gitlab-post-deployment
stop_review:
stage: maintenance
<<: *except-docu-branches
image:
name: registry.gitlab.com/mlreef/devops/k8s-images/k8s-kubectl:latest
entrypoint: ["/bin/bash", "-c"]
variables:
GIT_STRATEGY: none
when: manual
only:
- branches
except:
refs:
- master
environment:
name: review/$CI_BUILD_REF_NAME
action: stop
script:
- kubectl version
- kubectl delete ing -l ref=${CI_ENVIRONMENT_SLUG}
- kubectl delete all -l ref=${CI_ENVIRONMENT_SLUG}
- kubectl delete pvc -l ref=${CI_ENVIRONMENT_SLUG}
# remove the branch's docker containers
# 1633112 is the id of nautilus' repository id
- curl --request DELETE --header "PRIVATE-TOKEN:$GITLAB_COM_API_TOKEN"
https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/registry/repositories/1633112/tags/$CI_COMMIT_REF_SLUG
# 1117031 is the id of the "gateway's" sub-repository id
- curl --request DELETE --header "PRIVATE-TOKEN:$GITLAB_COM_API_TOKEN"
https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/registry/repositories/1117031/tags/$CI_COMMIT_REF_SLUG
# 1151242 is the id of the "backend's" sub-repository id
- curl --request DELETE --header "PRIVATE-TOKEN:$GITLAB_COM_API_TOKEN"
https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/registry/repositories/1151242/tags/$CI_COMMIT_REF_SLUG
# 1196730 is the id of the "epf's" sub-repository id
- curl --request DELETE --header "PRIVATE-TOKEN:$GITLAB_COM_API_TOKEN"
https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/registry/repositories/1196730/tags/$CI_COMMIT_REF_SLUG
clean rest docs folder:
stage: maintenance
<<: *run-on-pages-relevant-changes
<<: *except-docu-branches
image: registry.gitlab.com/systemkern/s5:1
allow_failure: true
cache:
key: pages-public-cache
paths:
- public/
- /usr/local/lib/node_modules
- docs/node_modules
# See bin/ci-pages for the exact path to where rest docs are deployed
script: |
chmod +x docs/bin/ci-pages-cleanup
docs/bin/ci-pages-cleanup
# please do not move, adapt, delete, move to a include, whatever, if you did not read about the special "pages" job of gitlab ci
pages:
image: node:14.16.1-alpine # https://hub.docker.com/_/node/
stage: deploy
<<: *run-on-pages-relevant-changes
cache:
key: pages-public-cache
paths:
- public/
- /usr/local/lib/node_modules
- docs/node_modules
script: docs/bin/ci-pages
allow_failure: true
artifacts:
paths:
- public
test rest docs are present:
stage: test
<<: *run-on-pages-relevant-changes
<<: *except-docu-branches
image: registry.gitlab.com/systemkern/s5:1
allow_failure: true
# See bin/ci-pages for the exact path to where rest docs are deployed
script: |
echo "Testing if backend rest-docs are available at https://mlreef.gitlab.io/mlreef/rest-api/$CI_COMMIT_BRANCH/index.html"
echo "https://mlreef.gitlab.io/mlreef/rest-api/$CI_COMMIT_BRANCH/index.html"
curl --fail --GET "https://mlreef.gitlab.io/mlreef/rest-api/$CI_COMMIT_BRANCH/index.html" > rest-docs-test.html
ls -al
# look for the specific error output of Spring Rest Docs
#cat rest-docs-test.html | grep -e "not found for operation::" > missing.html
#if [ -e missing.html ]; then
# cat missing.html
# echo "MLReef rest-docs is missing some snippets :( "
# exit 1
#fi
#if [ -s missing.html ]; then
# echo "Yay, MLReef rest-docs is not missing snippets :) "
#fi
smoke tests:
stage: test
<<: *run-on-all-code-changes
<<: *except-docu-branches
when: delayed
start_in: 5 minutes
image: registry.gitlab.com/systemkern/s5:latest-git
script: bin/ci-smoke-tests
.system-tests:
<<: *run-on-all-code-changes
<<: *except-docu-branches
stage: test
image: java:8
services:
- docker:19.03.0-dind
cache:
key: "$CI_COMMIT_BRANCH"
paths:
- .gradle/wrapper
- .gradle/caches
variables:
DOCKER_HOST: "tcp://docker:2375" # gitlab needs this to support docker testcontainers
DOCKER_DRIVER: overlay2 # gitlab needs this to support docker testcontainers
DOCKER_TLS_CERTDIR: "" # "/certs" gitlab needs this to support docker testcontainers
system tests:
extends: [".system-tests"]
allow_failure: false
stage: test
when: delayed
start_in: 3 minutes
script: backend/bin/ci-system-tests
pipeline tests:
extends: [".system-tests"]
allow_failure: true
stage: test
when: manual
script: backend/bin/ci-pipeline-tests