-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
99 lines (92 loc) · 2.18 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
stages:
- lint
- test
- quality
- build
- deploy
.all_branches: &all_branches
only:
- /^feature\/+[0-9](-[a-zA-Z0-9_]+)*/ # feature/76-Algum_nome_assim
- /^bugfix\/+[0-9](-[a-zA-Z0-9_]+)*/ # bugfix/76-Algum_nome_assim
- testes-software
- master
- develop
- tags # 0.1.0-rc.1
.protected_branches: &protected_branches
only:
- master
- develop
- tags
linting:
image: python:3.6
stage: lint
before_script:
- pip install pylint
script:
- pylint user_service/
- pylint settings/
allow_failure: true
<<: *all_branches
tests:
image: python:3.6
stage: test
services:
- postgres:latest
variables:
POSTGRES_DB: user_db
POSTGRES_USER: admin
POSTGRES_PASSWORD: admin
DB_HOST: postgres
DB_USER: admin
DB_PASS: admin
before_script:
- pip install pytest
- pip install -r requirements.txt
script:
- ./manage.py makemigrations
- ./manage.py migrate
- ./manage.py test
<<: *all_branches
radon:
image: python:3.6
stage: quality
before_script:
- pip install radon
script:
- radon mi -j user_service > mi.radon.json
- radon cc -j user_service > cc.radon.json
artifacts:
paths:
- '*.radon.json'
<<: *all_branches
build image:
stage: build
image: docker:stable
services:
- docker:stable-dind
variables:
VERSION: $CI_COMMIT_SHORT_SHA
before_script:
- docker login -u $DOCKER_USER -p $DOCKER_PASS
- |
if [ "$CI_COMMIT_REF_NAME" = "master" ];
then
export VERSION=stable
elif [ "$CI_COMMIT_REF_NAME" = "develop" ];
then
export VERSION=hm
fi
script:
- export IMAGE=$DOCKER_USER/$CI_PROJECT_NAME:$VERSION
- docker build -t $IMAGE .
- docker push $IMAGE
<<: *all_branches
deploy image:
stage: deploy
image: diemscott/rancher-cli-k8s:v2.0.2
script:
- echo 1 | rancher login -t "$RANCHER_API_TOKEN" "$RANCHER_SERVER_URL"
- rancher context switch "$CONTEXT_HOMOLOG"
- rancher kubectl -n homolog scale --current-replicas=1 --replicas=0 deployment/user-service
- rancher kubectl -n homolog scale --current-replicas=0 --replicas=1 deployment/user-service
<<: *protected_branches