This repository has been archived by the owner on Jul 15, 2024. It is now read-only.
forked from microsoft/codamosa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
180 lines (149 loc) · 3.73 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
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
# SPDX-FileCopyrightText: 2019–2022 Pynguin Contributors
#
# SPDX-License-Identifier: LGPL-3.0-or-later
SHELL := /usr/bin/env bash
IMAGE := pynguin
VERSION=$(shell git rev-parse --short HEAD)
ifeq ($(STRICT), 1)
POETRY_COMMAND_FLAG =
PIP_COMMAND_FLAG =
SAFETY_COMMAND_FLAG =
BANDIT_COMMAND_FLAG =
SECRETS_COMMAND_FLAG =
BLACK_COMMAND_FLAG =
DARGLINT_COMMAND_FLAG =
ISORT_COMMAND_FLAG =
MYPY_COMMAND_FLAG =
else
POETRY_COMMAND_FLAG = -
PIP_COMMAND_FLAG = -
SAFETY_COMMAND_FLAG = -
BANDIT_COMMAND_FLAG = -
SECRETS_COMMAND_FLAG = -
BLACK_COMMAND_FLAG = -
DARGLINT_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 ($(SAFETY_STRICT), 1)
SAFETY_COMMAND_FLAG =
else ifeq ($(SAFETY_STRICT), 0)
SAFETY_COMMAND_FLAG = -
endif
ifeq ($(BANDIT_STRICT), 1)
BANDIT_COMMAND_FLAG =
else ifeq ($(BANDIT_STRICT), 0)
BANDIT_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 ($(DARGLINT_STRICT), 1)
DARGLINT_COMMAND_FLAG =
else ifeq ($(DARGLINT_STRICT), 0)
DARGLINT_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://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
.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
$(SAFETY_COMMAND_FLAG)poetry run safety check --full-report
$(BANDIT_COMMAND_FLAG)poetry run bandit -ll -r pynguin
.PHONY: check-style
check-style:
$(BLACK_COMMAND_FLAG)poetry run black --diff --check ./
$(DARGLINT_COMMAND_FLAG)poetry run darglint -v 2 pynguin/**/*.py
$(ISORT_COMMAND_FLAG)poetry run isort --check-only . --profile black
$(MYPY_COMMAND_FLAG)poetry run mypy pynguin
.PHONY: codestyle
codestyle:
poetry run pre-commit run --all-files
.PHONY: test
test:
poetry run pytest --cov=pynguin --cov=tests --cov-branch --cov-report=term-missing --cov-report html:cov_html tests/
.PHONY: mypy
mypy:
poetry run mypy pynguin
.PHONY: pylint
pylint:
poetry run pylint pynguin
.PHONY: flake8
flake8:
poetry run flake8 --exclude replication,docs .
.PHONY: isort
isort:
poetry run isort . --profile black
.PHONY: black
black:
poetry run black --exclude '/replication/' .
.PHONY: darglint
darglint:
poetry run darglint -v 2 pynguin/**/*.py
.PHONY: check
check: isort black mypy flake8 pylint darglint 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 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