-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy path.gitlab-ci.yml
372 lines (348 loc) · 9.73 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
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
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
image: python:3.10-bullseye
stages:
- test
- package
- doc
- test-package
- sonar
- publish
- deploy
#
# Test Stage
#
.tox: &tox
stage: test
variables:
TOXENV: $CI_JOB_NAME
before_script:
- apt-get -yq update
- apt-get install -yq rdiff-backup
script:
- pip install tox
- export TOXENV=${TOXENV:-$CI_JOB_NAME}
- echo TOXENV=$TOXENV
- useradd myuser
- su myuser -c tox
artifacts:
paths:
- coverage-*.xml
- xunit-*.xml
expire_in: 1 day
flake8:
<<: *tox
black:
<<: *tox
isort:
<<: *tox
djlint:
<<: *tox
py3:
<<: *tox
image: $IMAGE
parallel:
matrix:
- TOXENV: py3
IMAGE: python:3.6
- TOXENV: py3
IMAGE: python:3.8
- TOXENV: bullseye
IMAGE: python:3.9-bullseye
- TOXENV: py3
IMAGE: python:3.10
- TOXENV: bookworm
IMAGE: python:3.11
sqlalchemy2:
<<: *tox
selenium:
<<: *tox
before_script:
- apt update
- apt -y --no-install-recommends install xvfb xauth chromium-driver rdiff-backup
artifacts:
paths:
- coverage.xml
- xunit.xml
rdiff-backup-latest:
<<: *tox
image: python:3.9-bullseye
variables:
TOXENV: bullseye
allow_failure: true
before_script:
- apt-get update
- apt -y install librsync-dev
- pip install tox
- pip install -U rdiff-backup
postgresql-12:
<<: *tox
image: $IMAGE
services:
- postgres:12.2-alpine
variables:
TOXENV: bullseye
IMAGE: python:3.9-bullseye
RDIFFWEB_TEST_DATABASE_URI: "postgresql://admin@postgres/test"
POSTGRES_DB: test
POSTGRES_USER: admin
POSTGRES_PASSWORD: ""
POSTGRES_HOST_AUTH_METHOD: trust
doc:
<<: *tox
stage: doc
needs: []
dependencies: []
artifacts:
paths:
- .tox/doc/tmp/html
expire_in: 1 day
package:py3:
stage: package
needs: []
script:
- pip3 install wheel
- python3 setup.py sdist bdist_wheel
dependencies: []
artifacts:
paths:
- dist/*.whl
expire_in: 1 day
package:docker:
stage: package
needs: []
dependencies: []
image: docker:20
services:
- name: docker:20-dind
script:
# Get docker layes
- docker pull ikus060/rdiffweb:latest || true
- docker pull ikus060/rdiffweb:$CI_COMMIT_REF_SLUG || true
- docker build --cache-from ikus060/rdiffweb:latest --cache-from ikus060/rdiffweb:$CI_COMMIT_REF_SLUG -t rdiffweb .
- docker build --target test .
- mkdir dist
- docker save rdiffweb --output dist/rdiffweb-docker.tar
artifacts:
paths:
- dist/*-docker.tar
expire_in: 1 day
package:deb:
stage: package
needs: []
image: buildpack-deps:$DIST
parallel:
matrix:
- DIST: [bullseye, bookworm]
- DIST: [jammy, lunar, noble, oracular]
script:
# Clean-up
- rm -f ../rdiffweb_*
- rm -Rf ./dist/$DIST/*
# Install dependencies
- apt update
- apt -y --no-install-recommends install devscripts lsb-release
- apt build-dep -y .
# Generate change log
- export DEBEMAIL=${CI_COMMIT_AUTHOR}
- debian/rules changelog
# Generate orig.tar.gz
- debian/rules gentarball
# Run build in separate target
- debuild -us -uc
# Move files to archives
- mkdir -p ./dist/$DIST
- mv ../rdiffweb_* ./dist/$DIST/
artifacts:
paths:
- ./dist/*
expire_in: 1 day
test-package:deb:
stage: test-package
image: buildpack-deps:$DIST
needs: ["package:deb"]
parallel:
matrix:
- DIST: [bullseye, bookworm]
# Ubuntu tzdata is broken https://githubmate.com/repo/regebro/tzlocal/issues/101
# So we need to make it explicit using environment variable
- DIST: [jammy, lunar, noble, oracular]
TZ: UTC
script:
- apt update
- apt install -y ./dist/$DIST/rdiffweb*.deb
- rdiffweb --version
- (/usr/bin/rdiffweb &)
- timeout 60 bash -c 'until curl --silent http://localhost:8080; do sleep 1; done'
# Check if static files are working
- curl http://localhost:8080/static/css/bootstrap.min.css
- curl http://localhost:8080/static/css/bootstrap.min.css.map
- curl http://localhost:8080/static/css/font-awesome.css.map
- curl http://localhost:8080/static/css/font-awesome.min.css
- curl http://localhost:8080/static/css/jquery.dataTables.min.css
- curl http://localhost:8080/static/css/responsive.dataTables.min.css
- curl http://localhost:8080/static/fonts/fontawesome-webfont.eot
- curl http://localhost:8080/static/fonts/fontawesome-webfont.svg
- curl http://localhost:8080/static/fonts/fontawesome-webfont.woff
- curl http://localhost:8080/static/fonts/fontawesome-webfont.woff2
- curl http://localhost:8080/static/images/sort_asc.png
- curl http://localhost:8080/static/images/sort_both.png
- curl http://localhost:8080/static/images/sort_desc.png
- curl http://localhost:8080/static/js/bootstrap.bundle.js.map
- curl http://localhost:8080/static/js/bootstrap.bundle.min.js
- curl http://localhost:8080/static/js/dataTables.buttons.min.js
- curl http://localhost:8080/static/js/dataTables.responsive.min.js
- curl http://localhost:8080/static/js/jquery.dataTables.min.js
- curl http://localhost:8080/static/js/jquery.min.js
publish:sonar:master:
stage: sonar
allow_failure: True
needs:
- py3
image: sonarsource/sonar-scanner-cli
only:
- master
variables:
SONAR_PROJECT_BASE_DIR: "${CI_PROJECT_DIR}"
script:
- sonar-scanner -X -Dsonar.python.coverage.reportPaths=coverage-*.xml -Dsonar.python.xunit.reportPaths=xunit-py3.xml -Dsonar.host.url=$SONAR_URL -Dsonar.login=$SONAR_TOKEN -Dsonar.projectKey=$CI_PROJECT_NAME -Dsonar.projectVersion=$(git describe) -Dsonar.qualitygate.wait=True
publish:sonar:dev:
stage: sonar
allow_failure: True
needs:
- py3
image: sonarsource/sonar-scanner-cli
only:
variables:
- $SONAR_URL
- $SONAR_TOKEN
variables:
SONAR_PROJECT_BASE_DIR: "${CI_PROJECT_DIR}"
script:
- sonar-scanner -X -Dsonar.python.coverage.reportPaths=coverage-*.xml -Dsonar.python.xunit.reportPaths=xunit-*.xml -Dsonar.host.url=$SONAR_URL -Dsonar.login=$SONAR_TOKEN -Dsonar.projectKey=$CI_PROJECT_NAME-dev -Dsonar.projectVersion=$(git describe) -Dsonar.qualitygate.wait=True
publish:docker:
needs:
- package:docker
image: docker:20
services:
- name: docker:20-dind
only:
variables:
- $DOCKER_USR
- $DOCKER_PWD
script: |
set -x
docker login $DOCKER_REGISTRY -u $DOCKER_USR -p $DOCKER_PWD
docker load --input dist/*.tar
# Push commit hash
docker tag rdiffweb ikus060/rdiffweb:$CI_COMMIT_SHORT_SHA
docker push ikus060/rdiffweb:$CI_COMMIT_SHORT_SHA
# Push branch name
docker tag rdiffweb ikus060/rdiffweb:$CI_COMMIT_REF_SLUG
docker push ikus060/rdiffweb:$CI_COMMIT_REF_SLUG
# Push tags
if [ -n "$CI_COMMIT_TAG" ]; then
docker tag rdiffweb ikus060/rdiffweb:$CI_COMMIT_TAG
docker push ikus060/rdiffweb:$CI_COMMIT_TAG
fi
# Push tag as latest
case ${CI_COMMIT_TAG##*.} in
[0-9]*)
docker tag rdiffweb ikus060/rdiffweb:latest
docker push ikus060/rdiffweb:latest
;;
esac
stage: publish
publish:docker-readme:
needs:
- package:docker
only:
variables:
- $DOCKER_USR
- $DOCKER_PWD
- $CI_COMMIT_TAG
image:
name: chko/docker-pushrm
entrypoint: ["/bin/sh", "-c"]
variables:
DOCKER_USER: $DOCKER_USR
DOCKER_PASS: $DOCKER_PWD
PUSHRM_SHORT: A web interface to rdiff-backup repositories.
PUSHRM_TARGET: docker.io/ikus060/rdiffweb
PUSHRM_DEBUG: 1
PUSHRM_FILE: $CI_PROJECT_DIR/README.md
script:
# Keep top 400 lines to workarround Dockerhub limitation.
- cp README.md README.md.orig
- head -n 400 README.md.orig > README.md
# Push file
- /docker-pushrm
stage: publish
publish:deb:
needs:
- package:deb
only:
variables:
- $NEXUS_USR
- $NEXUS_PWD
parallel:
matrix:
- DIST: [bullseye, bookworm, jammy, lunar, noble, oracular]
script: |
set -e
set -x
if [[ "$CI_COMMIT_TAG" == *.+([0-9]) ]]; then
APT_URL="$NEXUS_URL/repository/apt-release-${DIST}/"
else
APT_URL="$NEXUS_URL/repository/apt-dev-${DIST}/"
fi
export FILE=$(ls -1 ./dist/$DIST/rdiffweb*.deb)
curl --fail -u "$NEXUS_USR:$NEXUS_PWD" -H "Content-Type: multipart/form-data" --data-binary "@$FILE" "$APT_URL"
stage: publish
publish:wheel:
stage: publish
only:
variables:
- $NEXUS_USR
- $NEXUS_PWD
- $NEXUS_PYPI_URL
script: |
set -x
# Publish wheel
pip3 install wheel twine readme_renderer[md] --upgrade
LANG="C.UTF-8" python3 -m readme_renderer README.md -o /tmp/README.html
twine upload dist/*.whl -u $NEXUS_USR -p $NEXUS_PWD --repository-url $NEXUS_PYPI_URL
if [ ! -z "$CI_COMMIT_TAG" ]; then
twine upload dist/*.whl -u $PYPI_USR -p $PYPI_PWD
fi
publish:doc:
stage: publish
only:
variables:
- $NEXUS_USR
- $NEXUS_PWD
- $NEXUS_URL
needs:
- doc
script:
# publish to nexus
- export VERSION=$(python3 setup.py --version)
- cd .tox/doc/tmp/html
- find * -type f -exec curl --fail -u "$NEXUS_USR:$NEXUS_PWD" --upload-file "{}" $NEXUS_URL/repository/archive/rdiffweb/$VERSION/doc/{} \;
deploy:demo:
only:
variables:
- $GITLAB_ANSIBLE_TOKEN
allow_failure: True
environment:
name: demo
url: https://rdiffweb-demo.ikus-soft.com/
needs:
- package:deb
image: registry.gitlab.com/finestructure/pipeline-trigger
script:
- export DEB_VERSION=$(ls -1 ./dist/bookworm/rdiffweb_*_all.deb | cut -d '_' -f 2)
- echo DEB_VERSION=$DEB_VERSION
# Trigger ansible-config pipeline
- trigger -a "$ANSIBLE_PIPELINE_GITLAB_API_TOKEN" -t master -e "RDIFFWEB_VERSION=$DEB_VERSION" -p 36bae86778d901fc6b2d6453a41844 18716492
stage: deploy
variables:
GIT_STRATEGY: none