forked from digital-learning-lab/webplattform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
190 lines (177 loc) · 5.65 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
variables:
TEST_IMAGE_NAME: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_SLUG}
STAGING_IMAGE_NAME: ${CI_REGISTRY_IMAGE}:latest-staging
PRODUCTION_IMAGE_NAME: ${CI_REGISTRY_IMAGE}:release
STAGING_SOLR_IMAGE_NAME: ${CI_REGISTRY}/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}:solr-latest
RELEASE_SOLR_IMAGE_NAME: ${CI_REGISTRY}/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}:solr-release
DOCKER_FILE_PATH: .
stages:
- lint
- build
- test
- deploy
black:
stage: lint
image: python:3.10-slim
tags:
- dll-docker
before_script:
- pip install black
script:
- black --check .
rules:
- if: $CI_PIPELINE_SOURCE != "schedule" && $CI_PIPELINE_SOURCE != "merge_request_event"
test_python:
stage: test
image: ${TEST_IMAGE_NAME}
services:
- postgres:12-alpine
- name: ${STAGING_SOLR_IMAGE_NAME}
alias: solr
before_script:
- poetry install
script:
- coverage run --source=/code/dll/ -m pytest /code/dll/
- coverage report
tags:
- dll-docker
variables:
POSTGRES_DB: "postgres"
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: ""
POSTGRES_HOST_AUTH_METHOD: trust
REDIS_HOSTNAME: "redis"
DATABASE_USER: "postgres"
DATABASE_NAME: "postgres"
DATABASE_HOST: "postgres"
DJANGO_DEBUG: "True"
CELERY_TASK_ALWAYS_EAGER: "True"
SOLR_HOSTNAME: "solr"
EMAIL_HOST: "floki.rz.tuhh.de"
EMAIL_PORT: "25"
EMAIL_USE_TLS: "False"
EMAIL_SENDER: "j.doe@example.com"
CONTACT_EMAIL_BSB: "j.doe@example.com"
CONTACT_EMAIL_DLL: "j.doe@example.com"
META_SITE_PROTOCOL: https
META_SITE_DOMAIN: staging.digitallearninglab.de
DEFAULT_USER_EMAIL: digital.learning.lab@tuhh.de
rules:
- if: $CI_PIPELINE_SOURCE != "schedule" && $CI_PIPELINE_SOURCE != "merge_request_event"
test_collectstatic_s3:
stage: test
image: ${TEST_IMAGE_NAME}
tags:
- dll-docker
variables:
S3BACKEND: mem
POSTGRES_DB: "postgres"
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: ""
POSTGRES_HOST_AUTH_METHOD: trust
REDIS_HOSTNAME: "redis"
DATABASE_USER: "postgres"
DATABASE_NAME: "postgres"
DATABASE_HOST: "postgres"
DJANGO_DEBUG: "True"
CELERY_TASK_ALWAYS_EAGER: "True"
SOLR_HOSTNAME: "solr"
EMAIL_HOST: "floki.rz.tuhh.de"
EMAIL_PORT: "25"
EMAIL_USE_TLS: "False"
EMAIL_SENDER: "j.doe@example.com"
CONTACT_EMAIL_BSB: "j.doe@example.com"
CONTACT_EMAIL_DLL: "j.doe@example.com"
META_SITE_PROTOCOL: https
META_SITE_DOMAIN: staging.digitallearninglab.de
DEFAULT_USER_EMAIL: digital.learning.lab@tuhh.de
services:
- name: zenko/cloudserver
alias: s3.docker.test
before_script:
- apt-get update && apt-get install -y s3cmd
- s3cmd -c .test-s3cfg mb s3://dll
- poetry install
script:
- poetry run python manage.py collectstatic --no-input
rules:
- if: $CI_PIPELINE_SOURCE != "schedule" && $CI_PIPELINE_SOURCE != "merge_request_event"
register_staging_python_image:
stage: deploy
before_script:
- docker login -u gitlab-ci-token -p ${CI_JOB_TOKEN} ${CI_REGISTRY}
- docker pull ${TEST_IMAGE_NAME}
script:
- echo "Reached deployment stage. Retagging staging-test image for automatic deployment via keel."
- docker tag ${TEST_IMAGE_NAME} ${STAGING_IMAGE_NAME}
- docker push ${STAGING_IMAGE_NAME}
tags:
- dll-shell
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
when: never
- if: $CI_COMMIT_REF_NAME == "develop"
when: always
build_python_image:
stage: build
before_script:
- docker system prune -a -f
- docker login -u gitlab-ci-token -p ${CI_JOB_TOKEN} ${CI_REGISTRY}
script:
- docker build --no-cache -t ${TEST_IMAGE_NAME} ${DOCKER_FILE_PATH}
- docker push ${TEST_IMAGE_NAME}
tags:
- dll-shell
rules:
- if: $CI_PIPELINE_SOURCE != "schedule" && $CI_PIPELINE_SOURCE != "merge_request_event"
register_prod_python_image:
stage: deploy
before_script:
- docker login -u gitlab-ci-token -p ${CI_JOB_TOKEN} ${CI_REGISTRY}
script:
- docker tag ${TEST_IMAGE_NAME} ${PRODUCTION_IMAGE_NAME}
- docker push ${PRODUCTION_IMAGE_NAME}
tags:
- dll-shell
rules:
- if: $CI_COMMIT_REF_NAME == "master"
when: manual
build_solr_image:
stage: build
before_script:
- docker system prune -a -f
- docker login -u gitlab-ci-token -p ${CI_JOB_TOKEN} ${CI_REGISTRY}
script:
- docker build --no-cache -t ${STAGING_SOLR_IMAGE_NAME} ${DOCKER_FILE_PATH} -f Dockerfile.solr
- docker push ${STAGING_SOLR_IMAGE_NAME}
tags:
- dll-shell
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
when: never
- if: $CI_COMMIT_REF_NAME == "develop" || $CI_COMMIT_REF_NAME == "master"
when: always
register_prod_solr_image:
stage: deploy
before_script:
- docker login -u gitlab-ci-token -p ${CI_JOB_TOKEN} ${CI_REGISTRY}
script:
- docker tag ${STAGING_SOLR_IMAGE_NAME} ${RELEASE_SOLR_IMAGE_NAME}
- docker push ${RELEASE_SOLR_IMAGE_NAME}
tags:
- dll-shell
rules:
- if: $CI_COMMIT_REF_NAME == "master"
when: manual
update_deps:
stage: lint
image: renovate/renovate:latest
variables:
RENOVATE_PLATFORM: gitlab
RENOVATE_ENDPOINT: https://collaborating.tuhh.de/api/v4
RENOVATE_TOKEN: $GITLAB_ACCESS_TOKEN
RENOVATE_REPOSITORIES: itbh/tnt/digital-learning-lab/codebasis_plattform
RENOVATE_BASE_BRANCHES: develop
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
script: renovate