-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdevelop.sh
executable file
·226 lines (172 loc) · 4.71 KB
/
develop.sh
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
#!/bin/sh
#
# Script to control Mastrms in dev and test
#
TOPDIR=$(cd `dirname $0`; pwd)
# break on error
set -e
ACTION=$1
PORT='8000'
PROJECT_NAME='mastrms'
VIRTUALENV="${TOPDIR}/virt_${PROJECT_NAME}"
AWS_DOCKER_INSTANCE='ccg_syd_nginx_staging'
AWS_RPM_INSTANCE='aws_syd_mastrms_staging'
# A lot of tests need a database and/or X display to run. So the full
# test suite TEST_LIST and the tests which don't need a database or X
# are in NOSE_TEST_LIST, because they can be run outside the django
# test runner.
TEST_LIST="mastrms.repository.tests mastrms.mdatasync_server.test"
NOSE_TEST_LIST="mdatasync_client.test.tests:DataSyncServerTests mdatasync_client.test.tests:MSDataSyncAPITests mdatasync_client.test.tests:MSDSImplTests"
usage() {
echo ""
echo "Usage ./develop.sh (start|runtests|lettuce|selenium)"
echo "Usage ./develop.sh (pythonlint|jslint)"
echo "Usage ./develop.sh (ci_docker_staging|docker_staging_selenium|ci_rpm_staging|docker_rpm_staging_selenium)"
echo "Usage ./develop.sh (dockerbuild_unstable)"
echo "Usage ./develop.sh (rpmbuild|rpm_publish)"
echo ""
}
# ssh setup, make sure our ccg commands can run in an automated environment
ci_ssh_agent() {
ssh-agent > /tmp/agent.env.sh
. /tmp/agent.env.sh
ssh-add ~/.ssh/ccg-syd-staging-2014.pem
}
activate_virtualenv() {
. ${VIRTUALENV}/bin/activate
}
settings() {
export DJANGO_SETTINGS_MODULE="${PROJECT_NAME}.settings"
}
make_virtualenv() {
# check requirements
which virtualenv > /dev/null
if [ ! -e ${VIRTUALENV} ]; then
virtualenv ${VIRTUALENV}
fi
activate_virtualenv
pip install 'docker-compose<1.6' --upgrade
pip install 'flake8>=2.0,<2.1'
pip install 'closure-linter==2.3.13'
}
# build RPMs
rpmbuild() {
mkdir -p data/rpmbuild
chmod o+rwx data/rpmbuild
make_virtualenv
docker-compose --project-name mastr-ms -f docker-compose-rpmbuild.yml up
}
# publish rpms to testing repo
rpm_publish() {
time ccg publish_testing_rpm:data/rpmbuild/RPMS/x86_64/${PROJECT_NAME}*.rpm,release=6
}
# copy a version from testing repo to release repo
rpm_release() {
if [ -z "$1" ]; then
echo "rpm_release requires an rpm filename argument"
usage
exit 1
fi
time ccg release_rpm:$1,release=6
}
# puppet up staging which will install the latest rpm
ci_rpm_staging() {
ccg ${AWS_RPM_INSTANCE} boot
ccg ${AWS_RPM_INSTANCE} puppet
ccg ${AWS_RPM_INSTANCE} shutdown:120
}
# lint using flake8
pythonlint() {
make_virtualenv
flake8 ${PROJECT_NAME} --ignore=E501 --count
}
jslint() {
make_virtualenv
JSFILES="mastrms/mastrms/app/static/js/*.js mastrms/mastrms/app/static/js/repo/*.js"
OPTS="--exclude_files=mastrms/mastrms/app/static/js/swfobject.js,mastrms/mastrms/app/static/js/repo/prototype.js"
DISABLE="--disable 0131,0200,0210,0217,0220,0110,120"
for JS in $JSFILES
do
gjslint ${OPTS} ${DISABLE} $JS
done
}
start() {
mkdir -p data/dev
chmod o+rwx data/dev
make_virtualenv
docker-compose --project-name mastr-ms -f docker-compose.yml up
}
runtests() {
mkdir -p data/tests
chmod o+rwx data/tests
make_virtualenv
# clean up containers from past runs
( docker-compose --project-name ${PROJECT_NAME} -f docker-compose-test.yml rm --force || exit 0 )
docker-compose --project-name ${PROJECT_NAME} -f docker-compose-test.yml build # --no-cache
docker-compose --project-name ${PROJECT_NAME} -f docker-compose-test.yml up
}
lettuce() {
mkdir -p data/selenium
chmod o+rwx data/selenium
make_virtualenv
docker-compose --project-name ${PROJECT_NAME} -f docker-compose-lettuce.yml rm --force
docker-compose --project-name ${PROJECT_NAME} -f docker-compose-lettuce.yml build
docker-compose --project-name ${PROJECT_NAME} -f docker-compose-lettuce.yml up
}
selenium() {
mkdir -p data/selenium
chmod o+rwx data/selenium
make_virtualenv
docker-compose --project-name ${PROJECT_NAME} -f docker-compose-selenium.yml rm --force
docker-compose --project-name ${PROJECT_NAME} -f docker-compose-selenium.yml build
docker-compose --project-name ${PROJECT_NAME} -f docker-compose-selenium.yml up
}
clean() {
find ${PROJECT_NAME} -name "*.pyc" -exec rm -rf {} \;
}
purge() {
rm -rf ${VIRTUALENV}
rm *.log
}
case ${ACTION} in
runtests)
runtests
;;
lettuce)
lettuce
;;
selenium)
selenium
;;
pythonlint)
pythonlint
;;
jslint)
jslint
;;
start)
start
;;
rpmbuild)
rpmbuild
;;
rpm_publish)
ci_ssh_agent
rpm_publish
;;
ci_rpm_staging)
ci_ssh_agent
ci_rpm_staging
;;
clean)
settings
clean
;;
purge)
settings
clean
purge
;;
*)
usage
esac