-
Notifications
You must be signed in to change notification settings - Fork 85
Expand file tree
/
Copy pathMakefile
More file actions
257 lines (200 loc) · 7.57 KB
/
Copy pathMakefile
File metadata and controls
257 lines (200 loc) · 7.57 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
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
256
257
# 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)
# Sync with .github/workflows/shellcheck.yaml
SHELL_SCRIPTS=demo/demo-tekton.sh \
scripts/create_release_pr \
scripts/install_dev_tools \
scripts/pre-commit \
scripts/run-mockoon-tests \
scripts/setup-pre-commit-hook \
scripts/run-pelorus-e2e-tests
.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
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
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
.git/hooks/pre-commit: scripts/pre-commit
./scripts/setup-pre-commit-hook
## cli_dev_tools: install all necessary CLI dev tools
.PHONY: cli_dev_tools
cli_dev_tools:
./scripts/install_dev_tools -v $(PELORUS_VENV)
## 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 \
.git/hooks/pre-commit
$(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 -v $(PELORUS_VENV) -c oc,helm
$(info **** To run VENV: $$source ${PELORUS_VENV}/bin/activate)
$(info **** To later deactivate VENV: $$deactivate)
# Release
.PHONY: release minor-release major-release
release:
./scripts/create_release_pr
minor-release:
./scripts/create_release_pr -i
major-release:
./scripts/create_release_pr -m
.PHONY: mockoon-tests
mockoon-tests: $(PELORUS_VENV)
. ${PELORUS_VENV}/bin/activate && \
./scripts/run-mockoon-tests
# 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 -o konveyor -e failure,gitlab_committime,gitea_committime,bitbucket_committime,jira_committime,jira_custom_committime -t
e2e-tests-scenario-1: e2e-tests-dev-env
. ${PELORUS_VENV}/bin/activate && \
./scripts/run-pelorus-e2e-tests -f "periodic/quay_images_latest.yaml" -o konveyor -e failure,gitlab_committime,gitea_committime,bitbucket_committime,jira_committime,jira_custom_committime -t
e2e-tests-scenario-2: e2e-tests-dev-env
. ${PELORUS_VENV}/bin/activate && \
./scripts/run-pelorus-e2e-tests -f "periodic/different_deployment_methods.yaml"
# Integration tests
## integration-tests: pytest -rap -m integration
.PHONY: integration-tests
integration-tests: $(PELORUS_VENV)
. ${PELORUS_VENV}/bin/activate && \
coverage run -m pytest -rap -m "integration" && \
coverage report
# 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 && \
coverage run -m pytest -rap -m "not integration and not mockoon" && \
coverage report
# 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
# 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 exporters scripts
black-check: $(PELORUS_VENV)
. ${PELORUS_VENV}/bin/activate && \
black --check exporters scripts
isort: $(PELORUS_VENV)
. ${PELORUS_VENV}/bin/activate && \
isort exporters scripts
isort-check: $(PELORUS_VENV)
. ${PELORUS_VENV}/bin/activate && \
isort --check exporters scripts
# Linting
.PHONY: lint python-lint pylava chart-lint chart-lint-optional shellcheck shellcheck-optional chart-check-bump
## lint: lint python code, shell scripts, and helm charts
lint: python-lint chart-lint-optional shellcheck-optional
## python-lint: lint python files
python-lint: $(PELORUS_VENV)
@echo 🐍 🦙 Linting with pylama
. ${PELORUS_VENV}/bin/activate && \
pylama
pylava: python-lint
typecheck:
mypy
# 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, but is not currently set up for CI.
## chart-check-bump: lint helm charts, attempting to bump their versions if required
chart-check-bump: $(PELORUS_VENV)
./scripts/install_dev_tools -v $(PELORUS_VENV) -c ct && \
. ${PELORUS_VENV}/bin/activate && \
./scripts/chart-check-and-bump
chart-lint: $(PELORUS_VENV)
./scripts/install_dev_tools -v $(PELORUS_VENV) -c ct && \
. ${PELORUS_VENV}/bin/activate && \
ct lint --config ct.yaml
ifneq (, $(CHART_TEST))
chart-lint-optional: chart-lint
else
chart-lint-optional:
$(warning chart test (ct) not installed, skipping)
endif
shellcheck:
@echo "🐚 📋 Linting shell scripts with shellcheck"
$(SHELLCHECK) $(SHELL_SCRIPTS)
ifneq (, $(SHELLCHECK))
shellcheck-optional: shellcheck
else
shellcheck-optional:
$(warning 🐚 ⏭ Shellcheck not found, skipping)
endif
# Testing
.PHONY: test
# -r: show extra test summaRy: (a)ll except passed, (p)assed
# because using (A)ll includes stdout
# -m filters out integration tests
test: $(PELORUS_VENV)
. ${PELORUS_VENV}/bin/activate && pytest -r ap -m "not integration"
# 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