forked from vstconsulting/polemarch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
224 lines (208 loc) · 4.69 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
# 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
# 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
py37-coverage:
<<: *branch_tests
variables:
TOX_ENVS: "$CI_BUILD_NAME"
allow_failure: true
py36-install:
<<: *branch_tests
variables:
TOX_ENVS: "$CI_BUILD_NAME"
master_coverage:
<<: *branch_tests
variables:
TOX_ENVS: "py37-coverage"
except:
only:
refs:
- master
# Realese
###########################################
review_environment:
stage: release
image: onegreyonewhite/tox:tox
variables:
INSTANCE_NAME: "${CI_COMMIT_REF_NAME}"
TOX_ARGS: "--workdir /cache/.tox_polemarch"
before_script:
- source $OPENSTACKRC
- chmod 0600 $OPENSTACK_KEY
- chmod 0600 $CI_PROJECT_DIR
script:
- make test ENVS=deploy
environment:
name: "${CI_COMMIT_REF_NAME}"
on_stop: delete_environment
only:
variables:
- $OPENSTACKRC
- $OPENSTACK_KEY
when: manual
delete_environment:
stage: release
image: onegreyonewhite/tox:tox
variables:
INSTANCE_NAME: "${CI_COMMIT_REF_NAME}"
INSTANCE_DELETE: "yes"
TOX_ARGS: "--workdir /cache/.tox_polemarch"
before_script:
- source $OPENSTACKRC
script:
- make test ENVS=destroy
environment:
name: "${CI_COMMIT_REF_NAME}"
action: stop
when: manual
pages:
stage: release
script:
- make test ENVS=builddoc
- mv doc/_build/html public
artifacts:
paths:
- public
only:
refs:
- developer
when: always
release:
stage: release
image: onegreyonewhite/tox:tox
only:
refs:
- master
variables:
- $GIT_ACCESS_USER
- $GIT_ACCESS_PASSWORD
before_script:
- url_host=`echo "${CI_REPOSITORY_URL}" | sed -e "s/https:\/\/gitlab-ci-token:.*@//g"`
- git config --global user.name "${GITLAB_USER_NAME}"
- git config --global user.email "${GITLAB_USER_EMAIL}"
- git remote set-url origin "https://${GIT_ACCESS_USER}:${GIT_ACCESS_PASSWORD}@${url_host}"
script:
- bash autorelease.sh
release_pypi:
stage: release
image: onegreyonewhite/tox:centos6
only:
refs:
- tags
variables:
- $PYPI_UPLOAD_PASSWORD
- $PYPI_UPLOAD_NAME
variables:
TOX_ARGS: ""
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:tox
only:
refs:
- tags
variables:
- $PYPI_UPLOAD_PASSWORD
- $PYPI_UPLOAD_NAME
script:
- twine upload -u ${PYPI_UPLOAD_NAME} -p ${PYPI_UPLOAD_PASSWORD} dist/*.tar.gz dist/*.whl
publish_release:
stage: publish
image: onegreyonewhite/tox:ubuntu
allow_failure: true
only:
refs:
- tags
variables:
- $PYPI_UPLOAD_PASSWORD
- $PYPI_UPLOAD_NAME
variables:
TOX_ARGS: ""
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