-
Notifications
You must be signed in to change notification settings - Fork 58
/
Makefile
87 lines (67 loc) · 3.04 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
PYTHON_BINARY := python3
VIRTUAL_ENV := venv
VIRTUAL_BIN := $(VIRTUAL_ENV)/bin
PROJECT_NAME := easypost
TEST_DIR := tests
## help - Display help about make targets for this Makefile
help:
@cat Makefile | grep '^## ' --color=never | cut -c4- | sed -e "`printf 's/ - /\t- /;'`" | column -s "`printf '\t'`" -t
## black - Runs the Black Python formatter against the project
black:
$(VIRTUAL_BIN)/black $(PROJECT_NAME)/ $(TEST_DIR)/ --config examples/style_guides/python/pyproject.toml
## black-check - Checks if the project is formatted correctly against the Black rules
black-check:
$(VIRTUAL_BIN)/black $(PROJECT_NAME)/ $(TEST_DIR)/ --config examples/style_guides/python/pyproject.toml --check
## build - Builds the project in preparation for release
build:
$(VIRTUAL_BIN)/python -m build
## clean - Clean the project
clean:
rm -rf $(VIRTUAL_ENV) dist/ *.egg-info/ .*cache htmlcov *.lcov .coverage
find . -name '*.pyc' -delete
## coverage - Test the project and generate an HTML coverage report
coverage:
$(VIRTUAL_BIN)/pytest --cov=$(PROJECT_NAME) --cov-branch --cov-report=html --cov-report=lcov --cov-report=term-missing --cov-fail-under=87
## docs - Generates docs for the library
docs:
$(VIRTUAL_BIN)/pdoc $(PROJECT_NAME) -o docs
## flake8 - Lint the project with flake8
flake8:
$(VIRTUAL_BIN)/flake8 $(PROJECT_NAME)/ $(TEST_DIR)/ --append-config examples/style_guides/python/.flake8
## init-examples-submodule - Initialize the examples submodule
init-examples-submodule:
git submodule init
git submodule update
## install - Install the project locally
install: | init-examples-submodule
$(PYTHON_BINARY) -m venv $(VIRTUAL_ENV)
$(VIRTUAL_BIN)/pip install -e ."[dev]"
## update-examples-submodule - Update the examples submodule
update-examples-submodule:
git submodule init
git submodule update --remote
## isort - Sorts imports throughout the project
isort:
$(VIRTUAL_BIN)/isort $(PROJECT_NAME)/ $(TEST_DIR)/ --settings-file examples/style_guides/python/pyproject.toml
## isort-check - Checks that imports throughout the project are sorted correctly
isort-check:
$(VIRTUAL_BIN)/isort $(PROJECT_NAME)/ $(TEST_DIR)/ --settings-file examples/style_guides/python/pyproject.toml --check-only
## lint - Run linters on the project
lint: black-check isort-check flake8 mypy scan
## lint-fix - Runs all formatting tools against the project
lint-fix: black isort
## mypy - Run mypy type checking on the project
mypy:
$(VIRTUAL_BIN)/mypy $(PROJECT_NAME)/ $(TEST_DIR)/ --config-file examples/style_guides/python/pyproject.toml --install-types --non-interactive
## release - Cuts a release for the project on GitHub (requires GitHub CLI)
# tag = The associated tag title of the release
# target = Target branch or full commit SHA
release:
gh release create ${tag} dist/* --target ${target}
## scan - Scans the project for security issues with Bandit
scan:
$(VIRTUAL_BIN)/bandit -r $(PROJECT_NAME)
## test - Test the project
test:
$(VIRTUAL_BIN)/pytest
.PHONY: help black black-check build clean coverage docs flake8 install isort isort-check lint lint-fix mypy release scan test