-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.sh
executable file
·79 lines (66 loc) · 1.87 KB
/
test.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
#!/bin/bash
# Exit on error. Append "|| true" if you expect an error.
set -o errexit
# Exit on error inside any functions or subshells.
set -o errtrace
# Do not allow use of undefined vars. Use ${VAR:-} to use an undefined VAR
set -o nounset
# Catch the error in case mysqldump fails (but gzip succeeds) in `mysqldump | gzip`
set -o pipefail
TEST_TYPE=${1:-"all"}
shift || true
PACKAGES=("my_package")
function lint() {
echo "💨 linting.."
poetry run flake8 --config setup.cfg --jobs auto ${PACKAGES[@]}
echo "📝 isorting.."
poetry run isort ${PACKAGES[@]} --check-only --recursive --diff
echo "⚫ blacking.."
poetry run black --diff --check ${PACKAGES[@]}
echo "☠️ looking for dead code.."
poetry run vulture ${PACKAGES[@]}
}
function type_check() {
echo "👮 Type checking.."
for package in ${PACKAGES[@]}
do
poetry run mypy ${package}
done
}
function unit_tests() {
echo "🏃 Testing.."
for package in ${PACKAGES[@]}
do
echo ${package}
poetry run pytest -n auto ${package}
done
}
function unit_tests_with_coverage_report() {
echo "🏃 Testing.."
for package in ${PACKAGES[@]}
do
echo ${package}
poetry run pytest -n auto --cov-report html:${package}-coverage_html --cov=${package} ${package}
done
}
echo "Checking packages: ${PACKAGES[@]}"
echo
if [ "${TEST_TYPE}" = "lint" ] ; then
lint
elif [ "${TEST_TYPE}" = "type_check" ] ; then
type_check
elif [ "${TEST_TYPE}" = "unit_tests" ] ; then
unit_tests
elif [ "${TEST_TYPE}" = "tests_with_coverage_report" ] ; then
unit_tests_with_coverage_report
elif [ "$TEST_TYPE" = "all" ] ; then
lint
type_check
unit_tests
else
echo "❌ invalid test type - ${TEST_TYPE}"
echo
echo "Valid test types: lint|type_check|unit_tests|unit_tests_with_coverage_report|all"
exit 1
fi
echo "✅ All good."