-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
120 lines (88 loc) · 2.22 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
#!/usr/bin/make -f
# -*- coding: utf-8 -*-
SRC_DIR = src
TESTS_DIR = tests
DIST_DIR = dist
TMP_DIR = tmp
COVERAGE_DIR = htmlcov
##
# ALL
##
all: install test build clean
.PHONY: all
##
# RELEASE
##
release: update test-all lint-all distclean build clean
.PHONY: all
##
# INSTALL
##
install:
poetry install --sync
update:
poetry update
.PHONY: install update
##
# LINT & TESTS
##
lint:
poetry run flake8 ${SRC_DIR}
poetry run pylint ${SRC_DIR}
lint-all: lint
poetry run flake8 ${TESTS_DIR} || true
poetry run pylint ${TESTS_DIR} || true
test:
poetry run dotenv run coverage run -m pytest -m 'not slow'
poetry run coverage report --fail-under=100
test-all:
poetry run dotenv run coverage run -m pytest || \
poetry run dotenv run coverage run -a -m pytest --last-failed --last-failed-no-failures none
poetry run coverage report --fail-under=100
coverage:
poetry run coverage html -d ${COVERAGE_DIR}
open ${COVERAGE_DIR}/index.html
.PHONY: lint lint-all test test-all coverage
##
# BUILD
#
sync-version:
git grep -l "__version__\s*=" ${SRC_DIR} | xargs -I {} \
sed -i '' "s/^\s*__version__.*/__version__ = \'`poetry version -s`\'/" {}
build: sync-version
poetry check
poetry build
poetry run check-wheel-contents ${DIST_DIR}
.PHONY: build sync-version
##
# PUBLISH
##
test-publish:
poetry config repositories.testpypi https://test.pypi.org/legacy/
poetry publish -r testpypi
publish:
poetry publish
gh release create -p "v`poetry version -s`" ./${DIST_DIR}/mtg_parser-* --generate-notes
.PHONY: test-publish publish
##
# CLEAN
##
define remove_dir
find $(2) -type d -name $(1) -print0 | xargs -0 -I {} rm -rf '{}'
endef
clean-old-runs:
@echo 'Cleaning runs older than 120 days'
@gh run list --json startedAt,databaseId --limit 100 \
| jq '.[] | select(now - (.startedAt | fromdateiso8601) > 10368000) | .databaseId' \
| xargs -I {} gh run delete {}
clean-packages:
$(call remove_dir,${DIST_DIR},.)
clean:
poetry run coverage erase
$(call remove_dir,${COVERAGE_DIR},.)
$(call remove_dir,${TMP_DIR},.)
$(call remove_dir,'__pycache__',.)
$(call remove_dir,'.pytest_cache',.)
$(call remove_dir,'*.egg-info',${SRC_DIR} ${TESTS_DIR})
distclean: clean clean-packages
.PHONY: clean-old-runs clean clean-packages distclean