forked from neogeo-technologies/geocontrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
114 lines (104 loc) · 2.89 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
stages:
- test
- Static analysis
- build
- deploy
variables:
SONAR_PROJECTKEY: "$CI_PROJECT_NAME"
SONAR_HOST_URL: "https://sonarqube.neogeo.fr"
SONAR_LOGIN: $SONAR_TOKEN
GIT_DEPTH: 0
# Used to configure CI Test
POSTGRES_DB: geocontrib
POSTGRES_USER: geocontrib
POSTGRES_PASSWORD: geocontrib
POSTGRES_HOST_AUTH_METHOD: trust
build testing docker image:
stage: build
only:
- develop
tags:
- build_docker
variables:
DOCKER_TAG: testing
script:
- cat $DOCKER_PASSWORD | docker login --username $DOCKER_LOGIN --password-stdin
- cd docker
- docker-compose build geocontrib
- docker-compose push geocontrib
- echo Image docker neogeo/geocontrib:${DOCKER_TAG} livrée
deploy testing docker image:
stage: deploy
only:
- develop
tags:
- build
image:
name: curlimages/curl
script:
- curl -X POST -F token=$TRIGGER_TOKEN -F ref=main https://git.neogeo.fr/api/v4/projects/226/trigger/pipeline
build stable docker image:
stage: build
only:
- master
tags:
- build_docker
variables:
DOCKER_TAG: latest
script:
- cat $DOCKER_PASSWORD | docker login --username $DOCKER_LOGIN --password-stdin
- cd docker
- docker-compose build geocontrib
- docker-compose push geocontrib
- echo Image docker neogeo/geocontrib:${DOCKER_TAG} livrée
build tagged docker image:
stage: build
only:
- tags
tags:
- build_docker
variables:
DOCKER_TAG: $CI_COMMIT_TAG
script:
# Don't build tag id package.json as wrong version
- grep "__version__ = '$CI_COMMIT_TAG'" geocontrib/__init__.py
- cat $DOCKER_PASSWORD | docker login --username $DOCKER_LOGIN --password-stdin
- cd docker
- docker-compose build geocontrib
- docker-compose push geocontrib
- echo Image docker neogeo/geocontrib:${DOCKER_TAG} livrée
sonarqube-check:
image:
name: sonarsource/sonar-scanner-cli:latest
entrypoint: [""]
only:
- develop
stage: Static analysis
dependencies:
- test
allow_failure: true
script:
- sonar-scanner -Dsonar.qualitygate.wait=true -Dsonar.projectKey=$CI_PROJECT_NAME -Dsonar.projectName=$CI_PROJECT_NAME -Dsonar.projectVersion=$CI_COMMIT_BRANCH -Dsonar.cpd.exclusions=api/**/deprecated/**/*
test:
stage: test
image: python:3.7
services:
- redis
- postgis/postgis
variables:
REDIS_HOST: "redis"
DB_HOST: "postgis-postgis"
before_script:
- apt update && apt install -y --no-install-recommends libproj-dev gdal-bin
script:
- pip install -r requirements-dev.txt -r requirements.txt
- django-admin startproject config .
- cp -r config_sample/* config/
- ./manage.py check
- ./manage.py makemigrations --check
- pytest --junitxml=xunit-reports/xunit-result-pytest.xml --cov-report xml:coverage-reports/coverage-pytest.xml --cov .
artifacts:
paths:
- coverage-reports/
- xunit-reports/
expire_in: 1 week