-
Notifications
You must be signed in to change notification settings - Fork 12
/
config.yml
344 lines (333 loc) · 10.5 KB
/
config.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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
---
version: 2.1
orbs:
browser-tools: circleci/browser-tools@1.2.3
cypress: cypress-io/cypress@3
jobs:
deps:
docker:
- image: udata/circleci:2-alpine
steps:
- checkout
# needed to commit changed *.pip files if needed
- add_ssh_keys:
fingerprints:
- 0f:6a:bf:3e:f5:85:d5:41:ca:77:ef:85:7f:f8:b5:9e
# FIXME: do we need this? ${CIRCLE_BRANCH} seems ok
- run:
name: Get the base reference branch
command: export BASE_BRANCH=$(base_branch)
- restore_cache:
keys:
- py-cache-v16-{{ arch }}-{{ .Branch }}
- py-cache-v16-{{ arch }}-{{ .Environment.BASE_BRANCH }}
- run:
name: Create venv and install pip-tools
# FIXME: For now, we fix setuptools due to https://github.com/etalab/data.gouv.fr/issues/1041
command: |
virtualenv venv
source venv/bin/activate
pip install --force-reinstall setuptools==66.1.1
pip install pip-tools
- run:
name: Upgrade udata to latest pypi release if tagged release
command: |
if [[ $CIRCLE_TAG ]]; then
# upgrade udata to latest pypi release
echo "udata" > requirements/udata.in
echo "tagged release, using udata as content of udata.in"
else
echo "not a tagged release, using checked-in udata.in"
fi
- run:
name: Compile python dependencies against udata
command: |
source venv/bin/activate
pip-compile requirements/udata.in --output-file=requirements/udata.pip
pip-compile requirements/install.in --output-file=requirements/install.pip
pip-compile requirements/test.in --output-file=requirements/test.pip
pip-compile requirements/develop.in --output-file=requirements/develop.pip
- run:
name: Commit any change in compiled *.pip
command: |
echo "here is the git diff after dependencies update:"
git --no-pager diff
if [[ $CIRCLE_TAG ]]; then
echo "This a tag build, do not push changes"
else
git config --global user.email "robot@data.gouv.fr"
git config --global user.name "Circle CI"
( \
git ls-files -m|grep -E "(install|test|develop|udata).pip" \
&& git commit requirements/*.pip -m "[auto] update deps" \
&& git push origin ${CIRCLE_BRANCH} \
) || true
fi
- persist_to_workspace:
root: .
paths:
- venv
python:
docker:
- image: udata/circleci:2-alpine
- image: mongo:3.6
- image: redis:alpine
environment:
BASH_ENV: /root/.bashrc
steps:
- checkout
- attach_workspace:
at: .
- run:
name: Install python dependencies
command: |
source venv/bin/activate
pip install --force-reinstall --no-deps -r requirements/udata.in
pip install -r requirements/udata.pip \
-r requirements/install.pip \
-r requirements/test.pip \
-r requirements/develop.pip
pip install -e .
- save_cache:
key: py-cache-v16-{{ arch }}-{{ .Branch }}
paths:
- venv
- run:
name: Run tests
command: |
source venv/bin/activate
inv qa test --report
- store_test_results:
path: reports
- store_artifacts:
path: reports/
destination: reports
- persist_to_workspace:
root: .
paths:
- venv
assets:
docker:
# TODO make an image based on 2-alpine w/ nvm and phantom deps
- image: udata/circleci:py3
environment:
BASH_ENV: /root/.bashrc
steps:
- checkout
- run:
name: Compute JS dependencies key
command: cat .nvmrc package.json > js.deps
- run:
name: Get the base reference branch
command: export BASE_BRANCH=$(base_branch)
- restore_cache:
keys:
- js-cache-{{ arch }}-{{ checksum "js.deps" }}
- js-cache-{{ arch }}-{{ .Branch }}
- js-cache-{{ arch }}-{{ .Environment.BASE_BRANCH }}
- run:
name: Install NodeJS and dependencies
command: nvm install && npm ci
- save_cache:
key: js-cache-{{ arch }}-{{ checksum "js.deps" }}
paths:
- node_modules
- save_cache:
key: js-cache-{{ arch }}-{{ .Branch }}
paths:
- node_modules
- run:
name: Compile assets
command: |
nvm use
npm run build
- persist_to_workspace:
root: .
paths:
- udata_front/theme/gouvfr/static
udata_front_plugins_helper:
docker:
- image: cimg/node:lts
steps:
- checkout
- run:
name: Compute JS dependencies key
command: cat udata-front-plugins-helper/package.json > helper-js.deps
- run:
name: Get the base reference branch
command: export BASE_BRANCH=$(base_branch)
- restore_cache:
keys:
- js-cache-{{ arch }}-{{ checksum "helper-js.deps" }}
- js-cache-{{ arch }}-{{ .Branch }}
- js-cache-{{ arch }}-{{ .Environment.BASE_BRANCH }}
- run:
name: Install NodeJS and dependencies
command: npm ci
working_directory: ./udata-front-plugins-helper
- save_cache:
key: js-cache-{{ arch }}-{{ checksum "helper-js.deps" }}
paths:
- udata-front-plugins-helper/node_modules
- save_cache:
key: js-cache-{{ arch }}-{{ .Branch }}
paths:
- udata-front-plugins-helper/node_modules
- run:
name: Compile and test package
working_directory: ./udata-front-plugins-helper
command: npm run preversion
cypress:
docker:
- image: cimg/python:3.7.13-browsers
- image: mongo:3.6
- image: redis:alpine
steps:
- checkout
- cypress/install
- attach_workspace:
at: .
- run:
name: Install python deps
command: |
pip install --force-reinstall --no-deps -r requirements/udata.in
pip install -e .
- run:
name: Prepare udata.cfg file with udata-front plugin
command: cp cypress/udata-front-e2e.cfg.example cypress/udata-front-e2e.cfg
- run:
name: add secrets to cypress/udata-front-e2e.cfg
command: |
if [ "$CAPTCHETAT_BASE_URL" ]; then
echo "CAPTCHETAT_CLIENT_ID = '${CAPTCHETAT_CLIENT_ID}'" >> cypress/udata-front-e2e.cfg
echo "CAPTCHETAT_CLIENT_SECRET = '${CAPTCHETAT_CLIENT_SECRET}'" >> cypress/udata-front-e2e.cfg
echo "CAPTCHETAT_BASE_URL = '${CAPTCHETAT_BASE_URL}'" >> cypress/udata-front-e2e.cfg
echo "CAPTCHETAT_OAUTH_BASE_URL = '${CAPTCHETAT_OAUTH_BASE_URL}'" >> cypress/udata-front-e2e.cfg
fi
- cypress/run-tests:
cypress-command: npm run ci
lighthouse:
docker:
- image: cimg/python:3.7.13-browsers
- image: mongo:3.6
- image: redis:alpine
steps:
- checkout
- browser-tools/install-chrome
- attach_workspace:
at: .
- run:
name: Generate udata fixtures
command: |
pip install --force-reinstall --no-deps -r requirements/udata.in
pip install -e .
udata generate-fixtures
- run:
name: Install lighthouse
command: sudo npm install -g @lhci/cli@0.10.x
- run:
name: Prepare udata.cfg file with udata-front plugin
command: cp .lighthouseci/front-plugin-udata.cfg udata.cfg
- run:
name: Run lighthouse
command: npm run lighthouse
- store_artifacts:
path: reports/
destination: reports
dist:
docker:
- image: udata/circleci:2-alpine
environment:
BASH_ENV: /root/.bashrc
steps:
- checkout
- attach_workspace:
at: .
- run:
name: Build a distributable package
command: |
source venv/bin/activate
# Check long description renders properly
python setup.py check -m -s
# Build a wheel release
if [[ $CIRCLE_TAG ]]; then
# This is a tagged release
inv pydist
elif [[ "$CIRCLE_BRANCH" == feature/* ]]; then
# This is a feature branch
inv pydist -b $CIRCLE_BUILD_NUM+${CIRCLE_BRANCH#*/}
else
# This is a simple development build
inv pydist -b $CIRCLE_BUILD_NUM
fi
- store_artifacts:
path: dist
- persist_to_workspace:
root: .
paths:
- dist
publish:
docker:
- image: udata/circleci:2-alpine
steps:
- attach_workspace:
at: .
- deploy:
name: Publish on PyPI
command: |
source venv/bin/activate
pip install twine
twine upload --username "${PYPI_USERNAME}" --password "${PYPI_PASSWORD}" dist/*.whl
workflows:
version: 2
build:
jobs:
- deps:
filters:
tags:
only: /v[0-9]+(\.[0-9]+)*/
- python:
requires:
- deps
filters:
tags:
only: /v[0-9]+(\.[0-9]+)*/
- assets:
filters:
tags:
only: /v[0-9]+(\.[0-9]+)*/
- udata_front_plugins_helper:
filters:
tags:
only: /v[0-9]+(\.[0-9]+)*/
- cypress:
requires:
- deps
- assets
filters:
tags:
only: /v[0-9]+(\.[0-9]+)*/
- lighthouse:
requires:
- deps
- assets
filters:
tags:
only: /v[0-9]+(\.[0-9]+)*/
- dist:
requires:
- python
- assets
filters:
tags:
only: /v[0-9]+(\.[0-9]+)*/
- publish:
requires:
- dist
filters:
branches:
only:
- master
tags:
only: /v[0-9]+(\.[0-9]+)*/
context: org-global