-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
303 lines (283 loc) · 7.74 KB
/
.gitlab-ci.yml
File metadata and controls
303 lines (283 loc) · 7.74 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
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
default:
image: python:3.14
before_script:
- uname -a
- python -V # Print out python version for debugging
- apt-get update
- git config --global user.email "cobib@cobib.org"
- git config --global user.name "CoBib"
- pip install virtualenv tox
# See https://docs.gitlab.com/ci/pipelines/merge_request_pipelines/
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
# Change pip's cache directory to be inside the project directory since we can
# only cache local items.
variables:
TERM: "linux"
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
GIT_SUBMODULE_STRATEGY: recursive
GIT_SUBMODULE_FORCE_HTTPS: "true"
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}"
# 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:
paths:
- .cache/pip
stages:
- lint
- test
- docs
- deploy
- publish
lint:
stage: lint
dependencies: []
script:
- tox -e lint -- --html-report htmlmypy --cobertura-xml-report .
- head -1 cobertura.xml | awk -F'line-rate*=*\"' '{sub(/".*/,"",$2); printf "mypy coverage %.0f", $2 * 100; print "%"}'
coverage: '/mypy coverage \d+%/'
artifacts:
when: always
expire_in: 30 days
paths:
- cobertura.xml
- htmlmypy
reports:
coverage_report:
coverage_format: cobertura
path: cobertura.xml
test:
stage: test
dependencies: []
parallel:
matrix:
- PYTHON_VERSION: ['3.10', '3.11', '3.12', '3.13', '3.14']
image: python:$PYTHON_VERSION
script:
- tox -e py$PYTHON_VERSION
artifacts:
when: always
expire_in: 30 days
paths:
- tests/snapshot_report.html
- tests/report-py$PYTHON_VERSION.xml
reports:
junit: tests/report-py$PYTHON_VERSION.xml
rules:
- if: $CI_MERGE_REQUEST_EVENT_TYPE == 'merge_train'
when: on_success
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
when: manual
allow_failure: true
- when: on_success
no-optionals:
stage: test
dependencies: []
script:
- tox -e no-optionals
artifacts:
when: always
expire_in: 30 days
paths:
- tests/report-no-optionals.xml
- tests/snapshot_report.html
reports:
junit: tests/report-no-optionals.xml
plugin:
stage: test
dependencies: []
script:
- tox -e plugin
artifacts:
when: always
expire_in: 30 days
paths:
- plugin/report-plugin.xml
- plugin/snapshot_report.html
reports:
junit: plugin/report-plugin.xml
coverage:
stage: test
dependencies: []
script:
- tox -e coverage
coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+\s+\d+\s+)*(\d+%)/'
artifacts:
when: always
expire_in: 30 days
paths:
- coverage.xml
- htmlcov
- snapshot_report.html
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
docs:
stage: docs
needs: []
script:
- apt-get install -y ruby-dev
- gem install ronn-ng
- tox -e docs
- mv build/html public
artifacts:
paths:
- public
dev-pages:
stage: deploy
needs: ["docs"]
before_script: []
script:
- ls public
environment:
name: dev
url: "https://$CI_PROJECT_NAMESPACE.gitlab.io/-/$CI_PROJECT_NAME/-/jobs/$CI_JOB_ID/artifacts/public/index.html"
artifacts:
paths:
- public
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: on_success
- when: never
mr-pages:
stage: deploy
needs: ["docs"]
before_script: []
script:
- ls public
environment:
name: docs/$CI_COMMIT_REF_SLUG
url: "https://$CI_PROJECT_NAMESPACE.gitlab.io/-/$CI_PROJECT_NAME/-/jobs/$CI_JOB_ID/artifacts/public/index.html"
on_stop: stop-mr-pages
artifacts:
paths:
- public
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
when: on_success
- when: never
stop-mr-pages:
stage: deploy
needs:
- job: mr-pages
artifacts: false
before_script: []
script:
- echo "Stopping docs preview environment"
environment:
name: docs/$CI_COMMIT_REF_SLUG
action: stop
rules:
- if: $CI_MERGE_REQUEST_ID
when: manual
allow_failure: true
- when: never
pages:
stage: deploy
needs: ["docs"]
before_script: []
script:
- ls public
artifacts:
paths:
- public
rules:
- if: $CI_COMMIT_TAG
when: on_success
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: manual
allow_failure: true
- when: never
build:
stage: publish
dependencies: []
script:
- pip install build
- python -m build
artifacts:
paths:
- dist/
rules:
- if: $CI_COMMIT_TAG
when: on_success
- when: never
archive:
stage: publish
needs:
- job: build
artifacts: false
script:
- git archive --format tar -o release.tar HEAD
- git submodule --quiet foreach --recursive
'git archive --format tar --prefix=$displaypath/ -o submodule.tar HEAD'
- TOPDIR=$(pwd) git submodule --quiet foreach --recursive
'cd $TOPDIR; tar --concatenate --file=release.tar $displaypath/submodule.tar; rm -fv $displaypath/submodule.tar'
- gzip -9 release.tar
- mv release.tar.gz "$CI_PROJECT_NAME-$CI_COMMIT_TAG.tar.gz"
artifacts:
paths:
- $CI_PROJECT_NAME-$CI_COMMIT_TAG.tar.gz
rules:
- if: $CI_COMMIT_TAG
when: on_success
- when: never
publish-gitlab:
stage: publish
needs: ["archive"]
script:
- |
curl --location --header "JOB-TOKEN: ${CI_JOB_TOKEN}" \
--upload-file "$CI_PROJECT_NAME-$CI_COMMIT_TAG.tar.gz" \
"${PACKAGE_REGISTRY_URL}/${CI_COMMIT_TAG}/${CI_PROJECT_NAME}-${CI_COMMIT_TAG}.tar.gz"
rules:
- if: $CI_COMMIT_TAG
when: on_success
- when: never
publish-pypi:
stage: publish
needs: ["build"]
id_tokens:
PYPI_ID_TOKEN:
aud: pypi
script:
- pip install twine
- twine upload dist/*
environment:
name: release
url: https://pypi.org/p/cobib
rules:
- if: $CI_COMMIT_TAG
when: on_success
- when: never
release:
stage: publish
image: registry.gitlab.com/gitlab-org/cli:latest
needs:
- job: publish-gitlab
artifacts: false
- job: publish-pypi
artifacts: false
before_script:
- echo "creating gitlab release"
script:
- echo "creating gitlab release"
release:
tag_name: '$CI_COMMIT_TAG'
description: '$CI_COMMIT_TAG'
assets:
links:
- name: "${CI_PROJECT_NAME}-${CI_COMMIT_TAG}.tar.gz"
url: "${PACKAGE_REGISTRY_URL}/${CI_COMMIT_TAG}/${CI_PROJECT_NAME}-${CI_COMMIT_TAG}.tar.gz"
filepath: "/${CI_PROJECT_NAME}-${CI_COMMIT_TAG}.tar.gz"
link_type: "package"
rules:
- if: $CI_COMMIT_TAG
when: on_success
- when: never