-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
114 lines (91 loc) · 2.79 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
# Settings
DOCKER_MULTI_PYTHON_IMAGE = acidrain/multi-python:latest
DOCKER_USER = "$(shell id -u):$(shell id -g)"
# Default target
.DEFAULT_GOAL := tox
# Development environment
# -----------------------
# Install a virtualenv
.PHONY: venv
venv:
virtualenv venv
. venv/bin/activate && pip install --upgrade pip tox build && pip install -e ".[testing]"
# Build distribution package
.PHONY: build
build:
. venv/bin/activate && python -m build
# Test suite
# ----------
# Run complete tox suite with local Python interpreter
.PHONY: tox
tox:
tox run
# Run tox in venv (needs to be installed with `make venv` first)
.PHONY: venv-tox
venv-tox:
. venv/bin/activate && tox run
# Only run pytest
.PHONY: test
test:
tox run -e clean,py,report
# Only run flake8 linter
.PHONY: flake8
flake8:
tox run -e flake8
# Only run mypy (via tox; you can also just run "mypy" directly)
.PHONY: mypy
mypy:
tox run -e mypy
# Open HTML coverage report in browser
.PHONY: open-coverage
open-coverage:
$(or $(BROWSER),firefox) ./reports/coverage_html/index.html
# Run complete tox test suite in a multi-python Docker container
.PHONY: docker-tox
docker-tox: TOX_ARGS='-e clean,py312,py311,py310,report,flake8,py312-mypy'
docker-tox:
docker run --rm --tty \
--user $(DOCKER_USER) \
--mount "type=bind,src=$(shell pwd),target=/code" \
--workdir /code \
--env HOME=/tmp/home \
$(DOCKER_MULTI_PYTHON_IMAGE) \
tox run --workdir .tox_docker $(TOX_ARGS)
# Run partial tox test suites in Docker
.PHONY: docker-tox-py312 docker-tox-py311 docker-tox-py310
docker-test-py312: TOX_ARGS="-e clean,py312,py312-report"
docker-test-py312: docker-tox
docker-test-py311: TOX_ARGS="-e clean,py311,py311-report"
docker-test-py311: docker-tox
docker-test-py310: TOX_ARGS="-e clean,py310,py310-report"
docker-test-py310: docker-tox
# Run all tox test suites, but separately to check code coverage individually
.PHONY: docker-test-all
docker-test-all:
make docker-test-py310
make docker-test-py311
make docker-test-py312
# Run mypy using all different (or specific) Python versions in Docker
.PHONY: docker-mypy-all docker-mypy-py312 docker-mypy-py311 docker-mypy-py310
docker-mypy-all: TOX_ARGS="-e py312-mypy,py311-mypy,py310-mypy"
docker-mypy-all: docker-tox
docker-mypy-py312: TOX_ARGS="-e py312-mypy"
docker-mypy-py312: docker-tox
docker-mypy-py311: TOX_ARGS="-e py311-mypy"
docker-mypy-py311: docker-tox
docker-mypy-py310: TOX_ARGS="-e py310-mypy"
docker-mypy-py310: docker-tox
# Pull the latest image of the multi-python Docker image
.PHONY: docker-pull
docker-pull:
docker pull $(DOCKER_MULTI_PYTHON_IMAGE)
# Cleanup
# -------
.PHONY: clean
clean:
rm -rf .coverage .pytest_cache reports src/validataclass/_version.py .tox .tox_docker .eggs src/*.egg-info venv
.PHONY: clean-dist
clean-dist:
rm -rf dist/
.PHONY: clean-all
clean-all: clean clean-dist