-
Notifications
You must be signed in to change notification settings - Fork 3
/
.gitlab-ci.yml
88 lines (81 loc) · 2.35 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
image: sinntern/ubuntu_for_django:latest
variables:
LANG: C.UTF-8
POSTGRES_DB: landmatrix
POSTGRES_USER: landmatrix
POSTGRES_PASSWORD: landmatrix
STAGING_HOST: dev.landmatrix.org
STAGING_USER: landmatrix
PRODUCTION_HOST: landmatrix.org
PRODUCTION_USER: landmatrix
DJANGO_SETTINGS_MODULE: config.settings.ci
DATABASE_URL: "postgis://landmatrix:landmatrix@mdillon__postgis/landmatrix"
ELASTICSEARCH_URL: "http://elasticsearch"
stages:
- test
- deploy
django formatting and linting:
stage: test
interruptible: true
script:
# - poetry config experimental.new-installer false
- poetry install -E production
- npm i --force
- black . --check
# - poetry run pylint config -d unused-wildcard-import,unused-import,wildcard-import
# - poetry run pylint apps --exit-zero # pylint is quite broken at the moment
frontend formatting and linting:
stage: test
interruptible: true
script:
- cd frontend
- npm ci
- npm run build
tests and coverage:
stage: test
interruptible: true
services:
# - kartoza/postgis:12.1
- mdillon/postgis:10
- elasticsearch:5
script:
# - poetry config experimental.new-installer false
- poetry install -E production
- npm i --force
- poetry run doit -n 4 update
- poetry run pytest -x
coverage: /^TOTAL.*\s+(\d+\%)$/
deploy to staging:
stage: deploy
script:
- eval $(ssh-agent -s)
- echo "$STAGING_SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- |
ssh $STAGING_USER@$STAGING_HOST << E=O=F
set -e
mv maintenance.html_ maintenance.html || echo "could not move maintenance"
cd ~/htdocs
poetry run doit full_update dev=True production=True
sudo /bin/systemctl restart django-dev.landmatrix.org.service
cd ~
mv maintenance.html maintenance.html_
E=O=F
only:
- main
deploy to production:
stage: deploy
script:
- eval $(ssh-agent -s)
- echo "$PRODUCTION_SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- |
ssh $PRODUCTION_USER@$PRODUCTION_HOST << E=O=F
set -e
mv maintenance.html_ maintenance.html || echo "could not move maintenance"
cd ~/htdocs
poetry run doit full_update production=True branch=production
sudo /bin/systemctl restart django-landmatrix.org.service
cd ~
mv maintenance.html maintenance.html_
E=O=F
only:
- production