This repository has been archived by the owner on May 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
227 lines (175 loc) · 5.93 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
stages:
- check
- test
- build
django-test:
image: carrotmanmatt/poetry:3.12
stage: test
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
tags:
- python
variables:
PIP_CACHE_DIR: ${CI_PROJECT_DIR}/.cache/pip
PRODUCTION: False
cache:
paths:
- .venv
- ${PIP_CACHE_DIR}
before_script:
- poetry install --no-root --with dev --no-interaction
script:
poetry run python manage.py test
mypy-test:
image: carrotmanmatt/poetry:3.12
stage: test
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
allow_failure: true
tags:
- python
variables:
PIP_CACHE_DIR: ${CI_PROJECT_DIR}/.cache/pip
cache:
paths:
- .venv
- .mypy_cache
- ${PIP_CACHE_DIR}
before_script:
- poetry install --no-root --with dev --no-interaction
script:
poetry run mypy .
ruff-test:
image: carrotmanmatt/poetry:3.12
stage: test
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
allow_failure: true
tags:
- python
variables:
PIP_CACHE_DIR: ${CI_PROJECT_DIR}/.cache/pip
cache:
paths:
- .venv
- .ruff_cache
- ${PIP_CACHE_DIR}
before_script:
- poetry install --no-root --with dev --no-interaction
script:
poetry run ruff check . --no-fix --extend-select TD002,TD003
djlint-test:
image: carrotmanmatt/poetry:3.12
stage: test
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
allow_failure: true
tags:
- python
variables:
PIP_CACHE_DIR: ${CI_PROJECT_DIR}/.cache/pip
cache:
paths:
- .venv
- ${PIP_CACHE_DIR}
before_script:
- poetry install --no-root --with dev --no-interaction
script:
poetry run djlint . --lint
asciidoctor-test:
image: python:3
stage: check
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
tags:
- python
before_script:
- apt-get update -y
- apt-get install -y --no-install-recommends asciidoctor
script:
- asciidoctor -v --failure-level=WARNING -w -o /dev/null README.adoc dev_docs/*.adoc
pre-commit-test:
image: carrotmanmatt/poetry:3.12
stage: check
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
tags:
- python
variables:
PRE_COMMIT_HOME: ${CI_PROJECT_DIR}/.cache/pre-commit
PIP_CACHE_DIR: ${CI_PROJECT_DIR}/.cache/pip
PRODUCTION: False
cache:
paths:
- .venv
- ${PRE_COMMIT_HOME}
- ${PIP_CACHE_DIR}
before_script:
- apt-get update -y
- apt-get install -y --no-install-recommends git
- poetry install --no-root --with dev --no-interaction
script:
poetry run pre-commit run --all-files
check-updated-tag:
image: python:3
stage: check
rules:
- if: $CI_COMMIT_TAG =~ /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
tags:
- python
variables:
PIP_CACHE_DIR: ${CI_PROJECT_DIR}/.cache/pip
cache:
paths:
- ${PIP_CACHE_DIR}
before_script:
- apt-get update -y
- pip install --upgrade pip
- echo "installing yq"
- pip install yq==3.2.3
- apt-get install -y --no-install-recommends jq
script:
- echo "ensuring version matches tag:$CI_COMMIT_TAG"
- tomlq --compact-output --raw-output '.tool.poetry.version' pyproject.toml | grep -q $CI_COMMIT_TAG
build-latest-docker-image:
stage: build
tags:
- docker
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
before_script:
- echo "logging in to registry:$CI_REGISTRY as $CI_REGISTRY_USER"
- docker login $CI_REGISTRY -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD
- echo "pulling most recent latest image for caching"
- docker pull $CI_REGISTRY_IMAGE:latest || true
script:
- echo "building docker image latest version:$CI_COMMIT_SHA"
- docker build --cache-from $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA .
- echo "pushing built images to GitLab repository"
- docker push $CI_REGISTRY_IMAGE:latest
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
build-stable-docker-image:
stage: build
tags:
- docker
rules:
- if: $CI_COMMIT_TAG =~ /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
when: manual
before_script:
- echo "logging in to registry:$CI_REGISTRY as $CI_REGISTRY_USER"
- docker login $CI_REGISTRY -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD
- echo "pulling most recent stable image for caching"
- docker pull $CI_REGISTRY_IMAGE:stable || true
script:
- echo "building docker image stable version:$CI_COMMIT_TAG"
- docker build --cache-from $CI_REGISTRY_IMAGE:stable --tag $CI_REGISTRY_IMAGE:stable --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG .
- echo "pushing built images to GitLab repository"
- docker push $CI_REGISTRY_IMAGE:stable
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG