forked from geronimo-iia/async-btree
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
144 lines (104 loc) · 4.19 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# Project settings
PACKAGE := async_btree
REPOSITORY := geronimo-iia/async-btree
PACKAGES := $(PACKAGE) tests
MODULES := $(wildcard $(PACKAGE)/*.py)
# uncomment if you wanna disable test coverage
# DISABLE_COVERAGE
# MAIN TASKS ##################################################################
.PHONY: all
all: install
.PHONY: ci
ci: check test ## Run all tasks that determine CI status
# SYSTEM DEPENDENCIES #########################################################
.PHONY: doctor
doctor: ## Confirm system dependencies are available
tools/verchew
.PHONY: debug-info
debug-info: ## Show poetry debug info
poetry debug:info
# PROJECT DEPENDENCIES ########################################################
.PHONY: install
install: .install .cache ## Install project dependencies
GIT_DIR = .git
.install: poetry.lock
poetry install -E curio
poetry check
@- test -d $(GIT_DIR) && poetry run pre-commit install -f --install-hooks
@touch $@
poetry.lock: pyproject.toml
poetry lock
@touch $@
.cache:
@mkdir -p .cache
requirements.txt: poetry.lock ## Generate requirements.txt
poetry export --without-hashes -f requirements.txt > requirements.txt
# CHECKS ######################################################################
.PHONY: check
check: install ## Run linters and static analysis
poetry run isort $(PACKAGES) --recursive --apply
poetry run black $(PACKAGES)
poetry run flake8 $(PACKAGES)
poetry run pydocstyle $(PACKAGES) $(wildcard *.py)
poetry run mypy $(PACKAGE)
# TESTS #######################################################################
RANDOM_SEED ?= $(shell date +%s)
FAILURES := .cache/v/cache/lastfailed
PYTEST_OPTIONS := --random --random-seed=$(RANDOM_SEED)
ifdef DISABLE_COVERAGE
PYTEST_OPTIONS += --no-cov --disable-warnings
endif
.PHONY: test
test: install ## Run unit tests
@if test -e $(FAILURES); then poetry run pytest tests --last-failed --exitfirst; fi
@rm -rf $(FAILURES)
poetry run pytest tests $(PYTEST_OPTIONS)
ifndef DISABLE_COVERAGE
@echo "coverage report is located at htmlcov/index.html"
endif
# BUILD #######################################################################
DIST_FILES := dist/*.tar.gz dist/*.whl
.PHONY: build
build: install check test $(DIST_FILES) ## Builds the source and wheels archives
$(DIST_FILES): $(MODULES) pyproject.toml
@rm -f $(DIST_FILES)
poetry build
# RELEASE #####################################################################
.PHONY: publish
publish: build ## Publishes the package, previously built with the build command, to the remote repository
@git diff --name-only --exit-code
poetry publish
@PROJECT_RELEASE=$$(poetry run python -c "import async_btree; print(async_btree.__version__);") && \
git tag "v$$PROJECT_RELEASE" && \
git push origin "v$$PROJECT_RELEASE"
@tools/open https://pypi.org/project/async-btree
# DOC #########################################################################
SPHINX_BUILD_DIR = .cache/sphinx
.PHONY: docs
docs: ## Build and publish sit documentation.
@rm -rf docs/
@rm -rf $(SPHINX_BUILD_DIR)/
@mkdir -p $(SPHINX_BUILD_DIR)
@poetry run sphinx-build -M html "sphinx" "$(SPHINX_BUILD_DIR)"
@mv $(SPHINX_BUILD_DIR)/html docs/
@touch docs/.nojekyll
# CLEANUP #####################################################################
.PHONY: clean
clean: ## Delete all generated and temporary files
@rm -rf *.spec dist build .eggs *.egg-info .install
@rm -rf .cache .pytest .coverage htmlcov
@find $(PACKAGES) -name '__pycache__' -delete
@rm -rf *.egg-info
# UPDATE TEMPLATE ############################################################
.PHONY: update-from-template
update-from-template: ## Update project from template
@git diff --name-only --exit-code
@cookiecutter gh:geronimo-iia/template-python --output-dir .. --config-file .cookiecutter.yaml --no-input --overwrite-if-exists
@git status # shows lots of overridden files
@git add . -p # walk through patchsets, selecting files for adding
@git commit -m "Updated from template."
# HELP ########################################################################
.PHONY: help
help: all
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.DEFAULT_GOAL := help