-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitlab-ci.yml
145 lines (133 loc) · 2.98 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
stages:
- build
- test
- deploy
static:
image: node:20-slim
stage: build
cache:
key: npm-$CI_COMMIT_REF_SLUG
paths:
- "$CI_PROJECT_DIR/.npm-cache"
before_script:
- apt update && apt install --yes curl
script:
- npm ci --cache .npm-cache --prefer-offline
- npm run build
artifacts:
name: '$CI_JOB_ID-node_modules'
paths:
- ./node_modules
- ./static/build
expire_in: 2 hours
pip:
image: python:3.12-slim
stage: build
variables:
PIP_CACHE_DIR: $CI_PROJECT_DIR/.pip-cache
cache:
key: pip-$CI_COMMIT_REF_SLUG
paths:
- "$CI_PROJECT_DIR/.pip-cache"
before_script:
- apt-get update --yes
- apt-get install --yes build-essential libpq-dev git
script:
- python -m venv env
- source env/bin/activate
- pip install -r dev-requirements.txt
artifacts:
name: 'venv-$CI_JOB_ID'
paths:
- ./env/
expire_in: 2 hours
.python_test_template:
image: python:3.12-slim
stage: test
dependencies:
- pip
before_script:
- source env/bin/activate
variables:
SECRET_KEY: super-secret
test_python:
extends: .python_test_template
services:
- postgres:14-alpine
variables:
POSTGRES_HOST_AUTH_METHOD: trust
DATABASE_URL: postgres://postgres@postgres/postgres
TEST: "true"
script:
- apt-get update && apt-get install --yes git libpq-dev
- ./manage.py collectstatic --noinput --clear
- coverage run ./manage.py test
- coverage report
- coverage xml
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
dependencies:
- pip
- static
django_checks:
extends: .python_test_template
dependencies:
- pip
- static
script:
- apt-get update && apt-get install --yes libpq-dev
- ./manage.py collectstatic --noinput --clear
- ./manage.py check
- ./manage.py makemigrations --check --noinput
black:
extends: .python_test_template
script:
- black --check .
ruff:
extends: .python_test_template
script:
- ruff check .
mypy:
extends: .python_test_template
script:
- mypy .
djlint:
extends: .python_test_template
script:
- djlint website/ --lint --check
npm_lint:
image: node:20-slim
stage: test
dependencies:
- static
script:
- npm run lint
crontab:
image: alpine
stage: test
dependencies: []
before_script:
- apk add --no-cache supercronic
script:
- supercronic -test etc/crontab
container:
image: docker:stable
services:
- docker:dind
variables:
DEV_IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
PROD_IMAGE_TAG: $CI_REGISTRY_IMAGE:latest
DOCKER_BUILDKIT: 1
dependencies: []
stage: deploy
only:
- master
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
script:
- docker build --target production -t $DEV_IMAGE_TAG -t $PROD_IMAGE_TAG .
- docker push $CI_REGISTRY_IMAGE