-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
192 lines (172 loc) · 4.2 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
image: python:3.11
variables:
CONTAINER_IMAGE: ${CI_PROJECT_PATH}:${CI_COMMIT_SHORT_SHA}
stages:
- test
- package
- doc
- test-package
- upload
- deploy
.tox: &tox
script:
- pip install tox
- tox -e ${TOXENV:-$CI_JOB_NAME}
stage: test
black:
<<: *tox
flake8:
<<: *tox
isort:
<<: *tox
djlint:
<<: *tox
py3:
<<: *tox
artifacts:
paths:
- coverage.xml
- xunit.xml
sqlalchemy2:
<<: *tox
selenium:
<<: *tox
before_script:
- apt update && apt -y --no-install-recommends install xvfb xauth chromium-driver
artifacts:
paths:
- coverage-selenium.xml
- xunit-selenium.xml
bookworm:
<<: *tox
postgresql:
<<: *tox
services:
- postgres:12.2-alpine
variables:
TOXENV: py3
TEST_DATABASE_URI: "postgresql://admin@postgres/test"
POSTGRES_DB: test
POSTGRES_USER: admin
POSTGRES_PASSWORD: ""
POSTGRES_HOST_AUTH_METHOD: trust
sonar:
allow_failure: true
image: sonarsource/sonar-scanner-cli
needs:
- py3
- selenium
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 -Dsonar.projectVersion=$(git describe) -Dsonar.qualitygate.wait=true
stage: test
variables:
SONAR_PROJECT_BASE_DIR: "${CI_PROJECT_DIR}"
doc:
<<: *tox
stage: doc
needs: []
dependencies: []
artifacts:
paths:
- .tox/doc/tmp/html
expire_in: 1 day
bdist:deb:
stage: package
needs: []
image: buildpack-deps:$DIST
parallel:
matrix:
- DIST: [bookworm]
script: |
set -x
set -e
apt update
apt -y --no-install-recommends install devscripts
apt build-dep -y .
export SETUPTOOLS_SCM_PRETEND_VERSION_FOR_UDB=$(python3 -m setuptools_scm)
dch -v "$SETUPTOOLS_SCM_PRETEND_VERSION_FOR_UDB" "automated build"
dpkg-buildpackage -b
mkdir -p ./dist/$DIST
mv ../udb*.deb ./dist/$DIST/
artifacts:
paths:
- ./dist/*
package:docker:
image: docker:20
needs: []
script:
- docker --version
- docker build -t ${CONTAINER_IMAGE} .
stage: package
services:
- name: docker:20-dind
test-bdist:deb:
stage: test-package
image: buildpack-deps:$DIST
needs:
- bdist:deb
parallel:
matrix:
- DIST: [bookworm]
script:
- apt update && apt install -y ./dist/$DIST/udb*.deb
- udb --version | grep -v '0.0.0'
- (/usr/bin/udb --database-uri sqlite:///data.db &)
- timeout 60 bash -c 'until curl --silent http://localhost:8080; do sleep 1; done'
upload:deb:
image: buildpack-deps:bookworm
needs:
- bdist:deb
only:
variables:
- $NEXUS_USR
- $NEXUS_PWD
parallel:
matrix:
- DIST: [bookworm]
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/udb*.deb)
curl --fail -u "$NEXUS_USR:$NEXUS_PWD" -H "Content-Type: multipart/form-data" --data-binary "@$FILE" "$APT_URL"
sleep 2
curl --fail ${APT_URL}/dists/$DIST/main/binary-all/Packages | grep "$(basename $FILE)"
stage: upload
upload:doc:
stage: upload
only:
variables:
- $NEXUS_USR
- $NEXUS_PWD
- $NEXUS_URL
needs:
- doc
script:
- pip install setuptools-scm
- export VERSION=$(python -m setuptools_scm)
- cd .tox/doc/tmp/html
# publish to nexus
- find * -type f -exec curl --fail -u "$NEXUS_USR:$NEXUS_PWD" --upload-file "{}" $NEXUS_URL/repository/archive/udb/$VERSION/doc/{} \;
deploy:dev:
allow_failure: True
environment:
name: dev
url: https://udb-demo.ikus-soft.com/
needs:
- bdist:deb
- upload:deb
image: registry.gitlab.com/finestructure/pipeline-trigger
script:
- apk update && apk add git
- export DEB_VERSION=$(ls -1 dist/bookworm/udb_*_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 "UDB_VERSION=$DEB_VERSION" -p 36bae86778d901fc6b2d6453a41844 18716492
stage: deploy
variables:
GIT_STRATEGY: none