-
Notifications
You must be signed in to change notification settings - Fork 75
/
Makefile
149 lines (122 loc) · 2.91 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
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
# SPDX-FileCopyrightText: 2019–2024 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 =
BLACK_COMMAND_FLAG =
ISORT_COMMAND_FLAG =
MYPY_COMMAND_FLAG =
else
POETRY_COMMAND_FLAG = -
PIP_COMMAND_FLAG = -
SECRETS_COMMAND_FLAG = -
BLACK_COMMAND_FLAG = -
ISORT_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 ($(BLACK_STRICT), 1)
BLACK_COMMAND_FLAG =
else ifeq ($(BLACK_STRICT), 0)
BLACK_COMMAND_FLAG = -
endif
ifeq ($(ISORT_STRICT), 1)
ISORT_COMMAND_FLAG =
else ifeq ($(ISORT_STRICT), 0)
ISORT_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:
$(BLACK_COMMAND_FLAG)poetry run black --diff --check ./
$(ISORT_COMMAND_FLAG)poetry run isort --check-only .
$(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: mypy
mypy:
poetry run mypy
.PHONY: ruff
ruff:
poetry run ruff check src/pynguin
.PHONY: isort
isort:
poetry run isort .
.PHONY: black
black:
poetry run black .
update-docs-requirements:
poetry export -o docs/requirements.txt --with docs --without-hashes
.PHONY: check
check: update-docs-requirements isort black mypy ruff 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