forked from gregtap/mayan
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
171 lines (160 loc) · 4.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
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
stages:
- test
- build_python
- build_docker
- push_python
- push_docker
- deploy
job_docker_master:
stage: build_docker
image: docker:latest
services:
- docker:dind
script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- docker build --pull -t "$CI_REGISTRY_IMAGE" -f docker/Dockerfile .
- VERSION=`cat docker/version`
- docker tag "$CI_REGISTRY_IMAGE" "$CI_REGISTRY_IMAGE:$VERSION"
- docker run --rm "$CI_REGISTRY_IMAGE:$VERSION" run-tests
- docker push "$CI_REGISTRY_IMAGE:$VERSION"
- docker tag "$CI_REGISTRY_IMAGE:$VERSION" registry-1.docker.io/mayanedms/mayanedms:"$VERSION"
- docker tag "$CI_REGISTRY_IMAGE:$VERSION" registry-1.docker.io/mayanedms/mayanedms:latest
- docker logout
only:
- releases
job_docker_master:
stage: push_docker
image: docker:latest
services:
- docker:dind
script:
- docker login -u "$DOCKER_HUB_USERNAME" -p "$DOCKER_HUB_PASSWORD" https://registry-1.docker.io
- docker push registry-1.docker.io/mayanedms/mayanedms:"$VERSION"
- docker push registry-1.docker.io/mayanedms/mayanedms:latest
only:
- releases
job_docker_nightly:
stage: build_docker
image: docker:latest
services:
- docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" -f docker/Dockerfile .
- docker run --rm "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" run-tests
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
only:
- nightly
- staging
job_build_python:
stage: build_python
image: ubuntu:18.04
artifacts:
expire_in: 1 hr
paths:
- dist
before_script:
- apt-get -qq update
- apt-get install -qq locales make python-pip
script:
- echo "LC_ALL=\"en_US.UTF-8\"" >> /etc/default/locale
- locale-gen en_US.UTF-8
- update-locale LANG=en_US.UTF-8
- export LC_ALL=en_US.UTF-8
- pip install -r requirements/build.txt
- make wheel
only:
- releases
job_push_python:
stage: push_python
image: ubuntu:18.04
before_script:
- apt-get -qq update
- apt-get install -qq python-pip
script:
- pip install -r requirements/build.txt
- echo "$PYPIRC" > ~/.pypirc
- twine upload dist/* -r pypi
only:
- releases
.test_base: &test_base
stage: test
image: ubuntu:16.04
cache:
paths:
- ~/.cache/pip/
- /var/cache/apt/archives/
before_script:
- apt-get -qq update
- apt-get install -qq locales
- echo "LC_ALL=\"en_US.UTF-8\"" >> /etc/default/locale
- locale-gen en_US.UTF-8
- update-locale LANG=en_US.UTF-8
- export LC_ALL=en_US.UTF-8
- apt-get install -qq curl gcc ghostscript gpgv gnupg graphviz libjpeg-dev libmagic1 libpng-dev libtiff-dev poppler-utils libreoffice poppler-utils python-dev python-pip tesseract-ocr tesseract-ocr-deu
- pip install -r requirements/testing.txt
only:
- releases
- master
- staging
- nightly
test-mysql:
<<: *test_base
variables:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
MYSQL_DATABASE: "mayan_edms"
services:
- mysql:8.0.3
script:
- apt-get install -qq libmysqlclient-dev mysql-client
- pip install mysql-python
- mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD" -e "set global character_set_server=utf8mb4;"
- python manage.py test --mayan-apps --settings=mayan.settings.testing.gitlab-ci.db_mysql --nomigrations
tags:
- mysql
test-postgres:
<<: *test_base
variables:
POSTGRES_DB: "mayan_edms"
POSTGRES_PASSWORD: "postgres"
services:
- postgres
script:
- apt-get install -qq libpq-dev
- pip install psycopg2
- python manage.py test --mayan-apps --settings=mayan.settings.testing.gitlab-ci.db_postgres --nomigrations
tags:
- postgres
test-sqlite:
<<: *test_base
script:
- python manage.py test --mayan-apps --settings=mayan.settings.testing.gitlab-ci --nomigrations
deploy_demo:
environment:
name: demo
stage: deploy
before_script:
- mkdir -p ~/.ssh
- echo "${DEMO_SSH_KNOWN_HOST}" > ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- echo "${DEMO_PRIVATE_KEY}" > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
script:
- scp contrib/scripts/install/docker.sh root@$DEMO_IP_ADDRESS:~
- ssh root@$DEMO_IP_ADDRESS "DELETE_VOLUMES=true ./docker.sh"
when: manual
deploy_staging:
environment:
name: staging
stage: deploy
before_script:
- mkdir -p ~/.ssh
- echo "${STAGING_SSH_KNOWN_HOST}" > ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- echo "${STAGING_PRIVATE_KEY}" > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
script:
- scp contrib/scripts/install/docker.sh root@$STAGING_IP_ADDRESS:~
- ssh root@$STAGING_IP_ADDRESS "DOCKER_MAYAN_IMAGE=registry.gitlab.com/mayan-edms/mayan-edms:staging ./docker.sh"
when: manual