-
Notifications
You must be signed in to change notification settings - Fork 97
Expand file tree
/
Copy pathMakefile
More file actions
184 lines (146 loc) · 3.56 KB
/
Makefile
File metadata and controls
184 lines (146 loc) · 3.56 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# SPDX-FileCopyrightText: 2019–2026 Pynguin Contributors
#
# SPDX-License-Identifier: MIT
SHELL := /usr/bin/env bash
IMAGE := pynguin
VERSION=$(shell git rev-parse --short HEAD)
ifeq ($(STRICT), 1)
POETRY_COMMAND_FLAG =
PIP_COMMAND_FLAG =
SECRETS_COMMAND_FLAG =
MYPY_COMMAND_FLAG =
else
POETRY_COMMAND_FLAG = -
PIP_COMMAND_FLAG = -
SECRETS_COMMAND_FLAG = -
MYPY_COMMAND_FLAG = -
endif
ifeq ($(POETRY_STRICT), 1)
POETRY_COMMAND_FLAG =
else ifeq ($(POETRY_STRICT), 0)
POETRY_COMMAND_FLAG = -
endif
ifeq ($(PIP_STRICT), 1)
PIP_COMMAND_FLAG =
else ifeq ($(PIP_STRICT), 0)
PIP_COMMAND_FLAG = -
endif
ifeq ($(SECRETS_STRICT), 1)
SECRETS_COMMAND_FLAG =
else ifeq ($(SECRETS_STRICT), 0)
SECRETS_COMMAND_FLAG = -
endif
ifeq ($(MYPY_STRICT), 1)
MYPY_COMMAND_FLAG =
else ifeq ($(MYPY_STRICT), 0)
MYPY_COMMAND_FLAG = -
endif
.PHONY: download-poetry
download-poetry:
curl -sSL https://install.python-poetry.org | python3 -
.PHONY: install
install:
poetry lock -n
poetry install -n
ifneq ($(NO_PRE_COMMIT), 1)
poetry run pre-commit install
endif
.PHONY: check-safety
check-safety:
$(POETRY_COMMAND_FLAG)poetry check
$(PIP_COMMAND_FLAG)pip check
.PHONY: check-style
check-style:
$(MYPY_COMMAND_FLAG)poetry run mypy
.PHONY: codestyle
codestyle:
poetry run pre-commit run --all-files
.PHONY: test
test:
poetry run pytest --cov=src --cov=tests --cov-report=term-missing --cov-report html:cov_html tests/
.PHONY: testp
testp:
poetry run pytest -n auto --cov=src --cov=tests --cov-report=term-missing --cov-report html:cov_html tests/
.PHONY: mypy
mypy:
poetry run mypy
.PHONY: ruff
ruff:
poetry run ruff check src/pynguin
.PHONY: ruff-format
ruff-format:
poetry run ruff format .
.PHONY: check
check: mypy ruff ruff-format test
.PHONY: lint
lint: test check-safety check-style
.PHONY: documentation
documentation:
poetry run sphinx-build docs docs/_build
.PHONY: docker
docker:
@echo Building docker $(IMAGE):$(VERSION) ...
docker build \
-t $(IMAGE):$(VERSION) . \
-f ./docker/Dockerfile --no-cache
.PHONY: clean_docker
clean_docker:
@echo Removing docker $(IMAGE):$(VERSION) ...
docker rmi -f $(IMAGE):$(VERSION)
.PHONY: clean_build
clean_build:
rm -rf build/
rm -rf .hypothesis
rm -rf .mypy_cache
rm -rf .pytest_cache
rm -rf .ruff_cache
rm -rf cov_html
rm -rf dist
rm -rf docs/_build
find . -name pynguin-report -type d | xargs rm -rf {};
find . -name ".coverage*" -type f | xargs rm -rf {};
find . -name "*.pyc" -type f | xargs rm -rf {};
.PHONY: clean
clean: clean_build clean_docker
PYVERSIONS = 3.10 3.11 3.12 3.13 3.14
.PHONY: setup-envs
setup-envs:
@for v in $(PYVERSIONS); do \
echo "=== Setting up .venv-$$v ==="; \
pyenv local $$v; \
python -m venv .venv-$$v; \
. .venv-$$v/bin/activate; \
poetry install --extras "openai numpy fandango-faker"; \
deactivate; \
done
@echo "=== All environments created ==="
define activate_template
@echo "Activating .venv-$(1)..."
@bash --rcfile <(echo "source .venv-$(1)/bin/activate") -i
endef
.PHONY: py310 py311 py312 py313 py314
py310:
$(call activate_template,3.10)
py311:
$(call activate_template,3.11)
py312:
$(call activate_template,3.12)
py313:
$(call activate_template,3.13)
py314:
$(call activate_template,3.14)
define test_template
@echo "Running tests in .venv-$(1)..."
@bash -c 'source .venv-$(1)/bin/activate && pytest'
endef
.PHONY: py310-test py311-test py312-test py313-test py314-test
py310-test:
$(call test_template,3.10)
py311-test:
$(call test_template,3.11)
py312-test:
$(call test_template,3.12)
py313-test:
$(call test_template,3.13)
py314-test:
$(call test_template,3.14)