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