-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.gitlab-ci.yml
267 lines (247 loc) · 8.26 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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
image: docker:19.03.5-dind
stages:
- test
- build
- integration-test
- push-commit
- push-branch # To avoid duplicating the upload do it sequentially
- push-extras
variables:
DOCKER_IMAGE_FRONTEND: programaker-core-frontend
DOCKER_IMAGE_BACKEND: programaker-core-backend
DOCKER_IMAGE_BACKEND_OPTIMIZED: programaker-core-backend-optimized
services:
- docker:19.03.5-dind
## Frontend
test-frontend-logic:
stage: test
before_script:
- cd frontend
script:
- docker build --target builder --build-arg BUILD_COMMAND=test-logic -f scripts/ci-partial.dockerfile .
test-frontend-on-browser:
stage: test
before_script:
- cd frontend
script:
- docker build -t browser-test -f scripts/browser-test-ci-partial.dockerfile .
- docker run -v `pwd`:/app --rm -e BROWSER_BIN="chromium-browser" -e BROWSER_OPTS="--no-sandbox" browser-test sh -- /app/scripts/run-browser-tests.sh
build-prod-frontend:
stage: build
before_script:
- mkdir -p tmp_docker_images/ || true
- cd frontend
needs: []
artifacts:
paths:
- tmp_docker_images/
expire_in: 24h # No need to keep it around
script:
- docker build -t $DOCKER_IMAGE_FRONTEND -f scripts/ci-partial.dockerfile .
- docker save $DOCKER_IMAGE_FRONTEND -o ../tmp_docker_images/frontend.tar
push-frontend:
stage: push-commit
needs:
- build-prod-frontend
- test-frontend-logic
- test-frontend-on-browser
dependencies:
- build-prod-frontend
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker load -i tmp_docker_images/frontend.tar
- cd frontend
script:
- docker tag $DOCKER_IMAGE_FRONTEND "$CI_REGISTRY"/"$CI_PROJECT_PATH"/frontend:$CI_COMMIT_SHA
- docker push "$CI_REGISTRY"/"$CI_PROJECT_PATH"/frontend:$CI_COMMIT_SHA
only:
- develop
- master
tag-frontend-branch:
stage: push-branch
needs:
- build-prod-frontend
- test-frontend-logic
- test-frontend-on-browser
dependencies:
- build-prod-frontend
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker load -i tmp_docker_images/frontend.tar
- cd frontend
script:
- docker tag $DOCKER_IMAGE_FRONTEND "$CI_REGISTRY"/"$CI_PROJECT_PATH"/frontend:$CI_COMMIT_REF_NAME
- docker push "$CI_REGISTRY"/"$CI_PROJECT_PATH"/frontend:$CI_COMMIT_REF_NAME
only:
- develop
- master
## SSR Frontend
build-tag-push-ssr-frontend:
stage: push-extras
dependencies:
- test-ssr-frontend
- test-frontend-logic
- test-frontend-on-browser
needs: []
script:
# Build
- docker build --build-arg BUILD_COMMAND=build:ssr -t $DOCKER_IMAGE_FRONTEND -f scripts/ci-partial-ssr.dockerfile .
# Push as commit
- docker tag $DOCKER_IMAGE_FRONTEND "$CI_REGISTRY"/"$CI_PROJECT_PATH"/frontend-ssr:$CI_COMMIT_SHA
- docker push "$CI_REGISTRY"/"$CI_PROJECT_PATH"/frontend-ssr:$CI_COMMIT_SHA
# Push as branch
- docker tag $DOCKER_IMAGE_FRONTEND "$CI_REGISTRY"/"$CI_PROJECT_PATH"/frontend-ssr:$CI_COMMIT_REF_NAME
- docker push "$CI_REGISTRY"/"$CI_PROJECT_PATH"/frontend-ssr:$CI_COMMIT_REF_NAME
only:
- develop
- master
when: manual
## Programaker Frontend
build-programaker-frontend:
stage: build
before_script:
- mkdir -p tmp_docker_images/ || true
- cd frontend
needs: []
artifacts:
paths:
- tmp_docker_images/
expire_in: 24h # No need to keep it around
script:
- docker build --build-arg BUILD_COMMAND=build:programaker-ssr -t $DOCKER_IMAGE_FRONTEND -f scripts/ci-partial-ssr.dockerfile .
- docker save $DOCKER_IMAGE_FRONTEND -o ../tmp_docker_images/programaker-frontend.tar
test-ssr-frontend:
stage: integration-test
dependencies:
- build-programaker-frontend
- build-backend
needs:
- build-programaker-frontend
- build-backend
before_script:
- docker load -i tmp_docker_images/programaker-frontend.tar
- docker load -i tmp_docker_images_optimized/backend-optimized.tar
script:
- cd utils/integration-tests/ssr-auth-handling
- sh install-deps.alpine.sh
- CI_TYPE=gitlab bash test-ssr-auth-handling.sh "$DOCKER_IMAGE_BACKEND_OPTIMIZED" "$DOCKER_IMAGE_FRONTEND"
push-programaker-frontend:
stage: push-commit
dependencies:
- build-programaker-frontend
needs:
- build-programaker-frontend
- test-frontend-logic
- test-frontend-on-browser
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker load -i tmp_docker_images/programaker-frontend.tar
- cd frontend
script:
- docker tag $DOCKER_IMAGE_FRONTEND "$CI_REGISTRY"/"$CI_PROJECT_PATH"/programaker-frontend:$CI_COMMIT_SHA
- docker push "$CI_REGISTRY"/"$CI_PROJECT_PATH"/programaker-frontend:$CI_COMMIT_SHA
only:
- develop
- master
tag-programaker-frontend-branch:
stage: push-branch
dependencies:
- build-programaker-frontend
needs:
- build-programaker-frontend
- test-frontend-logic
- test-frontend-on-browser
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker load -i tmp_docker_images/programaker-frontend.tar
- cd frontend
script:
- docker tag $DOCKER_IMAGE_FRONTEND "$CI_REGISTRY"/"$CI_PROJECT_PATH"/programaker-frontend:$CI_COMMIT_REF_NAME
- docker push "$CI_REGISTRY"/"$CI_PROJECT_PATH"/programaker-frontend:$CI_COMMIT_REF_NAME
only:
- develop
- master
## Backend
test-backend:
stage: test
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- cd backend
script:
- docker build -t $DOCKER_IMAGE_BACKEND -f scripts/ci-partial.dockerfile .
- docker run -t --rm $DOCKER_IMAGE_BACKEND rebar3 eunit
dialyze-backend:
stage: test
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- cd backend
script:
- docker build -t $DOCKER_IMAGE_BACKEND -f scripts/ci-partial.dockerfile .
- docker run -t --rm $DOCKER_IMAGE_BACKEND rebar3 dialyzer
build-backend:
stage: build
needs: []
artifacts:
paths:
- tmp_docker_images_optimized/
expire_in: 24h # No need to keep it around
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- mkdir -p tmp_docker_images_optimized/ || true
- cd backend
script:
- docker build -t $DOCKER_IMAGE_BACKEND -f scripts/ci-partial.dockerfile .
- sh ../utils/ci-preparations/optimize-backend-image.sh $DOCKER_IMAGE_BACKEND $DOCKER_IMAGE_BACKEND_OPTIMIZED
# Run sanity check
- docker run -t --rm $DOCKER_IMAGE_BACKEND_OPTIMIZED /app/release/bin/automate escript ../scripts/sanity_check.erl
- docker save $DOCKER_IMAGE_BACKEND_OPTIMIZED -o ../tmp_docker_images_optimized/backend-optimized.tar
api-test-backend:
stage: integration-test
dependencies:
- build-backend
needs:
- build-backend
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker load -i tmp_docker_images_optimized/backend-optimized.tar
script:
- apk add --no-cache curl py3-pip graphviz-dev gcc musl-dev
- CI_TYPE=gitlab sh utils/testing/run-api-test.sh $DOCKER_IMAGE_BACKEND_OPTIMIZED
push-backend:
stage: push-commit
dependencies:
- build-backend
needs:
- build-backend
- api-test-backend
- test-backend
- dialyze-backend
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker load -i tmp_docker_images_optimized/backend-optimized.tar
- cd backend
script:
- docker tag $DOCKER_IMAGE_BACKEND_OPTIMIZED "$CI_REGISTRY"/"$CI_PROJECT_PATH"/backend:$CI_COMMIT_SHA
- docker push "$CI_REGISTRY"/"$CI_PROJECT_PATH"/backend:$CI_COMMIT_SHA
only:
- develop
- master
tag-backend-branch:
stage: push-branch
dependencies:
- build-backend
needs:
- build-backend
- api-test-backend
- test-backend
- dialyze-backend
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker load -i tmp_docker_images_optimized/backend-optimized.tar
- cd backend
script:
- docker tag $DOCKER_IMAGE_BACKEND_OPTIMIZED "$CI_REGISTRY"/"$CI_PROJECT_PATH"/backend:$CI_COMMIT_REF_NAME
- docker push "$CI_REGISTRY"/"$CI_PROJECT_PATH"/backend:$CI_COMMIT_REF_NAME
only:
- develop
- master