-
Notifications
You must be signed in to change notification settings - Fork 71
/
Copy pathMakefile
82 lines (63 loc) · 2.01 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
BUILD_DIR=build
PYTHON ?= /usr/bin/env python3
all: deps lint man package install
# Install dependent pip packages, needed to lint or build
deps:
$(PYTHON) -m pip install .[dev]
# Format using black
BLACK_CMD=$(PYTHON) -m black --line-length 100 -t py38 --preview --exclude "build/.*|\.eggs/.*"
ISORT_CMD=$(PYTHON) -m isort --profile black --py 38
format:
$(BLACK_CMD) .
$(ISORT_CMD) .
# Check formatting using black
check_format:
$(BLACK_CMD) --check --diff .
$(ISORT_CMD) --check --diff .
MYPY_COMMAND=$(PYTHON) -m mypy --show-error-codes
check_types:
$(MYPY_COMMAND) revup
pylint:
$(PYTHON) -m pylint revup
# Lint check for formatting and type hints
# This needs pass before any merge.
lint: check_types check_format pylint
# Clean all artifacts
clean:
rm -rf $(BUILD_DIR)
rm -rf .mypy_cache
REVUP_VERSION:=$(shell $(PYTHON) revup/__init__.py)
REVUP_DATE ?= Apr 21, 2021
define REVUP_HEADER
---
title: TITLE
section: 1
header: Revup Manual
footer: revup VERSION
date: DATE
---
endef
export REVUP_HEADER
REVUP_VERSION_HASH?=${shell git rev-parse --short v$(REVUP_VERSION) || echo main}
package: man
REVUP_VERSION_HASH=$(REVUP_VERSION_HASH) $(PYTHON) -m build --outdir $(BUILD_DIR)
install:
$(PYTHON) -m pip install build/revup-$(REVUP_VERSION)-py3-none-any.whl --force-reinstall
upload_check:
$(PYTHON) -m twine check build/revup-$(REVUP_VERSION).tar.gz
upload_test:
$(PYTHON) -m twine upload --repository testpypi build/revup-$(REVUP_VERSION).tar.gz
upload:
$(PYTHON) -m twine upload build/revup-$(REVUP_VERSION).tar.gz
man:
mkdir -p revup/man1 ; \
cd docs ; \
for file in *.md ; do \
CMD_NAME=`echo $${file} | awk -F'[.]' '{print $$1}'` ; \
echo "$${REVUP_HEADER}" | m4 -DTITLE=$${CMD_NAME} -DVERSION=$(REVUP_VERSION) -DDATE="$(REVUP_DATE)" - | \
cat - $${file} | pandoc -s -t man > ../revup/man1/$${CMD_NAME}.1 || exit 1 ; \
gzip -n -f -k ../revup/man1/$${CMD_NAME}.1 || exit 1 ; \
done
test:
$(PYTHON) -m pytest tests/
.PHONY: all deps man install package format check_format check_types pylint lint clean