-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
entrypoint.sh
executable file
·66 lines (58 loc) · 2.09 KB
/
entrypoint.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
#!/bin/bash
function display_help {
echo 'USAGE:'
echo 'docker run -ti [--rm] --mount source=$(pwd)/src,destination=/tmp/echr_process,type=bind,readonly <image_id|image_name[:image_tag]> [help | bash | /bin/bash | deploy | build | pytest [pytest options] [file_or_dir] [...] | lint | all]'
echo
echo 'OPTIONS:'
echo ' help - Prints this help and exits.'
echo ' bash | /bin/bash - Allows to access bash console of the container.'
echo ' deploy - Deploy a build to a given server'
echo ' all - Runs pytest'
echo ' - Then, build ECHR database'
echo ' After all, check the data.'
echo ' test - Runs pytest.'
echo ' build - Build ECHR database.'
echo ' lint - Runs pylint.'
}
function display_mounting_error {
echo "Mount echr_process directory into /tmp/echr_process in order to run test process properly."
echo "Use the following snippet in docker run command:"
echo '--mount src="$(pwd)"/src,dst=/tmp/echr_process/src,type=bind,readonly\n'
}
function build {
python3 ./build.py ${@:2}
}
function deploy {
echo "non-implemented yet :)"
}
function lint_source_code {
python -m pylint --rcfile=.pylintrc *.py
}
function handle_input {
if [[ "$#" -eq 0 ]] ; then
display_help
else
if [[ "$1" = 'bash' || "$1" = '/bin/bash' ]] ; then
/bin/bash
elif [[ "$1" = "build" ]] ; then
build $@
elif [[ "$1" = "all" ]] ; then
python -m pytest -v -c ./.pytest.ini --disable-warnings &&\
lint_source_code
elif [[ "$1" = "test" ]] ; then
python -m pytest -v -c ./.pytest.ini --disable-warnings
python -m pytest --cov-report xml:cov.xml --cov-report html:cov_html --cov-report term-missing --cov=echr tests/
return
elif [[ "$1" = 'lint' ]] ; then
lint_source_code
else
display_help
fi
fi
}
function main() {
handle_input $@
status_code=$?
exit ${status_code}
}
main $@