-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
89 lines (73 loc) · 2.32 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
PROJECT_DIR = foundation
TESTS_DIR = tests
SOURCE_DIRS := $(PROJECT_DIR) $(TESTS_DIR)
OUT_DIR = .out
SHELL := bash
.ONESHELL:
.SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
PYTHON ?= $(shell command -v python3 || command -v python)
# Default target, called by `make` alone
.PHONY: __default__
__default__: style mypy
.PHONY: check
check: style-check mypy
# Explicitly tell Make they're not associated with files
.PHONY: style
style:
ruff format $(SOURCE_DIRS)
ruff check --fix $(SOURCE_DIRS)
mdformat ./
.PHONY: style-check
style-check:
ruff format --check $(SOURCE_DIRS)
ruff check --no-fix $(SOURCE_DIRS)
mdformat --check ./
.PHONY: mypy
mypy:
@echo "============================== Type check ========================="
mypy --explicit-package-bases --config-file pyproject.toml $(SOURCE_DIRS)
.PHONY: poetry-check
poetry-check:
poetry check --lock
.PHONY: test
test:
@echo "============================== Tests =============================="
pytest -v $(TESTS_DIR) \
--junit-xml=$(OUT_DIR)/test-results/junit_pytest.xml
.PHONY: interactive-test
interactive-test:
@echo "============================== Interactive tests =================="
pytest -v $(TESTS_DIR) \
--junit-xml=$(OUT_DIR)/test-results/junit_pytest.xml \
--pdb -x
.PHONY: no-capture-test
no-capture-test:
@echo "============================== No capture tests ==================="
pytest -v $(TESTS_DIR) \
--junit-xml=$(OUT_DIR)/test-results/junit_pytest.xml \
-s
.PHONY: coverage
coverage:
@echo "============================== Coverage ==========================="
pytest -v $(TESTS_DIR) \
--junit-xml=$(OUT_DIR)/test-results/junit_pytest.xml \
--cov \
--cov-report html:$(OUT_DIR)/htmlcov \
--cov-report xml:$(OUT_DIR)/coverage.xml
@echo " => Open HTML coverage report in browser: $(OUT_DIR)/htmlcov/index.html"
.PHONY: clean-out
clean-out:
rm .coverage*
rm -rf $(OUT_DIR)
.PHONY: clean
clean: clean-out
find . -type d -name '__pycache__' -print0 | xargs -0 -I {} /bin/rm -rf "{}"
rm -rf dist
rm -rf build
.PHONY: badges
badges:
genbadge tests -i $(OUT_DIR)/test-results/junit_pytest.xml -o $(OUT_DIR)/badges/tests-badge.svg --local
genbadge coverage -i $(OUT_DIR)/coverage.xml -o $(OUT_DIR)/badges/coverage-badge.svg --local