-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
174 lines (156 loc) · 4.08 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
# TODO: refactor configuration (username, pass...)
# TODO: do not delete migrations
variables:
IMAGE: $CI_REGISTRY_IMAGE
DOCKER_DRIVER: overlay2
MYSQL_HOST: mysql-mysql-server
MYSQL_USER: resel
MYSQL_PASSWORD: blah
MYSQL_DATABASE: resel
MYSQL_ROOT_PASSWORD: blah
MYSQL_ROOT_HOST: '%'
REDIS_HOST: redis
MYSQL_QOS_DATABASE: qos
MYSQL_QOS_HOST: mysql-mysql-server
MYSQL_QOS_USER: root
MYSQL_QOS_PASSWORD: blah
ROOTDIR: ./
CONFDIR: myresel/
ETCDIR: .install/etc/
LIBDIR: .install/lib/
LDAP_PASSWORD: blah
LAPUTEX_HOST: http:\/\/laputex\/
#LAPUTEX_PWD in gitlab secrets
DEBIAN_FRONTEND: noninteractive
image: $IMAGE:latest
services:
- redis:stretch
- mysql/mysql-server:5.7
stages:
- docker_build
- docker_push
- configure
- test
- deploy
before_script:
# - source .install/scripts/install_essentials.sh no-upgrade
- source .install/scripts/install_essentials.sh
- apt-get install -qq default-mysql-client
- echo "CREATE DATABASE ${MYSQL_QOS_DATABASE}" | mysql -u${MYSQL_QOS_USER} -p${MYSQL_QOS_PASSWORD} -h ${MYSQL_QOS_HOST}
- source .install/scripts/install_openldap.sh
# - source .install/scripts/install_latex.sh
- pip3 install --break-system-packages -qUr requirements.txt
- rm -f -- ${ROOTDIR}myresel/settings_local.py
- export MYSQL_USER=root
- source .install/scripts/configure.sh
- source .install/scripts/populate_db.sh
- python3 manage.py populate_redis
- python3 manage.py calculate_free_ip
- python3 manage.py rqworker &
- python3 manage.py rqscheduler &
Build docker image:
stage: docker_build
image: $DOCKER_IMAGE
services:
- name: $RUNNER_IMAGE
alias: docker
before_script: &before_script
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
script:
- docker build -t $IMAGE:$CI_COMMIT_SHA --build-arg LDAPPASSWD=$LDAP_PASSWORD .
- docker push $IMAGE:$CI_COMMIT_SHA
only:
changes:
- Dockerfile
tags:
- admin
Push docker image:
stage: docker_push
image: $DOCKER_IMAGE
services:
- name: $RUNNER_IMAGE
alias: docker
before_script: *before_script
script:
- docker pull $IMAGE:$CI_COMMIT_SHA
- docker tag $IMAGE:$CI_COMMIT_SHA $IMAGE:latest
- docker push $IMAGE:latest
only:
changes:
- Dockerfile
tags:
- admin
django test suite:
stage: test
artifacts:
paths:
- htmlcov/
- myresel/settings_local.py
- wiki/migrations/
- tresorerie/migrations/
- pages/migrations/
- gestion_personnes/migrations/
- devices/migrations/
script:
- coverage run --rcfile=.coveragerc manage.py test --noinput
- coverage report
- coverage html
- grep pc_cov htmlcov/index.html | egrep -o "[0-9]+\%" | awk '{ print "covered " $1;}'
tags:
- admin
python linting:
stage: test
script:
- pylint --rcfile=.pylintrc --django-settings-module=myresel.settings campus fonctions gestion_personnes ldapback maisel myresel pages tresorerie wiki || exit $((35 & $?))
allow_failure: false
tags:
- admin
deploy to staging:
services: []
before_script:
- apt-get install -qq openssh-client
- eval $(ssh-agent -s)
- bash -c 'ssh-add <(echo "${STAGING_DEPLOY_KEY}")'
stage: deploy
script:
- ssh -o "StrictHostKeyChecking=no" -T deploy@flea
only:
- master
environment:
name: staging flea
url: https://dev.resel.fr/
tags:
- admin
deploy to brest:
stage: deploy
services: []
before_script:
- apt-get install -qq openssh-client
- eval $(ssh-agent -s)
- bash -c 'ssh-add <(echo "${SKYNET_DEPLOY_KEY}")'
script:
- ssh -o "StrictHostKeyChecking=no" -T deploy@skynet
only:
- deploy
environment:
name: skynet
url: https://resel.fr/
tags:
- admin
deploy to rennes:
stage: deploy
services: []
allow_failure: true
before_script:
- apt-get install -qq openssh-client
- eval $(ssh-agent -s)
- bash -c 'ssh-add <(echo "${DOUBIDOU_DEPLOY_KEY}")'
script:
- ssh -o "StrictHostKeyChecking=no" -T deploy@doubidou
only:
- deploy
environment:
name: doubidou
url: https://rennes.resel.fr/
tags:
- admin