-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
73 lines (48 loc) · 2.37 KB
/
Makefile
File metadata and controls
73 lines (48 loc) · 2.37 KB
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
# USE: `make install test build`
# ALSO SEE: `make help`
# ------------------------------------------------------- CONFIG -- #
.DEFAULT_GOAL := help
.PHONY: build check-lint check-poetry check-style check-types check clean-lock clean fix-lint fix-style help install publish test-watch test
SRC_DIR = marktab_py
TST_DIR = tests
# --------------------------------------------------------- HELP -- #
help: ## show this help message
@echo "Available targets:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'
# --------------------------------------- INSTALL | BUILD | TEST -- #
install: ## install dependencies
poetry install --with dev
build: ## build wheel and sdist distributions
poetry build
test: ## run unit tests
poetry run pytest -v
test-watch: ## watch tests (re-run on file changes)
poetry run ptw --runner "pytest -v"
coverage: ## run test coverage report
poetry run pytest --cov=$(SRC_DIR) --cov-report=term --cov-report=html \
&& echo "run 'open htmlcov/index.html' for details"
# ------------------------------------------------------ LINTING -- #
check: check-poetry check-style check-lint check-types ## run static analysis
check-style: ## run code style check (black)
poetry run black --check --diff $(SRC_DIR) $(TST_DIR)
fix-style: ## apply code style fixes (black) [WARNING: MODIFIES FILES]
poetry run black $(SRC_DIR) $(TST_DIR)
check-lint: ## run lint check (ruff)
poetry run ruff check $(SRC_DIR) tests
fix-lint: ## apply lint fixes (ruff) [WARNING: MODIFIES FILES]
poetry run ruff check --fix $(SRC_DIR) $(TST_DIR)
check-types: ## run type check (mypy)
poetry run mypy $(SRC_DIR) $(TST_DIR)
check-poetry: ## validate project packaging metadata
poetry check
# --------------------------------------------------- PUBLISHING -- #
publish: check test build ## publish package to PyPI
@read -p "Are you sure you want to publish to PyPI? [y/N] " ans; \
if [ "$$ans" = "y" ]; then poetry publish; else echo "Aborted."; fi
# ----------------------------------------------------- CLEAN UP -- #
clean: ## remove generated artifacts
rm -rf build dist *.egg-info .pytest_cache .mypy_cache .coverage htmlcov
find . -type d -name '__pycache__' -exec rm -rf {} +
clean-lock: ## remove poetry.lock
rm -f poetry.lock
# -------------------------------------------------------- (eof) -- #