-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpre-commit.sample
More file actions
24 lines (21 loc) · 827 Bytes
/
pre-commit.sample
File metadata and controls
24 lines (21 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env bash
# copy this to `.git/hooks/pre-commit` (if `pre-commit.sample` exists, remove `.sample`)
# if any command fails, exit immediately with that command's exit status
set -eo pipefail
# run flake8 linter checks
flake1=$(python3 -m flake8 tilewe example_*.py --count --exit-zero --select=E9,F63,F7,F82 --show-source --statistics)
flake2=$(python3 -m flake8 tilewe example_*.py --count --exit-zero --max-complexity=25 --max-line-length=127 --ignore=W291,W293,W504,E128,E201,E202,E252,E302,E305 --statistics)
if [ "$flake1" = "0" ] && [ "$flake2" = "0" ]; then
echo "passed all flake tests"
else
if [ "$flake1" != "0" ]; then
echo "$flake1"
fi
if [ "$flake2" != "0" ]; then
echo "$flake2"
fi
echo "failed some flake tests"
exit 1
fi
# run unit tests
python3 -m pytest