-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·130 lines (106 loc) · 2.65 KB
/
entrypoint.sh
File metadata and controls
executable file
·130 lines (106 loc) · 2.65 KB
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
#!/usr/bin/env bash
loadconfig() {
if [ -f /run/secrets/config.sh ]; then
echo "Use configuration from secrets"
source /run/secrets/config.sh
elif [ -f ./config.sh ]; then
echo "Use ./config.sh"
source ./config.sh
elif [ -f ./config.sh.example ]; then
echo "WARNING: Use ./config.sh.example"
source ./config.sh.example
else
echo "ERROR: config.sh not found"
exit 1
fi
}
executeapp() {
uvicorncom=$1
applocation="webapp.main:app"
if [[ -n ${2} ]]
then
applocation=$2
fi
loadconfig
exec $uvicorncom $applocation
}
startapp() {
echo "Run app in PRODUCTION mode"
executeapp "uvicorn --host 0.0.0.0 --port 8000" $1
}
developapp() {
echo "Run app in DEVELOPMENT mode"
executeapp "uvicorn --reload --host 0.0.0.0 --port 8000" $1
}
validatecode() {
help() {
echo
echo "Usage: validatecode [-h|k]"
echo
echo "Automatically run code validation whenever the code changes."
echo
echo "Options:"
echo "h Print this help menu."
echo "k Invoke Pytest option -k to run specific tests based on a substring match to the test name."
echo
}
while getopts ":h" option; do
case $option in
h)
help
exit;;
esac
done
echo -e "\nREADY TO RUN THE CODE VALIDATION SUITE\nSave a python file to trigger the checks."
loadconfig
watchmedo shell-command --patterns="*.py;*.txt" --recursive --command="/python/test_suite.sh \$@" --drop .
}
validatecodeonce() {
help() {
echo
echo "Usage: validatecodeonce [-h|k]"
echo
echo "Trigger a single run of code validation."
echo
echo "Options:"
echo "h Print this help menu."
echo "k Invoke Pytest option -k to run specific tests based on a substring match to the test name."
echo
}
while getopts ":h" option; do
case $option in
h)
help
exit;;
esac
done
echo -e "\nTriggering single run of code validation."
loadconfig
../test_suite.sh $@ reports
}
runtests() {
echo "Run pytest and output XML report files"
loadconfig
if [ -f ./coverage.conf ];
then
$covconf="--cov-config ./coverage.conf"
fi
python -m pytest -vv --durations=3 --junitxml unittesting.xml --cov=. $covconf\
--cov-report term-missing --cov-report xml:coverage.xml
mv *.xml /python/reports/
}
interrogateverbose() {
echo "Verify docstring coverage"
interrogate -vv
}
case "$1" in
startapp|developapp|validatecode|validatecodeonce|runtests|interrogateverbose)
# Run the identified command and the provided arguments
$@
;;
*)
# Just run any command past to the docker
echo "Execute this in bash: $@"
exec "$@"
;;
esac