-
Notifications
You must be signed in to change notification settings - Fork 5
/
.drone.yml
196 lines (177 loc) · 5.38 KB
/
.drone.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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# Anchors
when-pr-push: &when-pr-push
when:
event: [push, pull_request]
docker-compose: &docker-compose
image: docker/compose:1.22.0
volumes:
- /var/run/docker.sock:/var/run/docker.sock
test: &test
<<: *when-pr-push
image: fidals/se:dev
secrets: [ FTP_IP, FTP_USER, FTP_PASS, SELENIUM_WAIT_SECONDS, SELENIUM_IMPLICIT_WAIT, SELENIUM_TIMEOUT_SECONDS ]
environment:
- TEST_ENV=true
- DJANGO_SETTINGS_MODULE=shopelectro.settings.drone
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=test
- POSTGRES_URL=postgres
- POSTGRES_DB=test
- RABBITMQ_DEFAULT_USER=rabbitmq
- RABBITMQ_DEFAULT_PASS=test
- RABBITMQ_URL=rabbitmq
- RABBITMQ_PORT=5672
- SELENIUM_URL=http://selenium:4444/wd/hub
- FTP_IP=${FTP_IP}
- FTP_USER=${FTP_USER}
- FTP_PASS=${FTP_PASS}
- SELENIUM_WAIT_SECONDS=${SELENIUM_WAIT_SECONDS}
- SELENIUM_TIMEOUT_SECONDS=${SELENIUM_TIMEOUT_SECONDS}
- SELENIUM_IMPLICIT_WAIT=${SELENIUM_IMPLICIT_WAIT}
lint: &lint
<<: *when-pr-push
group: lint
# CI config
branches: master
workspace:
base: /drone
path: shopelectro/
pipeline:
build-nodejs:
<<: *docker-compose
<<: *when-pr-push
commands:
- cd docker/
- cp drone_env/.env . && cp drone_env/* env_files/
# we have these deps:
# build nodejs -> gulp build -> build python-prod
# @todo #761:60m Fix stale cache using for nodejs image.
# The image always uses stale cache for refarm-site's front.
# See this build log: https://ci.fidals.com/fidals/shopelectro/1438/6
- docker-compose -f docker-compose-build.yml build --no-cache nodejs
build-static:
<<: *when-pr-push
image: fidals/se-nodejs:dev
environment:
# deps from nodejs image
- DEPS_DIR=/usr/app/deps
commands:
- cp -r /usr/app/src/node_modules .
- gulp build
build-python:
<<: *docker-compose
<<: *when-pr-push
commands:
- cd docker/
# Build python images with sources and static files
- docker-compose -f docker-compose-build.yml build python-dev python-prod
fast-test:
<<: *test
commands:
- python manage.py migrate
- python manage.py excel
- python manage.py price
- python manage.py collectstatic --noinput
- python manage.py test --parallel --tag fast -k -v 3
slow-test:
<<: *test
commands:
- python manage.py test --parallel --tag slow -k --rerun-failed 2 -v 3
lint-coala:
<<: *lint
image: fidals/coala-ci
commands:
- coala --ci -j 2
lint-pdd:
<<: *lint
image: fidals/pdd-ci
commands:
- pdd --verbose
--exclude=node_modules/**/*
--exclude=static/**/*
--exclude=venv/**/*
--exclude=media/**/*
--exclude=.idea/**/*
--exclude=front_build
--exclude=front/images
--exclude=**/*.pyc
--exclude=**/*.jpg
-f report.xml
push-images:
image: docker:latest
environment:
- DOCKER_HUB_LOGIN=${DOCKER_HUB_LOGIN}
- DOCKER_HUB_PASSWORD=${DOCKER_HUB_PASSWORD}
commands:
- docker login -u $DOCKER_HUB_LOGIN -p $DOCKER_HUB_PASSWORD
- docker push fidals/se-nodejs:dev
- docker push fidals/se:dev
- docker push fidals/se:prod
volumes:
- /var/run/docker.sock:/var/run/docker.sock
when:
event: push
secrets: [ DOCKER_HUB_LOGIN, DOCKER_HUB_PASSWORD ]
copy-drone-env:
image: debian:latest
commands:
- cd docker
- cp drone_env/* env_files/
- for x in drone_env/*; do cat $x >> .env; done;
when:
status: [ success, failure ]
event: [push, pull_request]
test-docker-compose:
<<: *docker-compose
<<: *when-pr-push
environment:
- DJANGO_SETTINGS_MODULE=shopelectro.settings.drone
- VIRTUAL_HOST_PORT=8000
# COMPOSE_INTERACTIVE_NO_CLI in a combination with `docker-compose exec -T`
# fixes a syntax error: unterminated quoted string.
# Why is it? Nobody knows.
- COMPOSE_INTERACTIVE_NO_CLI=1
commands:
- cd docker
- docker-compose up -d app-drone
# wait postgres, apply migrations, create custom pages to reach "/" page
- docker-compose exec -T app-drone docker/wait-for.sh postgres:5432
- docker-compose exec -T app-drone python manage.py migrate
- docker-compose exec -T app-drone python manage.py custom_pages
# wait python server and check its health
- docker-compose exec -T app-drone docker/wait-for.sh 0.0.0.0:8000 -- docker/check-health.sh 0.0.0.0:8000
cleanup:
<<: *docker-compose
<<: *when-pr-push
commands:
- cd docker
- docker-compose logs app-drone
- docker-compose rm -fs
when:
status: [ success, failure ]
event: [push, pull_request]
services:
postgres:
<<: *when-pr-push
image: postgres
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=test
- POSTGRES_DB=test
rabbitmq:
<<: *when-pr-push
image: rabbitmq
environment:
- RABBITMQ_DEFAULT_USER=rabbitmq
- RABBITMQ_DEFAULT_PASS=test
selenium:
<<: *when-pr-push
image: selenium/standalone-chrome:3.141.59
environment:
# https://github.com/SeleniumHQ/docker-selenium/issues/392
- DBUS_SESSION_BUS_ADDRESS=/dev/null
- SCREEN_WIDTH=1366
- SCREEN_HEIGHT=768
shm_size: 4G
volumes: # https://github.com/SeleniumHQ/docker-selenium#running-the-images
- /dev/shm:/dev/shm