This repository has been archived by the owner on Aug 24, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
/
vagga.yaml
185 lines (172 loc) · 5.98 KB
/
vagga.yaml
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
minimum-vagga: v0.7.2
containers:
mysql:
setup:
- !Alpine v3.5
- !Install
- mariadb
- mariadb-client
- !EnsureDir /data
- !EnsureDir /run
environ:
DB_DATABASE: gdg
DB_USERNAME: mysql
DB_PASSWORD: mysql
DB_HOST: 127.0.0.1
DB_PORT: 3307
DB_DATA_DIR: /data
image-cache-url: .travis/.vagga-cache/${container_name}.${short_hash}.tar.xz
volumes:
/data: !Persistent
name: mysql-data
init-command: _init-mysql
/run: !Tmpfs
mode: 0o766
subdirs:
mysqld:
app:
setup:
- !Ubuntu xenial
- !UbuntuUniverse
# Add PPA exposing Python 3.6
- !AptTrust keys: [F06FC659]
# Ref: ubuntumaniac.com/2016/12/python-360-is-released-install-on.html
- !UbuntuPPA jonathonf/python-3.6
- &app-build-deps !BuildDeps
- git
- python3.6-dev
- !Install
- ca-certificates
- mysql-client
- &python_ver python3.6
- !Sh ln -sf /usr/bin/python3.6m /usr/bin/python3m
- !Sh ln -sf /usr/bin/python3.6 /usr/bin/python3
- !Sh ln -sf /usr/bin/python3 /usr/bin/python
- !PipConfig
# Don't install python3.5
install-python: false
dependencies: true
# It doesn't seem to locate python3.6 if python-exe isn't specified
python-exe: *python_ver
- !Depends setup.py
- !Depends setup.cfg
- !Py3Requirements requirements/dev.txt
- !NpmDependencies
- !Sh bower install --allow-root
- !EnsureDir /mnt/db_host
environ-file: /work/.env
image-cache-url: .travis/.vagga-cache/${container_name}.${short_hash}.tar.xz
test:
setup:
- !Container app
- !BuildDeps *app-build-deps
- !Depends .pre-commit-config.yaml
- !Py3Requirements requirements/test.txt
- !Py3Requirements requirements/test-env.txt
# Git is needed for pre-commit in runtime. Ref:
# github.com/pre-commit/pre-commit/issues/456#issuecomment-269653630
- !Install [git]
- !Sh HOME=/root pre-commit install-hooks
environ:
# Ref:
# github.com/pre-commit/pre-commit-hooks/pull/161#issuecomment-269662841
LANG: en_US.UTF-8
BLUEBERRYPY_CONFIG: "{}"
NOSE_TESTCONFIG_AUTOLOAD_YAML: "config/test/app.yml"
image-cache-url: .travis/.vagga-cache/${container_name}.${short_hash}.tar.xz
commands:
_init-mysql: !Command
description: Initialize mysql database
container: mysql
run: |
mysql_install_db --datadir=$DB_DATA_DIR
mysqld_safe --user=root --datadir=$DB_DATA_DIR \
--bind-address=$DB_HOST --port=$DB_PORT \
--no-auto-restart --no-watch
while [ ! -S /run/mysqld/mysqld.sock ]; do
sleep .2
done # wait for server to be ready
mysqladmin create $DB_DATABASE
mysql -e "CREATE USER '$DB_USERNAME'@'localhost' IDENTIFIED BY '$DB_PASSWORD';"
mysql -e "GRANT ALL PRIVILEGES ON $DB_DATABASE.* TO '$DB_USERNAME'@'localhost';"
mysql -e "FLUSH PRIVILEGES;"
clean-db: !Command
description: Cleanup mysql database
container: mysql
run: |
mysql_install_db --datadir=$DB_DATA_DIR
mysqld_safe --user=root --datadir=$DB_DATA_DIR \
--bind-address=$DB_HOST --port=$DB_PORT \
--no-auto-restart --no-watch
while [ ! -S /run/mysqld/mysqld.sock ]; do
sleep .2
done # wait for server to be ready
mysqladmin -f drop "$DB_DATABASE"
mysqladmin create "$DB_DATABASE"
mysql -e "GRANT ALL PRIVILEGES ON $DB_DATABASE.* TO '$DB_USERNAME'@'localhost';"
mysql -e "FLUSH PRIVILEGES;"
blueberrypy: !Command
description: |
Run blueberrypy command (you have to provide command and arguments by yourself)
container: app
run: [ blueberrypy ]
ishell: !Command
description: Run iPython REPL within project directory
container: app
run: [ipython]
mysql: !Command
description: Run RDBMS shell
container: mysql
run: |
mysqld_safe --user=root --datadir=$DB_DATA_DIR \
--bind-address=$DB_HOST --port=$DB_PORT \
--no-auto-restart --no-watch
while [ ! -S /run/mysqld/mysqld.sock ]; do
sleep .2
done
mysql -D $DB_DATABASE
run: !Supervise
description: Run application in development mode
mode: stop-on-failure
children:
run-app: !Command
container: app
run: |
touch /work/.dbcreation # Create lock file
while [ -f /work/.dbcreation ]; do # Acquire lock
sleep .2
done
current_version=$(alembic -c config/alembic.ini -x environment=dev current)
head_version=$(alembic -c config/alembic.ini -x environment=dev heads)
if [ "${current_version}" != "${head_version}" ]; then
alembic -c config/alembic.ini -x environment=dev upgrade head
fi
if [ -z "${current_version}" ]; then
load_gdg_fixtures --env dev src/GDGUkraine/fixtures/fixtures.yaml || exit 1
fi
blueberrypy serve -b 0.0.0.0:8080
run-db: !Command
container: mysql
run: |
mysqld_safe --user=root --datadir=$DB_DATA_DIR \
--bind-address=$DB_HOST --port=$DB_PORT \
--no-auto-restart --no-watch
while [ ! -S /run/mysqld/mysqld.sock ]; do
sleep .2
done # wait for server to be ready
rm -f /work/.dbcreation # Release lock
while :; do # Emulate infinite loop
sleep 1d;
done
lint: !Command
description: Run linters for gdg.org.ua project
container: test
run: pre-commit run --all-files
py.test: !Command
description: Run tests for gdg.org.ua project
container: test
run: [py.test, --cov, --cov-report, term, --cov-report, xml, -v]
test: !Command
description: Run tests for gdg.org.ua project
container: test
run: py.test --cov --cov-report term --cov-report xml -v src/tests/