forked from vstconsulting/polemarch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
177 lines (165 loc) · 4.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
# set to local images because too long execution
default:
image: vstconsulting/images:build
variables:
GET_SOURCES_ATTEMPTS: 3
ARTIFACT_DOWNLOAD_ATTEMPTS: 3
RESTORE_CACHE_ATTEMPTS: 3
DJANGO_LOG_LEVEL: 'DEBUG'
TOX_ARGS: "--workdir /cache/.tox_polemarch_${CI_BUILD_REF_NAME}"
CCACHE_DIR: /cache/.ccache
CC: ccache gcc
DOCKER_DRIVER: "overlay2"
REGISTRY_IMAGE: "${CI_REGISTRY_IMAGE}"
REGISTRY_IMAGE_TAG: "${KUBE_NAMESPACE}"
REGISTRY_USER: "${CI_REGISTRY_USER}"
REGISTRY_PASSWORD: "${CI_REGISTRY_PASSWORD}"
REGISTRY_URL: "${CI_REGISTRY}"
DOCKER_TLS_CERTDIR: ""
DOCKER_HOST: "tcp://docker_service_host:2375"
K8S_INGRESS_DOMAIN: "polemarch-$KUBE_NAMESPACE.$KUBE_INGRESS_BASE_DOMAIN"
stages:
- code_standarts
- build
- test
- packaging-test
- release
- publish
# Test templates
###########################################
.branch_tests_template: &branch_tests
stage: test
image: vstconsulting/images: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:
- tox -e $TOX_ENVS $TOX_ARGS
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
when: on_success
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" || $CI_PIPELINE_SOURCE == "external_pull_request_event"'
when: on_success
- if: '$CI_PIPELINE_SOURCE == "web" && $CI_COMMIT_TAG == null'
when: on_success
- when: never
# Branch tests
###########################################
code_style:
<<: *branch_tests
stage: code_standarts
variables:
TOX_ENVS: "flake,pylint"
py38-coverage:
<<: *branch_tests
variables:
TOX_ENVS: "$CI_BUILD_NAME"
py36-install:
<<: *branch_tests
variables:
TOX_ENVS: "$CI_BUILD_NAME"
# Realese
###########################################
#deploy_environment:
# stage: release
# image: vstconsulting/images:tox
# services:
# - name: "docker:19.03-dind"
# alias: "docker_service_host"
# script:
# - tox -e deploy_env
# environment:
# name: review/$CI_COMMIT_REF_NAME
# on_stop: delete_environment
# url: http://polemarch-$KUBE_NAMESPACE.$KUBE_INGRESS_BASE_DOMAIN
# only:
# kubernetes: active
# refs:
# - branches
# when: manual
#
#delete_environment:
# stage: release
# image: vstconsulting/images:tox
# script:
# - tox -e destroy_env
# environment:
# name: review/$CI_COMMIT_REF_NAME
# action: stop
# only:
# kubernetes: active
# refs:
# - branches
# when: manual
release:
stage: release
image: vstconsulting/images:tox
rules:
- if: '$CI_COMMIT_BRANCH == "master" && $GIT_ACCESS_USER && $GIT_ACCESS_PASSWORD'
when: on_success
- when: never
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
pages:
stage: release
script:
- tox -e builddoc $TOX_ARGS
- mv doc/_build/html public
artifacts:
paths:
- public
rules:
- if: '$CI_COMMIT_BRANCH == "developer" && $GIT_ACCESS_USER && $GIT_ACCESS_PASSWORD'
when: always
- when: never
release_pypi:
stage: release
image: vstconsulting/images:build
rules:
- if: '$CI_COMMIT_TAG && $PYPI_UPLOAD_PASSWORD && $PYPI_UPLOAD_NAME'
when: on_success
allow_failure: true
- when: never
variables:
TOX_ARGS: ""
script:
- tox -e build $TOX_ARGS
- twine upload -u ${PYPI_UPLOAD_NAME} -p ${PYPI_UPLOAD_PASSWORD} $(find dist/*.{tar.gz,whl})
artifacts:
name: "release-packages-${CI_BUILD_REF_NAME}.${CI_BUILD_ID}"
paths:
- dist/
publish_docker:
stage: publish
image: vstconsulting/images:tox
services:
- name: 'docker:19.03-dind'
alias: 'docker_service_host'
script:
- pip install tox
- tox -e release-docker
rules:
- if: '$CI_COMMIT_TAG && $POLEMARCH_DOCKER_USER && $POLEMARCH_DOCKER_PASSWORD && $POLEMARCH_DOCKER_EMAIL && $POLEMARCH_DOCKER_IMAGE_NAME'
when: on_success
- when: never
publish_release:
stage: publish
image: vstconsulting/images:tox
allow_failure: true
needs: ["release_pypi"]
rules:
- if: '$CI_COMMIT_TAG && $PYPI_UPLOAD_PASSWORD && $PYPI_UPLOAD_NAME'
when: on_success
- when: never
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} || echo "Failed to upload to github."
script:
- tox -e release