Zack Williams | 583833b | 2020-04-10 08:17:44 -0700 | [diff] [blame] | 1 | # kind-voltha testing Makefile |
| 2 | # |
| 3 | # SPDX-FileCopyrightText: © 2020 Open Networking Foundation |
| 4 | # SPDX-License-Identifier: Apache-2.0 |
| 5 | |
| 6 | SHELL = bash -eu -o pipefail |
| 7 | |
| 8 | .DEFAULT_GOAL := help |
Zack Williams | ded60cb | 2020-04-13 10:02:20 -0700 | [diff] [blame] | 9 | .PHONY: test shellcheck yamllint lint-json help |
Zack Williams | 583833b | 2020-04-10 08:17:44 -0700 | [diff] [blame] | 10 | |
Zack Williams | ded60cb | 2020-04-13 10:02:20 -0700 | [diff] [blame] | 11 | test: shellcheck lint-json yamllint ## run all tests |
Zack Williams | 583833b | 2020-04-10 08:17:44 -0700 | [diff] [blame] | 12 | |
David Bainbridge | 8d21b0f | 2020-04-21 16:03:00 -0700 | [diff] [blame] | 13 | SHELL_FILES := voltha |
Zack Williams | 583833b | 2020-04-10 08:17:44 -0700 | [diff] [blame] | 14 | shellcheck: ## check shell scripts with shellcheck |
| 15 | shellcheck --version |
David Bainbridge | 8d21b0f | 2020-04-21 16:03:00 -0700 | [diff] [blame] | 16 | shellcheck $(SHELL_FILES) |
Zack Williams | 583833b | 2020-04-10 08:17:44 -0700 | [diff] [blame] | 17 | |
Matteo Scandolo | 657e13c | 2020-07-28 11:41:42 -0700 | [diff] [blame] | 18 | YAML_FILES ?= $(shell find . -type f \( -name '*.yaml' -o -name '*.yml' \) -print ) |
Zack Williams | 583833b | 2020-04-10 08:17:44 -0700 | [diff] [blame] | 19 | yamllint: ## 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 | |
| 25 | JSON_FILES ?= $(shell find . -type f -name '*.json' -print ) |
Zack Williams | ded60cb | 2020-04-13 10:02:20 -0700 | [diff] [blame] | 26 | lint-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 Williams | 583833b | 2020-04-10 08:17:44 -0700 | [diff] [blame] | 31 | |
Zack Williams | ded60cb | 2020-04-13 10:02:20 -0700 | [diff] [blame] | 32 | help: ## Print help for each Makefile target |
Zack Williams | 583833b | 2020-04-10 08:17:44 -0700 | [diff] [blame] | 33 | @echo kind-voltha Makefile targets |
| 34 | @echo |
Zack Williams | ded60cb | 2020-04-13 10:02:20 -0700 | [diff] [blame] | 35 | @grep '^[[:alnum:]_-]*:.* ##' $(MAKEFILE_LIST) \ |
Zack Williams | 583833b | 2020-04-10 08:17:44 -0700 | [diff] [blame] | 36 | | sort | awk 'BEGIN {FS=":.* ## "}; {printf "%-25s %s\n", $$1, $$2};' |