forked from vstconsulting/polemarch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
278 lines (252 loc) · 6.01 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
# set to local images because too long execution
image: onegreyonewhite/tox:tox
variables:
TESTS: "polemarch.main.tests"
GET_SOURCES_ATTEMPTS: 3
ARTIFACT_DOWNLOAD_ATTEMPTS: 3
RESTORE_CACHE_ATTEMPTS: 3
DJANGO_LOG_LEVEL: 'ERROR'
TOX_ARGS: "--workdir /cache/.tox_polemarch_${CI_BUILD_REF_NAME}"
CCACHE_DIR: /cache/.ccache
CC: ccache gcc
stages:
- code_standarts
- build
- test
- packaging-test
- release
- publish
# Test templates
###########################################
.branch_tests_template: &branch_tests
stage: test
image: onegreyonewhite/tox:tox
variables:
TOX_ENVS: ""
before_script:
- if [ "${CI_BUILD_REF_NAME}" != "master" -a "${CI_BUILD_REF_NAME}" != "developer" ]; then export TOX_ARGS="--workdir /tmp/.tox_polemarchplus_${CI_BUILD_REF_NAME}"; fi
script:
- make test ENVS=$TOX_ENVS
- make build-clean
except:
refs:
- GUI
- master
- tags
- issue_building
only:
refs:
- merge_requests
- web
changes:
- polemarch/main/**/*
- polemarch/api/**/*
- tests.py
- setup.{py,cfg}
- MANIFEST.in
- requirements.txt
- requirements-test.txt
- Makefile
- tox.ini
- .coveragerc
- .gitlab-ci.yml
retry: 2
.pack_tamplate: &packing-test
stage: packaging-test
image: onegreyonewhite/tox:tox
variables:
MYSQL_ROOT_PASSWORD: 'polemarch'
MYSQL_DATABASE: 'polemarch'
MYSQL_USER: 'polemarch'
MYSQL_PASSWORD: 'polemarch'
services:
- name: 'mariadb:latest'
alias: 'db-server'
- name: 'redis'
alias: 'redis-server'
artifacts:
name: "package($CI_BUILD_NAME)"
expire_in: 1 hour
paths:
- dist/
allow_failure: false
only:
- master
- issue_building
retry: 2
# Branch tests
###########################################
code_style:
stage: code_standarts
image: onegreyonewhite/tox:tox
variables:
TOX_ARGS: "--workdir /cache/.tox_polemarch_code"
script:
- make test ENVS=flake,pylint
except:
refs:
- tags
- issue_building
only:
refs:
- merge_requests
- web
changes:
- polemarch/main/**/*
- polemarch/api/**/*
- requirements.txt
- Makefile
- tox.ini
- .pylintrc
- .pep8
retry: 2
py27-install:
<<: *branch_tests
variables:
TOX_ENVS: "$CI_BUILD_NAME"
py35-coverage:
<<: *branch_tests
variables:
TOX_ENVS: "$CI_BUILD_NAME"
py36-install:
<<: *branch_tests
variables:
TOX_ENVS: "$CI_BUILD_NAME"
master_coverage:
<<: *branch_tests
variables:
TOX_ENVS: "py36-coverage"
except:
only:
refs:
- master
####################################################
# DEPRECATED
.rpm_tests_tamplate: &packing-test-rpm_tests
<<: *packing-test
script:
- cat /etc/hosts
- tox ${TOX_ARGS} -c tox_build.ini -e py27-rpm RELEASE=${CI_BUILD_ID}
- sudo yum install dist/*.rpm -y -q
- sudo cat test_settings.ini > /etc/polemarch/settings.ini
- sudo chown polemarch:polemarch /etc/polemarch/settings.ini
- sudo -H -u polemarch /opt/polemarch/bin/pip install -r requirements-test.txt
- sudo -H -u polemarch /opt/polemarch/bin/polemarchctl test -v2 polemarch.main.tests --failfast
.deb_tests_tamplate: &packing-test-deb_tests
<<: *packing-test
image: onegreyonewhite/tox:ubuntu
script:
- cat /etc/hosts
- tox ${TOX_ARGS} -c tox_build.ini -e py27-deb RELEASE=${CI_BUILD_ID} RELOCATE_BIN=/usr/local/bin/venvctrl-relocate
- echo "echo 'hello'" > /bin/systemctl
- sudo apt update
- sudo apt install ./dist/*.deb -y -q
- sudo cat test_settings.ini > /etc/polemarch/settings.ini
- sudo chown polemarch:polemarch /etc/polemarch/settings.ini
- sudo -H -u polemarch /opt/polemarch/bin/pip install -r requirements-test.txt
- sudo -H -u polemarch /opt/polemarch/bin/polemarchctl test -v2 polemarch.main.tests --failfast
default_rpm_tests:
<<: *packing-test-rpm_tests
default_deb_tests:
<<: *packing-test-deb_tests
developer_rpm_tests:
<<: *packing-test-rpm_tests
stage: release
only:
refs:
- developer
when: manual
allow_failure: true
developer_deb_tests:
<<: *packing-test-deb_tests
stage: release
only:
refs:
- developer
when: manual
allow_failure: true
# Realese
###########################################
pages:
stage: release
script:
- make test ENVS=builddoc
- mv doc/_build/html public
artifacts:
paths:
- public
only:
refs:
- developer
when: always
release_pypi:
stage: release
image: onegreyonewhite/tox:centos6
only:
refs:
- tags
variables:
- $PYPI_UPLOAD_PASSWORD
script:
- make test ENVS=build
allow_failure: true
artifacts:
name: "release-rpm-${CI_BUILD_REF_NAME}.${CI_BUILD_ID}"
paths:
- dist/
publish_pypi:
stage: publish
image: onegreyonewhite/tox:ubuntu
only:
refs:
- tags
variables:
- $PYPI_UPLOAD_PASSWORD
script:
- twine upload -u ${PYPI_UPLOAD_NAME} -p ${PYPI_UPLOAD_PASSWORD} dist/*.tar.gz dist/*.whl
# DEPRECATED
#release_rpm:
# stage: release
# only:
# refs:
# - tags
# variables:
# - $PYPI_UPLOAD_PASSWORD
# script:
# - tox ${TOX_ARGS} -c tox_build.ini -e py27-rpm
# allow_failure: false
# artifacts:
# name: "release-rpm-${CI_BUILD_REF_NAME}.${CI_BUILD_ID}"
# paths:
# - dist/
# DEPRECATED
#release_deb:
# stage: release
# only:
# refs:
# - tags
# variables:
# - $PYPI_UPLOAD_PASSWORD
# image: onegreyonewhite/tox:ubuntu
# script:
# - tox ${TOX_ARGS} -c tox_build.ini -e py27-deb
# allow_failure: false
# artifacts:
# name: "release-deb-${CI_BUILD_REF_NAME}.${CI_BUILD_ID}"
# paths:
# - dist/
publish_release:
stage: publish
image: onegreyonewhite/tox:ubuntu
allow_failure: true
only:
refs:
- tags
variables:
- $PYPI_UPLOAD_PASSWORD
before_script:
- git config --global user.name "${GITLAB_USER_NAME}"
- git config --global user.email "${GITLAB_USER_EMAIL}"
- git push https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/vstconsulting/polemarch.git "${CI_COMMIT_TAG}"
script:
- make test ENVS=release