forked from comet-toolkit/comet_maths
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
275 lines (251 loc) · 6.56 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
268
269
270
271
272
273
274
275
# Default image, if not specified
image: "python:3.8"
stages:
- Static Analysis
- Readthedocs Documentation
- Build latex Documentation
- Publish latex Documentation
- Test
#- Full test
- Publish test report
- Combine quality documentation
### Setup cache ###
# See https://docs.gitlab.com/ee/ci/caching/index.html
#
# Change pip's cache directory to be inside the project directory since we can
# only cache local items.
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
# Pip's cache doesn't store the python packages
# https://pip.pypa.io/en/stable/reference/pip_install/#caching
#
# If you want to also cache the installed packages, you have to install
# them in a virtualenv and cache it as well.
cache:
key: ${CI_JOB_NAME}
paths:
- .cache/pip
- .tox/
- venv/
# Make a template for steps that use a python virtual env
.py_venv:
before_script:
# Store the CI_JOB_TOKEN so that jobs can access other repositories with the access rights of the triggering user:
- echo -e "machine gitlab.npl.co.uk\nlogin gitlab-ci-token\npassword ${CI_JOB_TOKEN}" > ~/.netrc
# Debug output
- ls -la
- pwd
- python -c "import sys;print(sys.path)"
- python --version
# Set up git for test commits
- git config --global user.name "Gitlabs CI Testing"
- git config --global user.email "[email protected]"
# Make a virtual environment to install deps into (this will be cached for each step)
- python --version
- pip install virtualenv
- virtualenv venv
- source venv/bin/activate
- pip install .[dev]
### Linting ###
black:
image:
name: cytopia/black
entrypoint: [""]
stage: Static Analysis
script:
- black --check comet_maths
allow_failure: true
needs: []
mypy:
image:
name: grktsh/mypy
entrypoint: [""]
stage: Static Analysis
script:
- mypy comet_maths
allow_failure: true
needs: []
### Tests ###
.tox:
extends: .py_venv
script:
- pwd
- ls -l
- export PYTHONPATH="$PYTHONPATH:."
- python -c "import sys;print(sys.path)"
- pip install tox
- mkdir test_report
- tox
coverage: '/^TOTAL.+?(\d+\%)$/'
needs: []
artifacts:
when: always
paths:
- test_report/
- test_report/cov_report
reports:
junit: cov_report.xml
expire_in: 1 hour
tox-3.6:
extends: ".tox"
stage: "Test"
image: "python:3.6"
rules:
- if: '$CI_COMMIT_TAG'
when: always
tox-3.7:
extends: ".tox"
stage: "Test"
image: "python:3.7"
tox-3.8:
extends: ".tox"
stage: "Test"
image: "python:3.8"
rules:
- if: '$CI_COMMIT_TAG'
when: always
# tox_slowtests:
# extends: .py_venv
# stage: "Full test"
# rules:
# # Run for scheduled or triggered builds
# - if: '$CI_PIPELINE_SOURCE == "trigger"'
# when: always
# - if: '$CI_PIPELINE_SOURCE == "schedule"'
# when: always
# # Run for tags
# - if: '$CI_COMMIT_TAG'
# when: always
# # And allow manual runs
# - if: '$CI_COMMIT_BRANCH'
# when: manual
# allow_failure: true
# script:
# - pwd
# - ls -l
# - export PYTHONPATH="$PYTHONPATH:."
# - python -c "import sys;print(sys.path)"
# - pip install tox
# - tox -- --runslow
# coverage: '/^TOTAL.+?(\d+\%)$/'
# needs: []
test_report:
needs: ["tox-3.7"]
stage: Publish test report
image:
name: oberonamsterdam/wkhtmltopdf
entrypoint: [""]
script:
- wkhtmltopdf --enable-local-file-access file:////builds/eco/tools/comet_maths/test_report/report.html test_report.pdf
- wkhtmltopdf --enable-local-file-access file:////builds/eco/tools/comet_maths/test_report/cov_report/index.html cov_report.pdf
- mv test_report.pdf ./quality_documentation/test_report.pdf
- mv cov_report.pdf ./quality_documentation/cov_report.pdf
artifacts:
paths:
- quality_documentation
expire_in: 1 hour
rules:
- if: '$CI_COMMIT_TAG'
when: always
### Documentation ###
# Upload the documentation to pages if it's a tagged commit
pages:
extends: .py_venv
stage: Readthedocs Documentation
needs: []
script:
- sphinx-build docs public -b html
artifacts:
paths:
- public
expire_in: 1 hour
rules:
- if: '$CI_COMMIT_TAG'
when: always
- if: '$CI_COMMIT_BRANCH == "master"'
when: always
pdf_make:
extends: .py_venv
stage: Build latex Documentation
needs: []
script:
- sphinx-build docs latex -b latex
- cp -r latex ./quality_documentation/latex
artifacts:
paths:
- quality_documentation/latex
expire_in: 1 hour
rules:
- if: '$CI_COMMIT_TAG'
when: always
pdf_compile:
needs: ["pdf_make"]
stage: Publish latex Documentation
image: charlesbaynham/ctanfull
artifacts:
paths:
- user_manual.pdf
expose_as: "Manual"
name: ${CI_COMMIT_REF_SLUG}_manual.pdf
script:
- ls
- cd quality_documentation/latex
- make
- cp user_manual.pdf ../../user_manual.pdf
rules:
- if: '$CI_COMMIT_TAG'
when: always
pdf_compile_all:
needs: ["pdf_make","test_report"]
stage: Combine quality documentation
image: charlesbaynham/ctanfull
artifacts:
paths:
- QualityDocumentation.pdf
expose_as: "QualityDocumentation"
name: ${CI_COMMIT_REF_SLUG}_QualityDocumentation.pdf
script:
- cd quality_documentation/latex
- ls
- cd ..
- cd uml
- for i in *.png; do echo "\includegraphics[width=\textwidth]{$i}">>uml.tex; done
- cd ..
- latexmk -e '$pdflatex=q/pdflatex %O -shell-escape %S/' -pdf
- cp QualityDocumentation.pdf ../.
rules:
- if: '$CI_COMMIT_TAG'
when: always
# Copied contents of Gitlab's Code-Quality.gitlab-ci.yml so I can edit the rules
code_quality:
stage: Static Analysis
needs: []
image: docker:19.03.5
allow_failure: true
services:
- docker:19.03.5-dind
variables:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
CODE_QUALITY_IMAGE: "registry.gitlab.com/gitlab-org/ci-cd/codequality:0.85.9"
script:
- |
if ! docker info &>/dev/null; then
if [ -z "$DOCKER_HOST" -a "$KUBERNETES_PORT" ]; then
export DOCKER_HOST='tcp://localhost:2375'
fi
fi
- docker pull --quiet "$CODE_QUALITY_IMAGE"
- docker run
--env SOURCE_CODE="$PWD"
--volume "$PWD":/code
--volume /var/run/docker.sock:/var/run/docker.sock
"$CODE_QUALITY_IMAGE" /code
artifacts:
reports:
codequality: gl-code-quality-report.json
expire_in: 1 week
dependencies: []
rules:
- if: '$CI_PROJECT_URL =~ /^.*gitlab.com.*/'
when: always