-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.sh
executable file
·196 lines (160 loc) · 3.11 KB
/
build.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
#!/bin/bash
export DEBUG=$DEBUG
export SECRET_KEY=$SECRET_KEY
export QLDB_ENABLED=$QLDB_ENABLED
export qldb_name=$qldb_name
export ADMIN_NAME=$ADMIN_NAME
export ADMIN_EMAIL=$ADMIN_EMAIL
export EMAIL_HOST=$EMAIL_HOST
export EMAIL_PORT=$EMAIL_PORT
export EMAIL_USERNAME=$EMAIL_USERNAME
export EMAIL_PASSWORD=$EMAIL_PASSWORD
export DEFAULT_FROM_EMAIL=$DEFAULT_FROM_EMAIL
export SERVER_EMAIL=$SERVER_EMAIL
export ENVIRONMENT=$ENVIRONMENT
function all() {
migrate
pip3 install -r requirements.txt
static
pushd ./main/static/main/js || exit
npm install
popd || exit
static
}
function run_tests() {
python3 manage.py test
}
function clean() {
rm -rf main/migrations/*
files=$(find . -name "__pycache__")
files2=$(find . -iregex ".*\.\(pyc\)")
rm -rf "${files2}"
rm -rf "${files}"
}
function migrate() {
pwd
python3 manage.py makemigrations main
python3 manage.py makemigrations app_mr
python3 manage.py makemigrations clinic_messages
python3 manage.py makemigrations
python3 manage.py migrate
}
function makemigrations() {
python3 manage.py makemigrations main
python3 manage.py makemigrations app_mr
python3 manage.py makemigrations clinic_messages
python3 manage.py makemigrations
}
function static() {
python3 manage.py collectstatic --no-input
}
function run() {
python3 manage.py runserver 0.0.0.0:8081
}
function documents() {
rm -rf build/
sphinx-apidoc -f -o source main
sphinx-apidoc -f -o source app_mr
sphinx-apidoc -f -o source clinic_messages
make html
mkdir -p docs/
cp -rf build/html/* docs/
}
function reset_migrations() {
python3 manage.py migrate --fake main
python3 manage.py showmigrations
rm -rf main/migrations
python3 manage.py migrate --fake-initial
python3 manage.py showmigrations
}
function setup() {
python3 manage.py creategroups
python3 manage.py createadmin
python3 manage.py adminoptions
python3 manage.py createinventoryforms
python3 manage.py createraceandethnicity
}
function docker-setup() {
python3 manage.py scaledata
}
function createsuperuser() {
python3 manage.py createsuperuser
}
function shell() {
python3 manage.py shell
}
function check() {
# We're going to ignore E1101, since Django exposes members to Model classes
# that PyLint can't see.
clear && \
black . && \
run_tests && \
pylint main app_mr clinic_messages --disable=E1101,W0613,R0903,C0301,C0114,C0115,C0116,R0801
}
function celery() {
celery --app=femr_onchain worker
}
function gunicorn_run() {
gunicorn --workers=2 --threads=5 --max-requests 5 femr_onchain.wsgi:application --bind 0.0.0.0:8081
}
case "$1" in
celery)
celery
;;
check)
check
;;
doc)
documents
;;
startapp)
python3 manage.py startapp "$2"
;;
clean)
clean
;;
migrate)
migrate
;;
test)
run_tests
;;
run)
run
;;
setup)
setup
;;
init-all-run)
all
setup
gunicorn_run
;;
docker-init-all)
check
all
setup
docker-setup
all
;;
all-run)
check
all
run
;;
all)
all
;;
reset_migrations)
reset_migrations
;;
makemigrations)
makemigrations
;;
createsuperuser)
createsuperuser
;;
shell)
shell
;;
esac