-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
65 lines (57 loc) · 1.69 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
SHELL:=/bin/bash
FIX=1
COVERAGE=0
RUFF=ruff
MYPY=mypy
PYTEST=pytest
PYTHON=python3
VERSION=0.0.0
PYPI_TOKEN=
IS_PYTHON_38=$(shell python --version |grep '^Python 3\.8\.' |wc -l)
default: help
.PHONY: lint
lint: ## Lint the code (FIX=0 to disable autofix)
ifeq ($(FIX), 0)
$(RUFF) format --check .
$(RUFF) .
else
$(RUFF) format .
$(RUFF) --fix .
endif
ifeq ($(IS_PYTHON_38), 1)
@echo "WARNING: mypy is skipped with Python 3.8 because of problems with Annotated types"
else
$(MYPY) --check-untyped-defs .
endif
.PHONY: test
test: ## Test the code
ifeq ($(COVERAGE), 0)
$(PYTEST) tests
else
$(PYTEST) --no-cov-on-fail --cov=jinja_tree --cov-report=term --cov-report=html --cov-report=xml tests
endif
.PHONY: doc
doc: ## Generate documentation
$(PYTHON) jinja_tree/infra/controllers/cli_tree.py .
.PHONY: clean
clean: ## Clean generated files
rm -Rf .*_cache build
find . -type d -name __pycache__ -exec rm -Rf {} \; 2>/dev/null || true
.PHONY: docker
docker: ## Build docker image
cd docker && $(MAKE) build
.PHONY: publish
publish: ## Publish to PyPI
@if test "${VERSION}" = "0.0.0"; then echo "ERROR: Cannot publish a dev version"; exit 1; fi
@if test "${PYPI_TOKEN}" = ""; then echo "ERROR: PYPI_TOKEN is not set"; exit 1; fi
cp -f pyproject.toml pyproject.toml.dev
poetry version "$(VERSION)"
poetry config pypi-token.pypi "$(PYPI_TOKEN)"
poetry build
poetry publish
.PHONY: help
help::
@# See https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
@cat $(MAKEFILE_LIST) >"$(TMPDIR)/makefile_help.txt"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' "$(TMPDIR)/makefile_help.txt" | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
@rm -f "$(TMPDIR)/makefile_help.txt"