summaryrefslogtreecommitdiff
path: root/dev.sh
blob: 7f6e249fc6e2337c277f52c8fbb1fd278a35338c (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
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/sh

[ x$1 = x ] && echo "\
Pieni ja kevyt skripti helppoa kehitystyökalujen ajoa varten.

Käyttö: $0 <komento>

Komennot:

dev        Asenna devausymäristö
pytest     Aja yksikkötestit pytestillä
pylint     Tarkista muotoilu pylintillä
covhtml    Tee haarakattavuus raportti html muodossa
covxml     Sama mutta xml muoto (codecov tarvitsee tämän)
covff      Tee html haarakattavuusraportti ja avaa se firefoxissa
all        Sama kuin '$0 covff && $0 pylint'
install    Rakenna ja asenna paketti käyttäen pipx & poetry
uninstall  Poistaa paketin (pipx uninstall...)
" && exit 0

echo "\033[32m>>> $0 $1 - started.\033[0m"

case $1 in

	dev)
		pipx install poetry \
		&& PYTHON_KEYRING_BACKEND=keyring.backends.fail.Keyring \
	   	poetry install --no-root
		;;

	pytest)
		poetry run pytest -v
		;;

	pylint)
		poetry run python3 -m pylint src/miinaharava/
		;;

	covhtml)
		poetry run python3 -m coverage run --branch -m pytest -v \
		&& poetry run python3 -m coverage html
		;;

	covxml)
		poetry run python3 -m coverage run --branch -m pytest -v \
		&& poetry run python3 -m coverage xml
		;;

	covff)
		poetry run python3 -m coverage run --branch -m pytest -v \
		&& poetry run python3 -m coverage html \
		&& firefox htmlcov/index.html
		;;

	all)	poetry run python3 -m coverage run --branch -m pytest -v \
		&& poetry run python3 -m coverage html \
		&& firefox htmlcov/index.html \
		&& poetry run python3 -m pylint src/miinaharava/
		;;

	install)
		pipx install poetry \
		&& poetry build \
		&& pipx install `ls dist/*.tar.gz -t -c -1 | head -1`
		;;

	uninstall)
		pipx uninstall miinaharava
		;;

	*)	
		echo "\033[31m<<< $0 $1 - unknown command.\033[0m"
		exit 1
		;;
esac

STATUS=$?

[ $STATUS != 0 ] \
	&& echo "\033[31m<<< $0 $1 - exited with code $STATUS.\033[0m" \
	&& exit $STATUS
	
echo "\033[32m<<< $0 $1 - done.\033[0m"