-
Notifications
You must be signed in to change notification settings - Fork 0
/
check.sh
executable file
·44 lines (39 loc) · 974 Bytes
/
check.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
#!/usr/bin/env bash
CHANGED=0
if [[ $# = 1 ]] && [[ "$1" = "--fix" ]]; then
if ! black --check . &> /dev/null; then
black . || exit 1
CHANGED=1
fi
if ! isort --check . &> /dev/null; then
isort . || exit 1
CHANGED=1
fi
elif [[ $# -gt 0 ]]; then
echo "Usage: $0 [--fix]" > /dev/stderr
exit 1
fi
echo Testing...
if ! ./test.py; then
echo "FAIL: tests"
exit 1
fi
# if this fails with "black: command not found" you need to install black
# python3 -m pip install black
echo Running black to check formatting...
if ! black --check --diff --quiet .; then
echo "FAIL: formatting"
exit 1
fi
# if this fails with "isort: command not found" you need to install isort
# python3 -m pip install isort
echo Running isort to check import sorting...
if ! isort --check --quiet .; then
echo "FAIL: import sorting"
exit 1
fi
if [[ $CHANGED = 1 ]]; then
echo "OK after fixes"
else
echo "OK"
fi