3 PIPENV
:= PIPENV_VENV_IN_PROJECT
=true pipenv
4 BANDIT
:= $(PIPENV
) run bandit
5 COVERAGE
:= $(PIPENV
) run coverage
6 PYTEST
:= $(PIPENV
) run py.
test -s
-vv
7 YAPF
:= $(PIPENV
) run yapf
9 .PHONY
: help pipenv-check test-bandit test-docker test-format-python \
10 test-gui-crawl test-integration test-packaging test-pylint \
11 test-shellcheck test-unit test-unit-coverage-html
14 echo
$(MAKE
) -C
$(dir $(VENV
)) $(notdir $(VENV
))
15 @echo
"pipenv-check - Checks for security vulnerabilities/PEP 508 markers"
16 @echo
"test-bandit - Run bandit (security) tests"
17 @echo
"test-docker - Run docker tests"
18 @echo
"test-format-python - Test the python formatting"
19 @echo
"test-gui-crawl - Run GUI crawl test"
20 @echo
"test-integration - Run integration tests"
21 @echo
"test-packaging - Run packaging tests"
22 @echo
"test-pylint - Run pylint based tests"
23 @echo
"test-shellcheck - Run shellcheck tests"
24 @echo
"test-unit - Run unit tests"
25 @echo
"test-unit-coverage-html - Create HTML coverage report for unit tests"
27 # These target need to be phony so it is run every time because only the other
28 # makefile can determine that there's nothing to be done.
29 # TODO: Move everything to top level makefile?
30 .PHONY
: $(VENV
) bandit.ini
33 $(MAKE
) -C
$(dir $(VENV
)) $(notdir $(VENV
))
36 echo
-e
"[bandit]\ntargets: $$(./find-python-files | tr '\n' ',' | sed 's/,$$//')" > bandit.ini
41 test-bandit
: $(VENV
) bandit.ini
42 # Currently only care about high severity reported issues. Once this is reached,
43 # go and enable the medium/low checks.
44 $(BANDIT
) -c ..
/bandit.yaml
-r
-lll
--ini bandit.ini
$(BANDIT_OUTPUT_ARGS
)
47 $(MAKE
) -C ..
/docker test-lint-dockerfile test-lint-entrypoint
50 test-format-python
: $(VENV
) ..
/.style.yapf
51 # Explicitly specify --style [FILE] to prevent costly searching in parent directories
52 # for each file specified via command line
54 # There are some mixed up lines on stdout caused by the --parallel option.
55 # Nevertheless, we keep that option to get a big performance boost. GitHub issue
56 # opened for this problem: https://github.com/google/yapf/issues/644.
57 @PYTHON_FILES
=$${PYTHON_FILES-
$$(.
/find-python-files
)} ; \
58 $(YAPF
) --parallel
--style ..
/.style.yapf
--verbose
--diff
$$PYTHON_FILES | \
59 grep
'^+++ .*(reformatted)$$' | \
60 sed
-e
's/^+++ //' -e
's/[[:blank:]]*(reformatted)$$/:1:1: error: file needs formatting/'
62 test-gui-crawl
: $(VENV
)
63 $(PYTEST
) -T gui_crawl
$(realpath integration
/cmk
/gui
/test_crawl.py
)
65 test-integration
: $(VENV
)
66 $(PYTEST
) -T integration
$(realpath integration
)
68 test-packaging
: $(VENV
)
69 $(PYTEST
) -T packaging packaging
72 $(PYTEST
) -T pylint pylint
75 @CMK_DIR
="$(realpath ..)" ; \
76 ENTERPRISE_DIR
="$(realpath ../enterprise)" ; \
78 $(SHELLCHECK_OUTPUT_ARGS
) \
79 $$(grep
-l
'^#!/.*sh' $$CMK_DIR/agents
/* $$CMK_DIR/agents
/plugins
/* $$CMK_DIR/agents
/special
/* 2>/dev
/null
) \
80 "$$ENTERPRISE_DIR/agents/mk-remote-alert-handler"
85 test-unit-coverage-html
: $(VENV
)
86 $(COVERAGE
) run
--rcfile
=.coveragerc_unit
-m pytest
-T unit
; $(COVERAGE
) html