aboutsummaryrefslogtreecommitdiff
path: root/check
blob: 9f57f6046e963dc753621aab353751440d6cb77e (plain)
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
#!/bin/sh

set -e

if [ $# -lt 1 ]
then
    $0 coverage
    $0 typecheck
    $0 qa
    exit 0
fi

root=$(readlink -f "$(dirname "$0")")

# print deprecation warnings etc.
export PYTHONDEVMODE=1

# ignore known warnings from third party libraries
export PYTHONWARNINGS='default,ignore:::itypes,ignore:::^django[.]'

SUBCMD=$1
shift 1

case $SUBCMD in
    "tests")
        cd "$root"
        ./manage.py test $@
        cd -
        ;;
    "coverage")
        cd "$root"
        python3-coverage run ./manage.py test $@
        python3-coverage report
        cd -
        ;;
    "qa")
        cd "$root"
        flake8 --select=E,F,W,C90,E123 --ignore=W503 .
        isort --check-only --diff .
        if which doc8
        then
            doc8 .
        fi
        cd -
        ;;
    "typecheck")
        cd "$root"
        mypy kerbana rrd
        cd -
        ;;
    "static")
        cd "$root"
        bandit --recursive --number=3 -lll -iii .
        cd -
        ;;
    "run")
        cd "$root"
        ./manage.py runserver
        cd -
        ;;
    "devdb")
        cd "$root"
        ./manage.py migrate
        ./manage.py createsuperuser --username admin --email admin@example.org
        cd -
        ;;
    *)
        echo "No such subcommand $SUBCMD"
        ;;
esac