-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
138 lines (112 loc) · 3.66 KB
/
Makefile
File metadata and controls
138 lines (112 loc) · 3.66 KB
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# 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 all locally installed Python interpreters
.PHONY: tox
tox:
tox run
# Run tox suite with the latest installed Python version
.PHONY: tox-latest
tox-latest:
tox run -e clean,py,report,flake8,mypy
# 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 pytest, but limited to the type checker tests in `tests/mypy`.
.PHONY: test
test-typing:
tox run -e pytest-mypy
# 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
# Base target for running tox in a multi-python Docker container (don't use directly)
.PHONY: _docker-tox
_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 complete tox test suite in a multi-python Docker container
.PHONY: docker-tox
docker-tox: TOX_ARGS='-e clean,py310,py311,py312,py313,py314,report,flake8,mypy'
docker-tox: _docker-tox
# Run partial tox test suites in Docker
.PHONY: docker-test-py314 docker-test-py313 docker-test-py312 docker-test-py311 docker-test-py310
docker-test-py314: TOX_ARGS="-e clean,py314,py314-report"
docker-test-py314: _docker-tox
docker-test-py313: TOX_ARGS="-e clean,py313,py313-report"
docker-test-py313: _docker-tox
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
make docker-test-py313
make docker-test-py314
# Run mypy using all different (or specific) Python versions in Docker
.PHONY: docker-mypy-py314 docker-mypy-all docker-mypy-py313 docker-mypy-py312 docker-mypy-py311 docker-mypy-py310
docker-mypy-all: TOX_ARGS="-e py310-mypy,py311-mypy,py312-mypy,py313-mypy,py314-mypy"
docker-mypy-all: _docker-tox
docker-mypy-py314: TOX_ARGS="-e py314-mypy"
docker-mypy-py314: _docker-tox
docker-mypy-py313: TOX_ARGS="-e py313-mypy"
docker-mypy-py313: _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