-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile.common
84 lines (68 loc) · 2.39 KB
/
Makefile.common
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
MAKEFLAGS += --no-print-directory --silent
PYTHONPATH ?= $(CURDIR)
PYTHON_COVERAGE ?= webapp
.PHONY: _help
_help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' Makefile | \
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: _runpyapp
_runpyapp: # runs the aiohttp server
ifdef KILL_PREVIOUS
-kill $$(ps ux | grep -e "webapp.app serve" | grep -v grep | awk '{ print $$2 }') > /dev/null 2>&1
endif
@python -m 'webapp.app' serve
.PHONY: _pipshell
_pipshell: # run pipenv shell
pipenv install --dev
pipenv shell
.PHONY: _test-pythonunittest
_test-pythonunittest: # run only python unit tests
@echo "pytest ..."
cd $(PYTHONPATH) && pytest --cov-report=term-missing --cov $(PYTHON_COVERAGE)
.PHONY: _test-complexity
_test-complexity: # run only complexity analysis (radon)
@echo "radon ..."
@radon cc .
.PHONY: _test-security
_test-security: # run only security analysis (bandit)
@echo "bandit ..."
@bandit -r .
.PHONY: _test-lint-pythonflake8
_test-lint-pythonflake8:
@echo "flake8 ..."
@cd ../ && flake8 $(PYTHON_MODULES)
.PHONY: _test-lint-pythonpylint
_test-lint-pythonpylint:
@echo "pylint ..."
@cd ../ && pylint $(PYTHON_MODULES)
.PHONY: _test-lint-python
_test-lint-python:
FAILED=0; \
$(MAKE) _test-lint-pythonflake8 || FAILED=1; \
$(MAKE) _test-lint-pythonpylint || FAILED=1; \
[ "$${FAILED}" = "0" ] || exit 1
.PHONY: _test-lint-docker
_test-lint-docker: # run only dockerfile linter (hadolint)
@echo "hadolint ..."
@command -v hadolint > /dev/null || (echo 'hadolint not installed!'; exit 1)
@if find . -type f -name "Dockerfile*" | grep -q .; then find . -type f -name "Dockerfile*" | xargs -n1 hadolint; fi
.PHONY: _test-lint-shellcheck
_test-lint-shellcheck: # run only shell/bash linter (shellcheck)
@echo "shellcheck ..."
@command -v shellcheck > /dev/null || (echo 'shellcheck not installed!'; exit 1)
@if find . -type f -name "*.sh" | grep -q .; then find . -type f -name "*.sh" | xargs -n1 shellcheck; fi
.PHONY: _lint
_lint: # generic linters
FAILED=0; \
$(MAKE) _test-complexity || FAILED=1; \
$(MAKE) _test-lint-docker || FAILED=1; \
$(MAKE) _test-lint-python || FAILED=1; \
$(MAKE) _test-lint-shellcheck || FAILED=1; \
$(MAKE) _test-security || FAILED=1; \
[ "$${FAILED}" = "0" ] || exit 1
.PHONY: _tests
_tests: # run all tests and linters for this repo
FAILED=0; \
$(MAKE) test || FAILED=1; \
$(MAKE) lint || FAILED=1; \
[ "$${FAILED}" = "0" ] || exit 1