forked from sysid/sse-starlette
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
130 lines (105 loc) · 3.78 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
.DEFAULT_GOAL := help
# You can set these variables from the command line, and also from the environment for the first two.
SOURCEDIR = source
BUILDDIR = build
MAKE = make
VERSION = $(shell cat VERSION)
app_root = $(PROJ_DIR)
app_root ?= .
pkg_src = $(app_root)/sse_starlette
tests_src = $(app_root)/tests
.PHONY: all
all: clean build upload ## Build and upload
@echo "--------------------------------------------------------------------------------"
@echo "-M- building and distributing"
@echo "--------------------------------------------------------------------------------"
################################################################################
# Building, Deploying \
BUILDING: ## ############################################################
.PHONY: build
build: clean format isort ## format and build
@echo "building"
python -m build
.PHONY: upload
upload: ## upload to PyPi
@echo "upload"
twine upload --verbose dist/*
.PHONY: bump-major
bump-major: ## bump-major, tag and push
bumpversion --commit --tag major
git push --tags
.PHONY: bump-minor
bump-minor: ## bump-minor, tag and push
bumpversion --commit --tag minor
git push --tags
.PHONY: bump-patch
bump-patch: ## bump-patch, tag and push
bumpversion --commit --tag patch
git push --tags
################################################################################
# Testing \
TESTING: ## ############################################################
.PHONY: coverage
coverage: ## Run tests with coverage
python -m coverage erase
python -m coverage run --include=$(pkg_src)/* -m pytest -ra
python -m coverage report -m
.PHONY: test
test: ## run tests
python -m pytest -ra --junitxml=report.xml --cov-config=setup.cfg --cov-report=xml --cov-report term --cov=$(pkg_src) tests/
.PHONY: tox
tox: ## Run tox
tox
################################################################################
# Code Quality \
QUALITY: ## ############################################################
.PHONY: style
style: isort format ## perform code style format (black, isort)
.PHONY: format
format: ## perform black formatting
black $(pkg_src) tests
.PHONY: isort
isort: ## apply import sort ordering
isort . --profile black
.PHONY: lint
lint: flake8 mypy ## lint code with all static code checks
.PHONY: flake8
flake8: ## check style with flake8
@flake8 $(pkg_src)
.PHONY: mypy
mypy: ## check type hint annotations
# keep config in setup.cfg for integration with PyCharm
mypy --config-file setup.cfg $(pkg_src)
################################################################################
# Clean \
CLEAN: ## ############################################################
.PHONY: clean
clean: clean-build clean-pyc ## remove all build, test, coverage and Python artifacts
.PHONY: clean-build
clean-build: ## remove build artifacts
rm -fr build/
rm -fr dist/
rm -fr .eggs/
find . \( -path ./env -o -path ./venv -o -path ./.env -o -path ./.venv \) -prune -o -name '*.egg-info' -exec rm -fr {} +
find . \( -path ./env -o -path ./venv -o -path ./.env -o -path ./.venv \) -prune -o -name '*.egg' -exec rm -f {} +
.PHONY: clean-pyc
clean-pyc: ## remove Python file artifacts
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -fr {} +
################################################################################
# Misc \
MISC: ## ############################################################
define PRINT_HELP_PYSCRIPT
import re, sys
for line in sys.stdin:
match = re.match(r'^([a-zA-Z0-9_-]+):.*?## (.*)$$', line)
if match:
target, help = match.groups()
print("\033[36m%-20s\033[0m %s" % (target, help))
endef
export PRINT_HELP_PYSCRIPT
.PHONY: help
help:
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)