blob: ee3d79cb7b4c9fd0647768a3b3972f468563e968 [file] [log] [blame]
Zack Williams583833b2020-04-10 08:17:44 -07001# kind-voltha testing Makefile
2#
3# SPDX-FileCopyrightText: © 2020 Open Networking Foundation
4# SPDX-License-Identifier: Apache-2.0
5
6SHELL = bash -eu -o pipefail
7
8.DEFAULT_GOAL := help
Zack Williamsded60cb2020-04-13 10:02:20 -07009.PHONY: test shellcheck yamllint lint-json help
Zack Williams583833b2020-04-10 08:17:44 -070010
Zack Williamsded60cb2020-04-13 10:02:20 -070011test: shellcheck lint-json yamllint ## run all tests
Zack Williams583833b2020-04-10 08:17:44 -070012
David Bainbridge8d21b0f2020-04-21 16:03:00 -070013SHELL_FILES := voltha
Zack Williams583833b2020-04-10 08:17:44 -070014shellcheck: ## check shell scripts with shellcheck
15 shellcheck --version
David Bainbridge8d21b0f2020-04-21 16:03:00 -070016 shellcheck $(SHELL_FILES)
Zack Williams583833b2020-04-10 08:17:44 -070017
Matteo Scandolo657e13c2020-07-28 11:41:42 -070018YAML_FILES ?= $(shell find . -type f \( -name '*.yaml' -o -name '*.yml' \) -print )
Zack Williams583833b2020-04-10 08:17:44 -070019yamllint: ## lint check YAML files with yamllint
20 yamllint --version
21 yamllint \
22 -d "{extends: default, rules: {line-length: {max: 99}}}" \
23 -s $(YAML_FILES)
24
25JSON_FILES ?= $(shell find . -type f -name '*.json' -print )
Zack Williamsded60cb2020-04-13 10:02:20 -070026lint-json: ## lint check JSON files by loading them with python
27 for jsonfile in $(JSON_FILES); do \
28 echo "Validating json file: $$jsonfile" ;\
29 python -m json.tool $$jsonfile > /dev/null ;\
30 done
Zack Williams583833b2020-04-10 08:17:44 -070031
Zack Williamsded60cb2020-04-13 10:02:20 -070032help: ## Print help for each Makefile target
Zack Williams583833b2020-04-10 08:17:44 -070033 @echo kind-voltha Makefile targets
34 @echo
Zack Williamsded60cb2020-04-13 10:02:20 -070035 @grep '^[[:alnum:]_-]*:.* ##' $(MAKEFILE_LIST) \
Zack Williams583833b2020-04-10 08:17:44 -070036 | sort | awk 'BEGIN {FS=":.* ## "}; {printf "%-25s %s\n", $$1, $$2};'