-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
258 lines (230 loc) · 6.61 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
default:
image: python:3.10
before_script: # poetry virtual env initialization
- apt-get update -qy
- pip install poetry
- export PATH="$HOME/.local/bin:$HOME/bin:$PATH"
- poetry install --no-ansi --no-interaction
- source `poetry env info --path`/bin/activate
stages:
- linter
- code coverage
- code quality
- compatability
- test suite quality
- publish
- examples
include:
- template: Code-Quality.gitlab-ci.yml
variables:
LANG: C.UTF-8
prospector:
stage: linter
script:
- echo "This is the prospector linter stage"
- poetry run lint
pytest_statement:
stage: code coverage
script:
- echo "This is the statement coverage test stage"
- coverage run --omit="tests/*" -m pytest tests --junitxml=report.xml --html=report.html --self-contained-html
- coverage report --ignore-errors
- coverage xml --ignore-errors
- coverage html --ignore-errors
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
artifacts:
name: "$CI_JOB_NAME"
when: always
paths:
- htmlcov/*
- report.html
reports:
junit: report.xml
coverage_report:
coverage_format: cobertura
path: coverage.xml
pytest_branch:
stage: code coverage
script:
- echo "This is the branch coverage test stage"
- coverage run --branch --omit="tests/*" -m pytest tests --junitxml=report.xml --html=report.html --self-contained-html
- coverage report --ignore-errors
- coverage xml --ignore-errors
- coverage html --ignore-errors
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
artifacts:
name: "$CI_JOB_NAME"
when: always
paths:
- htmlcov/*
- report.html
reports:
junit: report.xml
coverage_report:
coverage_format: cobertura
path: coverage.xml
cosmic_ray:
stage: test suite quality
allow_failure: true
needs: [prospector]
script:
- apt-get update -qy
- apt-get install -y bc
- pip install anybadge
- echo "This is the mutation test stage"
- poetry run mutation-test
- OUTPUT=$(poetry run mutation-text-report --config_path gmt_mutation_config.toml --database_path gmt_mutation.sqlite | tail -1)
- OUTPUT=$(echo "$OUTPUT" | grep -oP '\(\K[0-9.]+(?=%\))')
- OUTPUT=$(echo "100 - ${OUTPUT}" | bc)
- anybadge -l "Mutation Score" -v $OUTPUT -f mutation_score.svg coverage
artifacts:
when: always
paths:
- mutation_score.svg
- mutation_report.html
tags:
- single
code_quality:
stage: code quality
before_script:
- apk update
- apk add py3-pip
artifacts:
paths: [ gl-code-quality-report.json ]
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
code_quality_html:
extends: code_quality
variables:
REPORT_FORMAT: html
artifacts:
paths: [ gl-code-quality-report.html ]
qodana:
stage: code quality
only:
- main
- develop
- merge_requests
image:
name: jetbrains/qodana-python-community:2023.2
entrypoint: [ "" ]
variables:
QODANA_TOKEN: $qodana_token
script:
- qodana --save-report --results-dir=$CI_PROJECT_DIR/.qodana/results
--cache-dir=$CI_PROJECT_DIR/.qodana/cache
artifacts:
paths:
- qodana/report/
expose_as: 'Qodana report'
pytest_version:
stage: compatability
image: python:$VERSION
needs: [prospector]
script:
- pip install poetry
- export PATH="$HOME/.local/bin:$HOME/bin:$PATH"
- poetry install --no-ansi --no-interaction
- source `poetry env info --path`/bin/activate
- echo "This is the Python $VERSION compatability test stage"
- poetry run pytest tests
parallel:
matrix:
- VERSION: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
pytest_win_10:
stage: compatability
image: mcr.microsoft.com/windows
needs: [prospector]
before_script: [ ]
script:
- python -m virtualenv pytest_win_10
- .\pytest_win_10\Scripts\activate
- python -m pip install poetry
- python -m poetry install --no-ansi --no-interaction
- echo "This is the Python Windows Server 2019 compatability test stage"
- python -m poetry run pytest tests
tags:
- windows
pytest_wsl_win_10:
stage: compatability
image: mcr.microsoft.com/windows
needs: [prospector]
before_script: [ ]
script:
- wsl python3 -m pip install poetry
- wsl export PATH="$HOME/.local/bin:$HOME/bin:$PATH"
- wsl export PATH="$HOME/.poetry/bin:$PATH"
- wsl python3 -m poetry install --no-ansi --no-interaction
- wsl python3 -m poetry env info --path
- wsl echo "This is the Python 3.10 run in WSL1 run on Windows Server 2019 compatability test stage"
- wsl bash -c 'PATH="\$HOME/.local/bin:\$HOME/bin:\$PATH" && export PATH="\$HOME/.poetry/bin:\$PATH" && python3 -m poetry run pytest tests'
tags:
- windows
publishing:
stage: publish
needs: [ pytest_statement, pytest_branch, prospector, pytest_version, pytest_win_10, pytest_wsl_win_10 ]
script:
- echo "This is the publish stage"
- poetry config pypi-token.pypi "$PYPI_API_KEY"
- poetry publish --build
- echo "Publishing done!"
only:
- main
when: manual
# Examples using Python 3.10
.knapsack_example:
stage: examples
needs: [ ]
script:
- poetry run example-fail knapsack/test_knapsack.py
.simple_example:
stage: examples
needs: [ ]
script:
- poetry run example simple/test_add.py
- poetry run example simple/test_avg.py
.trigonometry_example:
stage: examples
needs: [ ]
script:
- poetry run example trigonometry/test_cos.py
- poetry run example trigonometry/test_faulty_sin.py
- poetry run example trigonometry/test_sin.py
.house_pricing_example:
stage: examples
needs: [ ]
script:
- poetry run example house_pricing/test_house_pricing.py
.shortest_path_example:
stage: examples
needs: [ ]
script:
- poetry run example shortest_path/test_path.py
.facial_keypoints_example:
stage: examples
needs: [ ]
script:
- poetry run example-fail facial_keypoints/test_keypoints.py
.radar_retraining_example:
stage: examples
needs: [ ]
script:
- poetry run example-fail radar_retraining/test_radar.py
.gtsrb_example:
stage: examples
needs: [ ]
script:
- poetry run example-fail gtsrb/metamorphic_tests
.mnist_example:
stage: examples
needs: [ ]
script:
- poetry run example-fail mnist/metamorphic_tests/test_label_preserving.py
- poetry run example-fail mnist/metamorphic_tests/test_non_label_preserving.py
.numpy_example:
stage: examples
needs: [ ]
script:
- poetry run example linalg/test_solve.py
- poetry run example linalg/test_solve_tighter_oracle.py
- poetry run example linalg/test_transpose.py