-
Notifications
You must be signed in to change notification settings - Fork 83
/
Makefile
255 lines (199 loc) · 7.99 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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# Variable setup and preflight checks
# may override with environment variable
PYTHON_BINARY?=python3
ifndef PELORUS_VENV
PELORUS_VENV=.venv
endif
ifeq (, $(shell which $(PYTHON_BINARY) ))
$(error "PYTHON=$(PYTHON_BINARY) binary not found in $(PATH)")
endif
SYS_PYTHON_VER=$(shell $(PYTHON_BINARY) -c 'from sys import version_info; \
print("%d.%d" % version_info[0:2])')
$(info Found system python version: $(SYS_PYTHON_VER));
PYTHON_VER_CHECK=$(shell $(PYTHON_BINARY) scripts/python-version-check.py)
ifneq ($(strip $(PYTHON_VER_CHECK)),)
$(error $(PYTHON_VER_CHECK). You may set the PYTHON_BINARY env var to specify a compatible version)
endif
CHART_TEST=$(shell which ct)
SHELLCHECK=$(shell which shellcheck)
.PHONY: default
default: \
dev-env
.PHONY: all
all: default
# note the following is required for the makefile help
## TARGET: DESCRIPTION
## ------: -----------
## help: print each make target with a description
.PHONY: help
help:
@echo ""
@(printf ""; sed -n 's/^## //p' Makefile) | column -t -s :
# Environment setup
$(PELORUS_VENV): exporters/requirements.txt exporters/requirements-dev.txt docs/requirements.txt
test -d ${PELORUS_VENV} || ${PYTHON_BINARY} -m venv ${PELORUS_VENV}
. ${PELORUS_VENV}/bin/activate && \
pip install -U pip && \
pip install -r exporters/requirements.txt \
-r exporters/requirements-dev.txt \
-r docs/requirements.txt
touch ${PELORUS_VENV}
.PHONY: exporters
exporters: $(PELORUS_VENV)
. ${PELORUS_VENV}/bin/activate && \
pip install -e exporters/
.PHONY: git-blame
git-blame:
@echo "⎇ Configuring git to ignore certain revs for annotations"
$(eval IGNORE_REVS_FILE = $(shell git config blame.ignoreRevsFile))
if [ "$(IGNORE_REVS_FILE)" != ".git-blame-ignore-revs" ]; then \
git config blame.ignoreRevsFile .git-blame-ignore-revs; \
fi
pre-commit-setup: $(PELORUS_VENV)
. ${PELORUS_VENV}/bin/activate && \
pre-commit install
## cli_dev_tools: install all necessary CLI dev tools
.PHONY: cli_dev_tools
cli_dev_tools: $(PELORUS_VENV)
. ${PELORUS_VENV}/bin/activate && \
./scripts/install_dev_tools.sh -v $(PELORUS_VENV)
# for installing a single CLI dev tool
$(PELORUS_VENV)/bin/%: $(PELORUS_VENV)
. ${PELORUS_VENV}/bin/activate && \
./scripts/install_dev_tools.sh -v $(PELORUS_VENV) -c $(notdir $@)
# system-level doc requirements
ifeq (Darwin, $(shell uname -s))
/opt/homebrew/Cellar/%:
brew install $(notdir $@)
system-doc-deps: /opt/homebrew/Cellar/libffi /opt/homebrew/Cellar/cairo
else
system-doc-deps:
endif
## dev-env: set up everything needed for development (install tools, set up virtual environment, git configuration)
dev-env: $(PELORUS_VENV) cli_dev_tools exporters git-blame \
pre-commit-setup
$(info **** To run VENV: $$source ${PELORUS_VENV}/bin/activate)
$(info **** To later deactivate VENV: $$deactivate)
.PHONY: e2e-tests-dev-env
## e2e-tests-dev-env: set up environment required to run e2e tests
e2e-tests-dev-env: $(PELORUS_VENV)
. ${PELORUS_VENV}/bin/activate && \
./scripts/install_dev_tools.sh -v $(PELORUS_VENV) -c oc,helm
$(info **** To run VENV: $$source ${PELORUS_VENV}/bin/activate)
$(info **** To later deactivate VENV: $$deactivate)
.PHONY: mockoon-tests
mockoon-tests: $(PELORUS_VENV)
. ${PELORUS_VENV}/bin/activate && \
./scripts/run-mockoon-tests.sh
# End to end tests
## e2e-tests: installs pelorus, mongo-todolist and tests commit and deploy exporters
## e2e-tests-scenario-1: run e2e-tests with latest quay images
## e2e-tests-scenario-2: run e2e-tests for deploytime exporter using different exporter install methods
.PHONY: e2e-tests e2e-tests-scenario-1 e2e-tests-scenario-1
e2e-tests: e2e-tests-dev-env
. ${PELORUS_VENV}/bin/activate && \
./scripts/run-pelorus-e2e-tests.sh -o konveyor -a -t
e2e-tests-scenario-1: e2e-tests-dev-env
. ${PELORUS_VENV}/bin/activate && \
./scripts/run-pelorus-e2e-tests.sh -f "periodic/quay_images_latest.yaml" -o konveyor -a -t
e2e-tests-scenario-2: e2e-tests-dev-env
. ${PELORUS_VENV}/bin/activate && \
./scripts/run-pelorus-e2e-tests.sh -f "periodic/different_deployment_methods.yaml"
# Integration tests
## integration-tests: pytest everything marked as integration
.PHONY: integration-tests
integration-tests: $(PELORUS_VENV)
. ${PELORUS_VENV}/bin/activate && \
pytest -rap -m "integration"
# Unit tests
## unit-tests: pytest everything minus integration and mockoon
.PHONY: unit-tests
unit-tests: $(PELORUS_VENV)
# -r: show extra test summaRy: (a)ll except passed, (p)assed
# because using (A)ll includes stdout
# -m filters out integration tests
. ${PELORUS_VENV}/bin/activate && \
pytest -rap -m "not integration and not mockoon"
# Prometheus ruels
## test-prometheusrules: test prometheus with data in _test/test_promethusrules
.PHONY: test-prometheusrules
test-prometheusrules: $(PELORUS_VENV)
. ${PELORUS_VENV}/bin/activate && \
./_test/test_prometheusrules.sh
# Conf tests
## conf-tests: execute _test/conftest.sh
.PHONY: conf-tests
conf-tests: $(PELORUS_VENV)
. ${PELORUS_VENV}/bin/activate && \
./_test/conftest.sh
# Formatting
.PHONY: format black isort format-check black-check isort-check
format: $(PELORUS_VENV) black isort
## format-check: check that all python code is properly formatted
format-check: $(PELORUS_VENV) black-check isort-check
black: $(PELORUS_VENV)
. ${PELORUS_VENV}/bin/activate && \
black .
black-check: $(PELORUS_VENV)
. ${PELORUS_VENV}/bin/activate && \
black --check .
isort: $(PELORUS_VENV)
. ${PELORUS_VENV}/bin/activate && \
isort .
isort-check: $(PELORUS_VENV)
. ${PELORUS_VENV}/bin/activate && \
isort --check .
# Linting
.PHONY: lint python-lint pylava chart-lint chart-lint-optional shellcheck typecheck
## lint: lint python code, shell scripts, and helm charts
lint: python-lint chart-lint-optional shellcheck
## python-lint: lint python files
python-lint: $(PELORUS_VENV)
@echo 🐍 🦙 Linting with pylama
. ${PELORUS_VENV}/bin/activate && \
pylama
pylava: python-lint
typecheck: $(PELORUS_VENV)
$(warning Type checking is not fully ready yet, the issues below may be ignorable)
. ${PELORUS_VENV}/bin/activate && \
pyright
# chart-lint allows us to fail properly when run from CI,
# while chart-lint-optional allows graceful degrading when
# devs don't have it installed.
# shellcheck follows a similar pattern.
## chart-lint: lint helm charts and check all project versions
chart-lint: $(PELORUS_VENV) $(PELORUS_VENV)/bin/ct $(PELORUS_VENV)/bin/helm
. ${PELORUS_VENV}/bin/activate && \
./scripts/chart-test.sh
ifneq (, $(CHART_TEST))
chart-lint-optional: chart-lint
else
chart-lint-optional:
$(warning chart test (ct) not installed, skipping)
endif
shellcheck: $(PELORUS_VENV) $(PELORUS_VENV)/bin/shellcheck
@echo "🐚 📋 Linting shell scripts with shellcheck"
. ${PELORUS_VENV}/bin/activate && \
shellcheck $(shell find . -name '*.sh' -type f | grep -v 'venv/\|git/\|.pytest_cache/\|htmlcov/\|_test/test_helper/\|_test/bats\|_test/conftest')
## doc-check: Check if there is any problem with the project documentation generation
doc-check: $(PELORUS_VENV)
. ${PELORUS_VENV}/bin/activate && mkdocs build --verbose --strict
## pre-commit-all: Runs pre-commit library against all files of the project
pre-commit-all: $(PELORUS_VENV)
. ${PELORUS_VENV}/bin/activate && \
pre-commit run --all-files
## update-requirements: Updates project's Python dependencies files. Requires Poetry executable
update-requirements: $(PELORUS_VENV)
. ${PELORUS_VENV}/bin/activate && \
poetry export --format requirements.txt --output docs/requirements.txt --only doc && \
poetry export --format requirements.txt --output exporters/requirements-dev.txt --only dev && \
poetry export --format requirements.txt --output exporters/requirements.txt
## openshift-check-versions: Checks if OpenShift versions used by the project are the 4 latest minor stable releases
openshift-check-versions: $(PELORUS_VENV)
. ${PELORUS_VENV}/bin/activate && \
./scripts/check_openshift_version.py
# Cleanup
## clean-dev-env: remove the virtual environment and clean up all .pyc files
clean-dev-env:
rm -rf ${PELORUS_VENV}
find . -iname "*.pyc" -delete