-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·104 lines (85 loc) · 2.63 KB
/
run.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
#!/bin/bash
THISDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PRJDIR="$THISDIR/src"
ENV="venv"
set -e
set -u
function build_help() {
cat <<ENDHELP
build [cmd]
Build commands for "$THISDIR"
build: Build the python
citest: Run unit tests
default: Same as restore, build, citest, report
install: Prints instructions for turning on completion
pack: Create packages
publish: Publish packages
coverage: Generate coverage report
profile: Gemerate profile report
restore: Update dependencies in environment $ENV
setup: Install prerequisites
test: Create packages and run integration tests
test_nopack: Run integration tests without creating packages
regress: Run regression tests
regress_nopack: Run regression tests without creating packages
After clone, run setup
After checkout or pull run restore
Before commit run default
ENDHELP
}
function build_build() {
python -m mypy "$PRJDIR" --config-file "$THISDIR/mypy.ini"
(
cd "$THISDIR"
flake8 "$PRJDIR" --ignore=W504 --max-line-length=100 && echo "Passed Flake8"
)
}
# function build_profile() {
# python -m cProfile -o risk.prof "$PRJDIR/risk.py"
# snakeviz risk.prof
# }
function build_citest() {
coverage run --branch --source="$PRJDIR" -m pytest --pdb --pyargs "$PRJDIR" "$PRJDIR"
}
function build_restore() {
if ! which python | grep -w "$ENV" > /dev/null ; then
python3 -m venv "$ENV"
fi
source "$ENV/bin/activate"
pip install -r requirements.txt
}
function run_cmd() {
local script=$1
shift
printf '==== %-10s ====\n' "$script"
"build_$script" "$@"
}
function build_default() {
run_cmd setup
run_cmd restore
run_cmd build
run_cmd citest
run_cmd report
}
function build_setup() {
command virtualenv --version > /dev/null || { echo "Missing virtualenv - you need to install it." ; exit 1 ; }
command pip --version > /dev/null || { echo "Missing pip - you need to install it." ; exit 2 ; }
}
# function build_pack() {
# #work out how to use the inbuild ppi
# :
# }
# function build_publish() {
# #pass
# :
# }
function build_report() {
coverage report --fail-under 75 --omit='./venv/*'
coverage html --fail-under 75 --omit='./venv/*'
}
# function build_docs() {
# :
# }
cmd="${1:-default}"
shift || true
"build_$cmd" "$@"