-
Notifications
You must be signed in to change notification settings - Fork 89
/
.gitlab-ci.yml
177 lines (162 loc) · 5.31 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: registry.gitlab.com/vstconsulting/images:ubuntu-v2
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"
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
stages:
- code_standarts
- build
- test
- packaging-test
- release
- publish
# Test templates
###########################################
.branch_tests_template: &branch_tests
stage: test
image: registry.gitlab.com/vstconsulting/images:ubuntu-v2
coverage: '/\d+\%\s*$/'
variables:
TOX_ENVS: ""
YARN_CACHE_FOLDER: "${CI_PROJECT_DIR}/yarn"
before_script:
- >
if [ "${CI_COMMIT_REF_NAME}" != "master" -a "${CI_COMMIT_REF_NAME}" != "developer" ]; then
export TOX_ARGS="--workdir /tmp/.tox_polemarch_${CI_COMMIT_REF_NAME}";
unset BUILD_OPTIMIZATION;
fi
- if [ "${TOX_ENVS}" ]; then export TOX_ARGS="${TOX_ARGS} -e ${TOX_ENVS}"; fi
script:
- tox $TOX_ARGS
rules:
- if: '$CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH =~ /^release_/'
when: on_success
- if: '($CI_COMMIT_BRANCH != "master" && $CI_COMMIT_BRANCH !~ /^release_/) && ($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
.js_tests_template: &branch_js_tests
<<: *branch_tests
image: registry.gitlab.com/vstconsulting/images:node18-tests
before_script:
- yarn install --pure-lockfile --mutex network
script:
- yarn test
# Branch tests
###########################################
code_style:
<<: *branch_tests
stage: code_standarts
parallel:
matrix:
- TOX_ENVS:
- flake
- pylint
js_style:
<<: *branch_js_tests
stage: code_standarts
script:
- yarn lint
functional_test:
<<: *branch_tests
parallel:
matrix:
- TOX_ENVS:
- py38-install
- TOX_ENVS:
- py311-coverage
# Realese
###########################################
release:
stage: release
image: registry.gitlab.com/vstconsulting/images:ubuntu-v2
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: registry.gitlab.com/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 -c tox_build.ini $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: registry.werf.io/werf/werf
before_script:
- type werf && source $(werf ci-env gitlab --as-file)
- werf version
script:
- werf cr login -u $POLEMARCH_DOCKER_USER -p $POLEMARCH_DOCKER_PASSWORD index.docker.io
- werf export --repo=$WERF_REPO/storage --tag=$WERF_REPO:$CI_COMMIT_TAG --tag=index.docker.io/$POLEMARCH_DOCKER_IMAGE_NAME:$CI_COMMIT_TAG
- werf export --repo=$WERF_REPO/storage --tag=$WERF_REPO:latest --tag=index.docker.io/$POLEMARCH_DOCKER_IMAGE_NAME:latest
after_script:
- werf cr login -u nobody -p ${WERF_IMAGES_CLEANUP_PASSWORD} ${CI_REGISTRY}
- werf cleanup --repo=$WERF_REPO/storage
rules:
- if: '$CI_COMMIT_TAG && $POLEMARCH_DOCKER_USER && $POLEMARCH_DOCKER_PASSWORD && $POLEMARCH_DOCKER_IMAGE_NAME && $WERF_IMAGES_CLEANUP_PASSWORD'
when: on_success
- when: never
publish_release:
stage: publish
image: registry.gitlab.com/vstconsulting/images:ubuntu-v2
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