-
-
Notifications
You must be signed in to change notification settings - Fork 127
/
.gitlab-ci.yml
75 lines (71 loc) · 2.46 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
stages:
- build_test
- test
- deploy
include:
- template: SAST.gitlab-ci.yml
build:
stage: build_test
image: docker
services:
- docker:dind
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
script:
- CI_COMMIT_REF_NAME_SANITIZED=${CI_COMMIT_REF_NAME/\#/-}
- CI_COMMIT_REF_NAME_SANITIZED=${CI_COMMIT_REF_NAME_SANITIZED//\//-}
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME_SANITIZED || true
- docker build --cache-from $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME_SANITIZED --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME_SANITIZED .
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME_SANITIZED
test:
stage: build_test
image: python:3.10
variables:
DJANGO_SECRET_KEY: abcdef
TEST_DATABASE_URL: postgis://kobo:kobo@postgres:5432/kobocat_test
REDIS_SESSION_URL: redis://redis_cache:6379/2
CACHE_URL: redis://redis_cache:6379/3
USE_POSTGRESQL: "True"
POSTGRES_USER: kobo
POSTGRES_PASSWORD: kobo
POSTGRES_DB: kobocat_test
SERVICE_ACCOUNT_BACKEND_URL: redis://redis_cache:6379/4
ENKETO_REDIS_MAIN_URL: redis://redis_cache:6379/0
services:
- name: postgis/postgis:14-3.2
alias: postgres
- name: redis:6.2
alias: redis_cache
script:
- apt-get update && apt-get install -y ghostscript gdal-bin libproj-dev gettext openjdk-17-jre
- pip install -r dependencies/pip/dev_requirements.txt
- pytest -vv -rf
deploy-beta:
stage: deploy
image:
name: alpine/helm:3.12.0
entrypoint: [""]
script:
- helm repo add kobo https://gitlab.com/api/v4/projects/32216873/packages/helm/stable
- helm -n kobo-dev upgrade beta kobo/kobo --atomic --set-string kobocat.image.tag=${CI_COMMIT_SHORT_SHA} --reuse-values
environment:
name: beta
url: https://kc.beta.kobotoolbox.org
only:
refs:
- public-beta
- gitlab-ci-build
variables:
- $CI_COMMIT_REF_PROTECTED
deploy-staging:
stage: deploy
image:
name: alpine/helm
entrypoint: [""]
script:
- BRANCH_TITLE=${CI_COMMIT_BRANCH#feature/}
- helm repo add kobo https://gitlab.com/api/v4/projects/32216873/packages/helm/stable
- helm -n kobo-dev upgrade --install $BRANCH_TITLE kobo/kobo --atomic --set-string kobocat.image.tag=${CI_COMMIT_SHORT_SHA} --reuse-values
rules:
- if: $CI_COMMIT_BRANCH =~ /^(feature\/)/ && $CI_COMMIT_REF_PROTECTED