-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
256 lines (238 loc) · 6.18 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
image: docker:stable
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_DRIVER: overlay2
POSTGRES_DB: reset
POSTGRES_USER: postgres
POSTGRES_PASSWORD: bleubleu
services:
- docker:dind
stages:
- build-frontend
- build-backend
- run-tests
- generate-reports-and-doc
check-frontend:
stage: .pre
needs: []
image: node:lts-alpine
script:
- npx prettier@2.0.5 . --check
check-backend:
stage: .pre
needs: []
image: python:3.7-slim
script:
- pip3 install black==19.10b0
- black --check .
compile-frontend:
stage: build-frontend
needs: ["check-frontend", "check-backend"]
image: node:lts-alpine
artifacts:
paths:
- ftl/frontend/dist
- ftl/frontend/webpack-stats.json
- ftl/frontend/node_modules
expire_in: 7 days
script:
- cd ftl/frontend
- npm ci
- npm run build
compile-backend:
stage: build-backend
needs: ["compile-frontend"]
image: registry.gitlab.com/exotic-matter/ftl-base-image-ci:latest
dependencies:
- compile-frontend
artifacts:
paths:
- ftl
- venv
expire_in: 7 days
script:
- export DJANGO_SETTINGS_MODULE=ftl.settings_tests
- virtualenv venv && source venv/bin/activate
- cd ftl && pip3 install -r requirements.txt && pip3 install -r requirements_dev.txt
- python3 -m compileall ./
- python3 manage.py compilemessages
- python3 manage.py collectstatic
test-frontend-js:
stage: run-tests
needs: ["compile-frontend"]
image: node:lts-alpine
dependencies:
- compile-frontend
artifacts:
paths:
- ftl/frontend/coverage
expire_in: 7 days
script:
- cd ftl/frontend
- npx vue-cli-service test:unit --coverage
test-fast-python:
stage: run-tests
needs: ["compile-backend"]
image: registry.gitlab.com/exotic-matter/ftl-base-image-ci:latest
services:
- postgres:11-alpine
dependencies:
- compile-backend
artifacts:
paths:
- ftl/.coverage.*
expire_in: 7 days
script:
- export DJANGO_SETTINGS_MODULE=ftl.settings_tests
- source venv/bin/activate && cd ftl
- python3 -m coverage run manage.py test -v 2 --exclude-tag=slow
test-slow-python-firefox:
stage: run-tests
needs: ["compile-frontend", "compile-backend"]
image: registry.gitlab.com/exotic-matter/ftl-base-image-ci:latest
services:
- postgres:11-alpine
dependencies:
- compile-backend
artifacts:
paths:
- ftl/.coverage.*
- ftl/ftests/tests_screenshots
expire_in: 7 days
script:
- export TEST_BROWSER=firefox
- export DJANGO_SETTINGS_MODULE=ftl.settings_tests
- source venv/bin/activate && cd ftl
- python3 -m coverage run manage.py test -v 2 --tag=slow
allow_failure: false
when: manual
test-slow-python-chrome:
stage: run-tests
needs: ["compile-frontend", "compile-backend"]
image: registry.gitlab.com/exotic-matter/ftl-base-image-ci:latest
services:
- postgres:11-alpine
dependencies:
- compile-backend
artifacts:
paths:
- ftl/.coverage.*
- ftl/ftests/tests_screenshots
- ftl/ftests/browser_logs
expire_in: 7 days
script:
- export TEST_BROWSER=chrome
- export DJANGO_SETTINGS_MODULE=ftl.settings_tests
- source venv/bin/activate && cd ftl
- python3 -m coverage run manage.py test -v 2 --tag=slow
allow_failure: false
when: manual
check-browser-logs:
stage: generate-reports-and-doc
needs: ["test-slow-python-chrome"]
image: registry.gitlab.com/exotic-matter/ftl-base-image-ci:latest
services:
- postgres:11-alpine
dependencies:
- test-slow-python-chrome
script:
- cd ftl/ftests/tools
- python3 check_browser_logs.py
allow_failure: false
python-coverage:
stage: generate-reports-and-doc
needs: ["compile-backend", "test-fast-python", "test-slow-python-firefox", "test-slow-python-chrome"]
image: registry.gitlab.com/exotic-matter/ftl-base-image-ci:latest
services:
- postgres:11-alpine
dependencies:
- compile-backend
- test-fast-python
- test-slow-python-firefox
- test-slow-python-chrome
artifacts:
name: "python_coverage_report"
paths:
- ftl/htmlcov
- ftl/coverage.svg
expire_in: 7 days
script:
- source venv/bin/activate && cd ftl
- python3 -m coverage combine
- python3 -m coverage html
- python3 -m coverage_badge -o coverage.svg
allow_failure: true
only:
- master
javascript-coverage:
stage: generate-reports-and-doc
needs: ["compile-frontend", "test-frontend-js"]
image: node:lts-alpine
dependencies:
- compile-frontend
- test-frontend-js
artifacts:
paths:
- ftl/frontend/coverage/lcov-report
- ftl/frontend/coverage/badge.svg
expire_in: 7 days
script:
- cd ftl/frontend
- npx make-coverage-badge
allow_failure: true
only:
- master
build-doc:
stage: generate-reports-and-doc
needs: []
image: python:3.7-slim
artifacts:
paths:
- site
expire_in: 7 days
script:
- pip3 install mkdocs
- python3 -m mkdocs build
allow_failure: true
only:
- master
pages: # Magic job name that publish public folder to Gitlab Pages
stage: .post
needs: ["python-coverage", "javascript-coverage", "build-doc"]
dependencies:
- python-coverage
- javascript-coverage
- build-doc
artifacts:
paths:
- public # Required to trigger Gitlab pages:deploy job
script:
- mkdir public
- mv ftl/htmlcov public/python-coverage
- mv ftl/coverage.svg public/python-coverage.svg
- mv ftl/frontend/coverage/lcov-report public/javascript-coverage
- mv ftl/frontend/coverage/badge.svg public/javascript-coverage.svg
- mv site public/doc
allow_failure: true
only:
- master
build-docker-gitlab:
stage: .post
needs: []
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME .
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
when: manual
build-docker-hub:
stage: .post
needs: []
script:
- docker login -u $DOCKER_REGISTRY_LOGIN -p $DOCKER_REGISTRY_PASSWORD
- docker build -t $DOCKER_REGISTRY_IMAGE:$CI_COMMIT_TAG .
- docker push $DOCKER_REGISTRY_IMAGE:$CI_COMMIT_TAG
when: manual
only:
- tags
except:
- branches