-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
112 lines (71 loc) · 2.2 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
# Makefile for wxdata
# use a local.env file if it exists
-include local.env
BASEDIR ?= $(PWD)
SRCDIR ?= $(BASEDIR)/src
APPNAME ?= $(shell grep -m1 '^name' "$(BASEDIR)/pyproject.toml" | sed -e 's/name.*"\(.*\)"/\1/')
APPVER ?= $(shell grep -m1 '^version' "$(BASEDIR)/pyproject.toml" | sed -e 's/version.*"\(.*\)"/\1/')
WITH_VENV := poetry run
export
.PHONY: all
all: venv preflight build
.PHONY: venv
venv:
poetry sync --no-interaction
$(WITH_VENV) pre-commit install --install-hooks --overwrite
poetry.lock: venv
poetry lock --no-interaction
.PHONY: build-dist
build-dist: preflight
poetry build --no-interaction
.PHONY: build-image
build-image: preflight
docker image build --tag "$(APPNAME):dev" "$(BASEDIR)"
.PHONY: build
build: build-dist build-image
.PHONY: release
release:
git tag "v$(APPVER)" main
git push origin "v$(APPVER)"
.PHONY: run
run: venv
$(WITH_VENV) python3 -m wxdat --config $(BASEDIR)/local.yaml
.PHONY: runc
runc: build-image
docker container run --rm --tty --volume "$(BASEDIR):/opt/wxdat" \
"$(APPNAME):dev" --config=/opt/wxdat/local.yaml
.PHONY: static-checks
static-checks: venv
$(WITH_VENV) pre-commit run --all-files --verbose
.PHONY: unit-tests
unit-tests: venv
$(WITH_VENV) coverage run "--source=$(SRCDIR)" -m \
pytest "$(BASEDIR)/tests" --vcr-record=once
.PHONY: coverage-report
coverage-report: venv unit-tests
$(WITH_VENV) coverage report
.PHONY: coverage-html
coverage-html: venv unit-tests
$(WITH_VENV) coverage html
.PHONY: coverage
coverage: coverage-report coverage-html
.PHONY: preflight
preflight: static-checks unit-tests coverage-report
.PHONY: reset-vcr
reset-vcr:
rm -Rf "$(BASEDIR)/tests/cassettes"
.PHONY: clean
clean:
rm -f "$(BASEDIR)/.coverage"
rm -Rf "$(BASEDIR)/.pytest_cache"
find "$(BASEDIR)" -name "*.pyc" -print | xargs rm -f
find "$(BASEDIR)" -name '__pycache__' -print | xargs rm -Rf
docker image rm "$(APPNAME):dev" 2>/dev/null || true
.PHONY: clobber
clobber: clean reset-vcr
$(WITH_VENV) pre-commit uninstall
rm -Rf "$(BASEDIR)/htmlcov"
rm -Rf "$(BASEDIR)/dist"
poetry env remove --all --no-interaction
docker image rm "$(APPNAME):latest" 2>/dev/null || true
docker image rm "$(APPNAME):$(APPVER)" 2>/dev/null || true