-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
273 lines (257 loc) · 8.26 KB
/
Copy path.gitlab-ci.yml
File metadata and controls
273 lines (257 loc) · 8.26 KB
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
#image: python:3.10-alpine3.19
image: python:3.11.9-slim-bookworm
variables: # Change pip's cache directory to be inside the project directory since we can only cache local items.
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip/"
stages:
- build
- test
- report
- package
- deploy
# before_script:
# - apk add --no-cache alpine-sdk g++ hdf5-dev llvm14-dev linux-headers
# - apt-get update
build-matrix:
stage: build
parallel:
matrix:
- PYTHON_VERSION: ["3.10", "3.12", "3.13", "3.11.9"]
image: python:${PYTHON_VERSION}-slim-bookworm
variables:
MATRIX_CACHE_KEY: "venv-${CI_COMMIT_REF_SLUG}-${PYTHON_VERSION}"
script:
- python -m pip install --upgrade pip
- python -m venv .venv
- . .venv/bin/activate
# - LLVM_CONFIG=/usr/bin/llvm14-config pip install llvmlite # Uncomment if needed for numba on specific images
- pip install --upgrade --upgrade-strategy eager -e ".[gui]"
cache:
key: "$MATRIX_CACHE_KEY"
paths:
- .venv/
- .cache/pip/
policy: pull-push
# TODO: as soon as the COS cache on gitlab works, separate into three jobs running in parallel to the tests
lint:
stage: test
cache:
key: "venv-${CI_COMMIT_REF_SLUG}-3.11.9"
paths:
- .venv/
- .cache/pip/
policy: pull
script:
# - if [ ! -d .venv ]; then python -m venv .venv; fi
- . .venv/bin/activate
- pip install ruff
- return_code=0
- ruff check --output-format grouped || return_code=$(($return_code + $?))
- ruff check --exit-zero --output-format grouped --output-file ruff.txt
- ruff check --exit-zero --output-format gitlab --output-file gl-code-quality-report.json
- exit $return_code
artifacts:
reports:
codequality: gl-code-quality-report.json
paths:
- ruff.txt
when: always
allow_failure: true
format:
stage: test
cache:
key: "venv-${CI_COMMIT_REF_SLUG}-3.11.9"
paths:
- .venv/
- .cache/pip/
policy: pull
script:
- . .venv/bin/activate
- pip install ruff
- ruff format --check
codespell:
stage: test
cache:
key: "venv-${CI_COMMIT_REF_SLUG}-3.11.9"
paths:
- .venv/
- .cache/pip/
policy: pull
script:
- . .venv/bin/activate
- pip install codespell
- return_code=0
- codespell > codespell.txt || return_code=$?
- cat codespell.txt
- python .gitlab/scripts/codespell_to_codequality.py < codespell.txt > gl-codespell-quality.json
- exit $return_code
artifacts:
when: always
reports:
codequality: gl-codespell-quality.json
paths:
- codespell.txt
- gl-codespell-quality.json
allow_failure: true
# Run tests in parallel across multiple Python versions for Merge Requests only
tests-matrix:
stage: test
parallel:
matrix:
- PYTHON_VERSION: ["3.10", "3.12", "3.13", "3.11.9"]
image: python:${PYTHON_VERSION}-slim-bookworm
variables:
MATRIX_CACHE_KEY: "venv-${CI_COMMIT_REF_SLUG}-${PYTHON_VERSION}"
COVERAGE_FILE: ".coverage.${PYTHON_VERSION}"
QT_QPA_PLATFORM: "offscreen"
cache:
key: "$MATRIX_CACHE_KEY"
paths:
- .venv/
- .cache/pip/
policy: pull-push
script:
- apt-get update && apt-get install -y libgl1 libxkbcommon-x11-0 libegl1 libdbus-1-3 libglib2.0-0 libfontconfig1 libnss3 libasound2 # needed for pyqt tests
- python -m pip install --upgrade pip
- python -m venv .venv
- . .venv/bin/activate
- pip install --upgrade --upgrade-strategy eager -e ".[gui]"
- pip install coverage pytest pytest-cov
- mkdir -p .testreports
- PYVER_SAFE=${PYTHON_VERSION//./}
- COVER_XML=.testreports/coverage-${PYTHON_VERSION}.xml
- HTML_DIR=.testreports/html-${PYTHON_VERSION}
- mkdir -p $HTML_DIR
- pytest test --junitxml=.testreports/report-${PYTHON_VERSION}.xml --cov=pyRadPlan --cov-report term --cov-report xml:$COVER_XML --cov-report html:$HTML_DIR
artifacts:
when: always
reports:
junit: .testreports/report-${PYTHON_VERSION}.xml
coverage_report:
coverage_format: cobertura
path: .testreports/coverage-${PYTHON_VERSION}.xml
paths:
- .coverage.${PYTHON_VERSION}
- .testreports/html-${PYTHON_VERSION}
- .testreports/coverage-${PYTHON_VERSION}.xml
- .testreports/report-${PYTHON_VERSION}.xml
coverage: '/TOTAL.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
coverage-aggregate:
stage: report
image: python:3.11-slim-bookworm
needs:
- job: tests-matrix
artifacts: true
script:
- python -m pip install --upgrade pip
- pip install coverage
# Combine only the reference Python (3.11) coverage as canonical; optionally we could merge all.
- ls -1 .coverage.* || true
- if [ -f .coverage.3.11.9 ]; then cp .coverage.3.11.9 .coverage; fi
# If combining all versions is desired later, replace previous line with: coverage combine .coverage.*
- coverage xml -o .testreports/coverage-aggregated.xml
- coverage html -d .testreports/html-aggregated
- coverage report || true
artifacts:
when: always
reports:
coverage_report:
coverage_format: cobertura
path: .testreports/coverage-aggregated.xml
paths:
- .testreports/html-aggregated
- .testreports/coverage-aggregated.xml
coverage: '/TOTAL.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
packaging:
stage: package
variables:
TWINE_USERNAME: gitlab-ci-token
TWINE_PASSWORD: $CI_JOB_TOKEN
cache:
key: "venv-${CI_COMMIT_REF_SLUG}-3.11.9"
paths:
- .venv/
- .cache/pip/
policy: pull
script:
#- if [ ! -d .venv ]; then python -m venv .venv; fi
- . .venv/bin/activate
- pip install --upgrade build
- python -m build
artifacts:
paths:
- dist/
expire_in: 1 week
docs:
stage: package
cache:
key: "venv-${CI_COMMIT_REF_SLUG}-3.11.9"
paths:
- .venv/
- .cache/pip/
policy: pull
script:
#- if [ ! -d .venv ]; then python -m venv .venv; fi
- . .venv/bin/activate
- pip install sphinx
- pip install sphinx-autodoc-typehints
- pip install autodoc_pydantic
- pip install sphinx-design
- pip install pydata-sphinx-theme
- pip install numpydoc
- sphinx-build docs .doc
artifacts:
when: always
paths:
- .doc
deploy-tag-internal:
stage: deploy
variables:
TWINE_USERNAME: gitlab-ci-token
TWINE_PASSWORD: $CI_JOB_TOKEN
cache:
key: "venv-${CI_COMMIT_REF_SLUG}-3.11.9"
paths:
- .venv/
- .cache/pip/
policy: pull
rules:
- if: '$CI_COMMIT_TAG =~ /^v\d+.\d+.\d+$/'
script:
#- if [ ! -d .venv ]; then python -m venv .venv; fi
- . .venv/bin/activate
- pip install --upgrade twine
- python -m twine upload --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi dist/*
dependencies:
- packaging
deploy-tag-pypi:
stage: deploy
variables:
TWINE_USERNAME: __token__
TWINE_PASSWORD: $PYPI_TOKEN
cache:
key: "venv-${CI_COMMIT_REF_SLUG}-3.11.9"
paths:
- .venv/
- .cache/pip/
policy: pull
rules:
- if: '$CI_COMMIT_TAG =~ /^v\d+.\d+.\d+$/'
script:
#- if [ ! -d .venv ]; then python -m venv .venv; fi
- . .venv/bin/activate
- pip install --upgrade twine
- python -m twine upload dist/*
dependencies:
- packaging
pages-internal:
stage: deploy
dependencies:
- coverage-aggregate
- docs
script:
- mv .doc public/
artifacts:
paths:
- public
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH