forked from pydanny/listo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
66 lines (56 loc) · 1.92 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
# Define default goal
.DEFAULT_GOAL := help # Sets default action to be help
# Define macro for printing help message
define PRINT_HELP_PYSCRIPT # start of Python section
import re, sys
output = []
# Loop through the lines in this file
for line in sys.stdin:
# if the line has a command and a comment start with
# two pound signs, add it to the output
match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line)
if match:
target, help = match.groups()
output.append("%-10s %s" % (target, help))
# Sort the output in alphanumeric order
output.sort()
# Print the help result
print('\n'.join(output))
endef
export PRINT_HELP_PYSCRIPT # End of python section
# Define target for printing help message
help:
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
# Define target for building the changelog
changelog: ## Fetches the changelog from the latest release. Requires GH CLI
gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/pydanny/listo/releases/latest > changelog.json
python utils/update_changelog.py
rm changelog.json
# Define target for linting code
lint: ## Lint code with black and ruff
black .
ruff check . --fix
mypy
# Define target for testing code
test: ## Test code with coverage and pytest
coverage run -m pytest .
coverage report -m
coverage html
# Define target for tagging version
VERSION=$(shell grep -m 1 version pyproject.toml | tr -s ' ' | tr -d '"' | tr -d "'" | cut -d' ' -f3)
tag: ## Tag version with git
echo "Tagging version $(VERSION)"
git tag -a $(VERSION) -m "Creating version $(VERSION)"
git push origin $(VERSION)
# Define phony target for executing all targets
all: changelog lint test tag ## Execute all targets
# Define phony target for cleaning up files
.PHONY: clean
clean: ## Clean up files generated by makefile
rm -f changelog.json
rm -rf htmlcov
# Declare phony targets
.PHONY: all changelog lint test tag clean help