blob: fb56e3a50728ab324377317b4ef0274432b7d23d [file] [log] [blame]
Joey Armstrongdd334492023-07-09 17:59:02 -04001# -*- makefile -*-
2# -----------------------------------------------------------------------
3# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17# SPDX-FileCopyrightText: 2022 Open Networking Foundation (ONF) and the ONF Contributors
18# SPDX-License-Identifier: Apache-2.0
19# -----------------------------------------------------------------------
20
21$(if $(DEBUG),$(warning ENTER))
22
23--onf-mk-lint-yaml-- := true# # Inhibit loading downstream lint-yaml targets
24
25# yamllint := $(env-clean) yamllint
26# yamllint := $(activate) && yamllint
27
28YAMLLINT = $(activate) && yamllint
29
30## -------------------------------
31## Add requirement(s) for checking
32## -------------------------------
33yamllint-cfg := yamllint.helm
34yamllint-conf = $(wildcard $(yamllint-cfg) $(ONF_MAKEDIR)/lint/yaml/$(yamllint-cfg))
35yamllint-args += $(addprefix --config-file$(space),$(yamllint-conf))
36yamllint-args += --strict
37
38## -----------------------------------------------------------------------
39## Intent: Use the yaml command to perform syntax checking.
40## -----------------------------------------------------------------------
41ifndef NO-LINT-YAML
42 # lint-yaml-mode := $(if $(have-yaml-files),modified,all)
43 lint : lint-yaml
44 lint-yaml : lint-yaml-votlha-lib-go
45# lint-yaml : lint-yaml-all-votlha-lib-go-$(lint-yaml-mode)
46endif# NO-LINT-YAML
47
48## -----------------------------------------------------------------------
49## ----------------------------------------------------------------------
50lint-yaml-votlha-lib-go: lint-yaml-cmd-version
51
52 $(call banner-enter,Target $@)
53 $(HIDE)$(MAKE) --no-print-directory lint-yaml-install
54
55 $(HIDE)$(env-clean) $(call gen-yaml-find-cmd) \
56 | $(env-clean) $(xargs-cmd) -I'{}' \
57 bash -c "$(YAMLLINT) $(yamllint-args) {}"
58 $(call banner-leave,Target $@)
59
60## -----------------------------------------------------------------------
61## Intent: Display command usage
62## -----------------------------------------------------------------------
63help::
64 # lint-yaml help already displayed by lint/yaml/help.mk
65 ifdef VERBOSE
66 @echo ' $(MAKE) lint-yaml YAML_FILES=...'
67 @echo ' lint-yaml-votlha-lib-go lint-yaml for repo:voltha-lib-go'
68 endif
69
70$(if $(DEBUG),$(warning LEAVE))
71
72# [EOF]