-
Notifications
You must be signed in to change notification settings - Fork 3
/
.gitlab-ci.yml
292 lines (269 loc) · 8.21 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
stages:
- test
- doc
- build
- build_check
- notif
before_script:
- echo 'sudo --preserve-env=PYTHONPATH -u www-data python3-coverage run -a --source se,sosse ./sosse/sosse_admin.py "$@"' > /tmp/sudo_sosse
- chmod 755 /tmp/sudo_sosse
- test -z "$APT_PROXY" || (echo "Acquire::http::Proxy \"$APT_PROXY\";" > /etc/apt/apt.conf.d/proxy.conf)
- "git submodule update --recursive --remote ||:"
- 'sed -e "s/^__version__.*/__version__ = \"1.0.0\"/" -i se/deps/fake-useragent/src/fake_useragent/settings.py ||:'
variables:
GIT_SUBMODULE_STRATEGY: recursive
unit_tests:
image: biolds/sosse:debian-test
stage: test
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
artifacts:
when: always
paths:
- se/migrations/*.py
- htmlcov/*
- log/*
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
script:
- export PYTHONPATH="$CI_PROJECT_DIR"
- make _docker_unit_test_prepare
- failed=0
- /tmp/sudo_sosse test -v3 --failfast || failed=1
- /tmp/sudo_sosse load_se tests/opensearch.xml || failed=1
- /tmp/sudo_sosse update_se || failed=1
- /tmp/sudo_sosse shell -c 'from django.contrib.auth.models import User; User.objects.all().delete()' || failed=1
- /tmp/sudo_sosse default_admin || failed=1
- /tmp/sudo_sosse generate_secret || failed=1
- /tmp/sudo_sosse extract_doc cli > /dev/null || failed=1
- /tmp/sudo_sosse extract_doc conf > /dev/null || failed=1
- /tmp/sudo_sosse extract_doc se > /dev/null || failed=1
- python3 ./sosse/sosse_admin.py makemigrations || failed=1
- /tmp/sudo_sosse migrate || failed=1
- /tmp/sudo_sosse migrate se 0001 || failed=1
- python3-coverage report --omit "*/se/deps/*,*/dist-packages/*"
- python3-coverage html --omit "*/se/deps/*,*/dist-packages/*"
- python3-coverage xml --omit "*/se/deps/*,*/dist-packages/*"
- mv /var/log/sosse log
- exit $failed
.functional_tests: &functional_tests
image: biolds/sosse:pip-test
stage: test
needs:
- doc_code_extract
artifacts:
when: always
paths:
- tests/robotframework/screenshots/*
- tests/robotframework/*.html
- log/*
script:
- make _pip_functional_tests
- (make _rf_functional_tests ; echo -n $? > /tmp/ret_code) || true
- mv /var/log/sosse log
- test "$(cat /tmp/ret_code)" -eq 0
functional_tests_chromium:
<<: *functional_tests
variables:
BROWSER: chromium
functional_tests_firefox:
<<: *functional_tests
variables:
BROWSER: firefox
migrations:
image: biolds/sosse:debian-test
stage: test
script:
- apt update
- 'grep ^Depends: debian/control | sed -e "s/.*},//" -e "s/,//g" | xargs apt install -y'
- /etc/init.d/postgresql start
- export PYTHONPATH="$CI_PROJECT_DIR"
- chown www-data:www-data -R /var/log/sosse
- /tmp/sudo_sosse default_conf | sed -e "s/^#db_pass=.*/db_pass=sosse/" -e "s/^#debug=.*/debug=true/" > /etc/sosse/sosse.conf
- MIGRATION_COUNT="$(ls se/migrations/*.py|grep '/[0-9]'|wc -l)"
- python3 ./sosse/sosse_admin.py makemigrations
- MIGRATION_COUNT2="$(ls se/migrations/*.py|grep '/[0-9]'|wc -l)"
- test "$MIGRATION_COUNT" -eq "$MIGRATION_COUNT2"
static_checks:
image: biolds/sosse:debian-test
stage: test
script:
- make static_checks
doc_gen:
image: biolds/sosse:debian-test
stage: test
artifacts:
paths:
- doc/source/*_generated.rst
- doc/source/*/*_generated.rst
- doc/source/CHANGELOG.md
- doc/source/introduction.md
script:
- make doc_gen
doc_code_extract:
image: biolds/sosse:doc
stage: test
needs:
- doc_gen
artifacts:
paths:
- doc/code_blocks.json
script:
- sed -e 's/|[^|]*| //g' -e 's/^.. \(image\|figure\)::.*//' -i $(find doc -name \*.rst)
- make _build_doc
doc:
image: biolds/sosse:doc
stage: doc
artifacts:
paths:
- doc/build/*
needs:
- doc_gen
- functional_tests_chromium
#- functional_tests_firefox -> commenteed because only the artifacts (screenshot) from Chromium are needed
script:
- make _build_doc
- test -n "$RTD_TOKEN" && curl -X POST -d "branches=main" -d "token=$RTD_TOKEN" -d "default_branch=main" https://readthedocs.org/api/v2/webhook/sosse/236935/ || true
pip_pkg:
image: biolds/sosse:pip-test
artifacts:
paths:
- dist/*
stage: build
needs:
- doc
- migrations
- unit_tests
- functional_tests_chromium
- functional_tests_firefox
- static_checks
script:
- sed -e "s/^SOSSE_VERSION_TAG = .*/SOSSE_VERSION_TAG = '${CI_COMMIT_TAG/v/}'/" -i sosse/settings.py
- sed -e "s/^SOSSE_VERSION_COMMIT = .*/SOSSE_VERSION_COMMIT = '${CI_COMMIT_SHORT_SHA}'/" -i sosse/settings.py
- make _pip_pkg
debian_pkg:
image: biolds/sosse:debian-pkg
#image: registry.gitlab.com/biolds1/sosse/debian-pkg:latest
stage: build
needs:
- doc
- migrations
- unit_tests
- functional_tests_chromium
- functional_tests_firefox
- static_checks
artifacts:
paths:
- deb/*.deb
script:
- cd "$CI_PROJECT_DIR"
- rm -rf htmlcov
- sed -e "s/^SOSSE_VERSION_TAG = .*/SOSSE_VERSION_TAG = '${CI_COMMIT_TAG/v/}'/" -i sosse/settings.py
- sed -e "s/^SOSSE_VERSION_COMMIT = .*/SOSSE_VERSION_COMMIT = '${CI_COMMIT_SHORT_SHA}'/" -i sosse/settings.py
- mkdir /deb
- make _deb
- mv /deb .
changelog:
image: biolds/sosse:debian-test
stage: build
needs: []
artifacts:
paths:
- CHANGELOG.md
variables:
GIT_DEPTH: 0 # disable sahllow cloning since the step requires all tags
script:
- 'last_ver="$(git tag -l | sort -V | tail -n 1 | sed -e "s/^v//")"'
- 'new_ver="${last_ver%.*}.$((${last_ver/*./} + 1))"'
- echo "$last_ver / $new_ver"
- 'curl -X GET -H "PRIVATE-TOKEN: $GITLAB_REST_API_CHANGELOG" "https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/repository/changelog?version=$new_ver" | jq -r .notes | tee /tmp/new'
- cat /tmp/new CHANGELOG.md > new.md && mv new.md CHANGELOG.md
doc_test_debian:
image: debian:bookworm
stage: build_check
needs:
- doc_code_extract
script:
- apt update
- apt install -y make jq
- make _doc_test_debian
doc_test_pip:
image: debian:bookworm
stage: build_check
needs:
- doc_code_extract
script:
- apt update
- apt install -y make jq
- make _doc_test_pip
.debian_pkg_check: &debian_pkg_check
image: debian:bookworm
stage: build_check
artifacts:
when: always
paths:
- tests/robotframework/screenshots/*
- tests/robotframework/*.html
- log/*
needs:
- doc_code_extract
- debian_pkg
script:
- apt update
- apt install -y jq make virtualenv
- make _deb_pkg_functional_tests
- (make _rf_functional_tests ; echo -n $? > /tmp/ret_code) || true
- mv /var/log/sosse log
- test "$(cat /tmp/ret_code)" -eq 0
debian_pkg_check_chromium:
<<: *debian_pkg_check
variables:
BROWSER: chromium
debian_pkg_check_firefox:
<<: *debian_pkg_check
variables:
BROWSER: firefox
.pip_pkg_check: &pip_pkg_check
image: biolds/sosse:pip-test
stage: build_check
artifacts:
when: always
paths:
- tests/robotframework/screenshots/*
- tests/robotframework/*.html
- log/*
needs:
- doc_code_extract
- pip_pkg
script:
- make _pip_pkg_functional_tests
- (make _rf_functional_tests ; echo -n $? > /tmp/ret_code) || true
- mv /var/log/sosse log
- test "$(cat /tmp/ret_code)" -eq 0
pip_pkg_check_chromium:
<<: *pip_pkg_check
variables:
BROWSER: chromium
pip_pkg_check_firefox:
<<: *pip_pkg_check
variables:
BROWSER: firefox
discord_tag_notif:
image: debian:bookworm
stage: notif
allow_failure: true
rules:
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/'
needs:
- doc_gen
- pip_pkg
- debian_pkg_check_chromium
- debian_pkg_check_firefox
script: |
test -n "$DISCORD_TAG_NOTIF_URL"
apt update
apt install -y jq curl make
changelog="$(grep -v '^# Changelog' < doc/source/CHANGELOG.md | sed '/^$/Q' | sed -e 's#(\(https\?://[^)]*\))#(<\1\>)#g')"
msg="$(jq -n --arg tag "$CI_COMMIT_TAG" --arg changelog "$changelog" '{"content": ($tag + " was just released! 🎉\n\n" + $changelog)}')"
curl -X POST -H 'Content-Type: application/json' -d "$msg" "$DISCORD_TAG_NOTIF_URL"