-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcommit-check
executable file
·85 lines (68 loc) · 1.66 KB
/
commit-check
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
#!/bin/bash
set -e
function cleanup()
{
echo
echo "Cleaning up..."
if [[ -d $TMP_VENV ]]; then
rm -r "$TMP_VENV"
fi
}
trap cleanup EXIT
#=====================================================
# Run checks
#=====================================================
FAILURES=0
echo "Setting up python venv..."
TMP_VENV=$(mktemp -d -t venv.XXXXXX)
python3 -m venv "$TMP_VENV"
source "$TMP_VENV/bin/activate"
pip install -U pip wheel
pip install -r requirements.txt
echo
echo "Running black check..."
if ! black --check .; then
echo "Run 'black .' to fix the python formatting." >&2
FAILURES=$((FAILURES+1))
fi
echo
echo "Running isort check..."
if ! isort --check .; then
echo "Run 'isort .' to fix the python import order." >&2
FAILURES=$((FAILURES+1))
fi
echo
echo "Running pylint..."
if ! pylint scripts/{host-check,xr-compose}; then
echo "Pylint failed, check output and fix issues." >&2
FAILURES=$((FAILURES+1))
fi
echo
echo "Running mypy..."
if ! mypy; then
echo "Mypy failed, check output and fix issues." >&2
FAILURES=$((FAILURES+1))
fi
echo
echo "Running shellcheck..."
if ! shellcheck scripts/{apply-bugfixes,launch-xrd}; then
echo "Shellcheck failed, check output and fix issues." >&2
FAILURES=$((FAILURES+1))
fi
echo
echo "Running tests..."
if ! pytest; then
echo "Tests failed, check output and fix issues." >&2
FAILURES=$((FAILURES+1))
fi
#=====================================================
# Final steps
#=====================================================
echo
if ((FAILURES > 0)); then
echo "ERROR: There were $FAILURES failures"
exit 1
else
echo "SUCCESS: All passed!"
exit 0
fi