-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
94 lines (60 loc) · 2.11 KB
/
Makefile
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
86
87
88
89
90
91
92
93
94
define check_pip_module
$(if $(shell pip show $(1)),,$(error "module '$(1)' not found."))
endef
define echo_section
@printf "\33[33m\n%s\n%s\n\33[0m" $(1) "==========================="
endef
define ask_prompt
@printf "%s\nAre you sure? [y/N]" $(1) && read ans && [ $${ans:-N} = y ]
endef
VERSION := $(shell ./scripts/get_version.sh __version__)
PY_VERSION := $(shell ./scripts/get_version.sh __py_version__)
all: typecheck black test install docker-build clean
install:
$(call echo_section,"installing")
pip install .
test: gentest unittest clean
coverage: gentest runcoverage clean
gentest:
$(call echo_section,"generate test repos")
./scripts/generate_test_repos.sh
unittest:
$(call echo_section,"running tests")
python -m unittest --verbose
typecheck:
$(call check_pip_module,"mypy")
$(call echo_section,"static type checking")
mypy --pretty --show-error-context --show-error-codes git_substatus
runcoverage:
$(call check_pip_module,"coverage")
$(call echo_section,"measuring code coverage")
coverage run --source git_substatus -m unittest && coverage report
black:
$(call check_pip_module,"black")
$(call echo_section,"checking code formatting with black")
python -m black --check .
black-apply:
$(call check_pip_module,"black")
$(call echo_section,"applying code formatting with black")
python -m black .
clean:
$(call echo_section,"cleaning")
# directories
find . -depth -name __pycache__ -exec rm -rf {} \;
find . -depth -name *.pyc -exec rm -rf {} \;
find . -depth -name *.mypy_cache -exec rm -rf {} \;
find . -depth -name *.egg-info -exec rm -rf {} \;
# files
find . -depth -name .coverage -exec rm {} \;
# absolute path files
rm -rf tests/generated-test-proj-dir;
tag-create:
$(call ask_prompt,"creating tag \"v$(VERSION)\".")
git tag "v$(VERSION)"
tag-push:
$(call ask_prompt,"pushing tag \"$(VERSION)\" to master.")
git push origin "v$(VERSION)"
docker-build:
$(call echo_section,"building the docker image")
docker build -t strboul/git-substatus:"$(VERSION)" --build-arg PY_VERSION="$(PY_VERSION)" .
docker tag strboul/git-substatus:"$(VERSION)" strboul/git-substatus:latest