Makefile library merge with onf-make and voltha-lib-go

makefiles/
----------
  o Import standalone makefile directories to checkin smaller parts of a mega patch.
  o Build out directory hierarchy by topic and feature.

makefiles/lint/yaml/
--------------------
  o Pull in logic evolved in repo:voltha-lib-go.
  o Refactoring: support special snowflake targets by repository.
  o ci-management and voltha-lib-go use distinct yamllint.conf files.
  o Separate until there is time to review and consolidate.
  o Added deps for on-demand local install of yamllint.
    - requirements.txt could be used but every build would incur overhead.

Makefile
--------
  o Use latest syntax from repo:onf-make.
  o No need to set path variables, makefiles/include.mk can infer them.
  o Added a help target to explicitly display targets and suggestions.
  o Logic is bundled in libraries and use of 'make help' is not well known.

Change-Id: Id8eba6f914a7bfe9a31637901bd8fb78a387e0c2
diff --git a/makefiles/lint/include.mk b/makefiles/lint/include.mk
index 357b6f5..894f718 100644
--- a/makefiles/lint/include.mk
+++ b/makefiles/lint/include.mk
@@ -1,6 +1,25 @@
 # -*- makefile -*-
+# -*- makefile -*-
 # -----------------------------------------------------------------------
-# Copyright 2022 Open Networking Foundation (ONF) and the ONF Contributors
+# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-FileCopyrightText: 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+# SPDX-License-Identifier: Apache-2.0
+# -----------------------------------------------------------------------
+# https://gerrit.opencord.org/plugins/gitiles/onf-make
+# ONF.makefile.version = 1.2
 # -----------------------------------------------------------------------
 
 $(if $(DEBUG),$(warning ENTER))
@@ -9,15 +28,15 @@
 	@echo
 	@echo "[LINT]"
 
-include $(ONF_MAKE)/lint/groovy.mk
-include $(ONF_MAKE)/lint/jjb.mk
-include $(ONF_MAKE)/lint/json.mk
-include $(ONF_MAKE)/lint/makefile.mk
-include $(ONF_MAKE)/lint/python.mk
-include $(ONF_MAKE)/lint/shell.mk
-include $(ONF_MAKE)/lint/yaml.mk
-
-include $(ONF_MAKE)/lint/help.mk
+include $(ONF_MAKEDIR)/lint/groovy.mk
+include $(ONF_MAKEDIR)/lint/jjb.mk
+include $(ONF_MAKEDIR)/lint/json.mk
+include $(ONF_MAKEDIR)/lint/license/include.mk
+include $(ONF_MAKEDIR)/lint/makefile.mk
+include $(ONF_MAKEDIR)/lint/python/include.mk
+include $(ONF_MAKEDIR)/lint/shell.mk
+include $(ONF_MAKEDIR)/lint/tox/include.mk
+include $(ONF_MAKEDIR)/lint/yaml/include.mk
 
 $(if $(DEBUG),$(warning LEAVE))
 
diff --git a/makefiles/lint/license/include.mk b/makefiles/lint/license/include.mk
new file mode 100644
index 0000000..2b42049
--- /dev/null
+++ b/makefiles/lint/license/include.mk
@@ -0,0 +1,41 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -----------------------------------------------------------------------
+
+##-------------------##
+##---]  GLOBALS  [---##
+##-------------------##
+
+##-------------------##
+##---]  TARGETS  [---##
+##-------------------##
+ifndef NO-LINT-REUSE
+  lint : lint-license
+endif
+
+## -----------------------------------------------------------------------
+## Intent: Perform a lint check on makefile sources
+## -----------------------------------------------------------------------
+lint-license:
+	reuse --root . lint
+
+## -----------------------------------------------------------------------
+## Intent: Display command help
+## -----------------------------------------------------------------------
+help-summary ::
+	@echo '  lint-reuse              License syntax checking'
+
+# [EOF]
diff --git a/makefiles/lint/license/reuse.mk b/makefiles/lint/license/reuse.mk
new file mode 100644
index 0000000..5572bef
--- /dev/null
+++ b/makefiles/lint/license/reuse.mk
@@ -0,0 +1,41 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -----------------------------------------------------------------------
+
+##-------------------##
+##---]  GLOBALS  [---##
+##-------------------##
+
+##-------------------##
+##---]  TARGETS  [---##
+##-------------------##
+ifndef NO-LINT-REUSE
+  lint : lint-license
+endif
+
+## -----------------------------------------------------------------------
+## Intent: Perform a lint check on makefile sources
+## -----------------------------------------------------------------------
+lint-license:
+	reuse --root . lint
+
+## -----------------------------------------------------------------------
+## Intent: Display command help
+## -----------------------------------------------------------------------
+help-summary ::
+	@echo '  lint-reuse              License syntax checking"
+
+# [EOF]
diff --git a/makefiles/lint/python/find_utils.mk b/makefiles/lint/python/find_utils.mk
new file mode 100644
index 0000000..7ab4c4f
--- /dev/null
+++ b/makefiles/lint/python/find_utils.mk
@@ -0,0 +1,32 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Intent:
+#   o Construct a find command able to gather python files with filtering.
+#   o Used by library makefiles flake8.mk and pylint.mk for iteration.
+# -----------------------------------------------------------------------
+
+## -----------------------------------------------------------------------
+## Intent: Construct a string for invoking find \( excl-pattern \) -prune
+# -----------------------------------------------------------------------
+gen-python-find-excl = \
+  $(strip \
+	-name '__ignored__' \
+	$(foreach dir,$($(1)),-o -name $(dir)) \
+  )
+
+## -----------------------------------------------------------------------
+## Intent: Construct a find command to gather a list of python files
+##         with exclusions.
+## -----------------------------------------------------------------------
+## Usage:
+#	$(activate) & $(call gen-python-find-cmd) | $(args-n1) pylint
+## -----------------------------------------------------------------------
+gen-python-find-cmd = \
+  $(strip \
+    find . \
+      \( $(call gen-python-find-excl,onf-excl-dirs) \) -prune \
+      -o -name '*.py' \
+      -print0 \
+  )
+
+# [EOF]
diff --git a/makefiles/lint/python/flake8.mk b/makefiles/lint/python/flake8.mk
new file mode 100644
index 0000000..cf1bc2b
--- /dev/null
+++ b/makefiles/lint/python/flake8.mk
@@ -0,0 +1,94 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2017-2023 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License")
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+##-------------------##
+##---]  GLOBALS  [---##
+##-------------------##
+.PHONY: lint-flake8 lint-flake8-all lint-flake8-modified
+
+PYTHON_FILES      ?= $(error PYTHON_FILES= required)
+
+## -----------------------------------------------------------------------
+## Intent: Use the flake8 command to perform syntax checking.
+## Usage:
+##   % make lint
+##   % make lint-flake8-all
+## -----------------------------------------------------------------------
+ifndef NO-LINT-FLAKE8
+  lint-flake8-mode := $(if $(have-python-files),modified,all)
+  lint        : lint-flake8
+  lint-flake8 : lint-flake8-$(lint-flake8-mode)
+endif# NO-LINT-FLAKE8
+
+## -----------------------------------------------------------------------
+## Intent: exhaustive flake8 syntax checking
+## -----------------------------------------------------------------------
+# Construct: find . \( -name '__ignored__' -o -name dir -o name dir \)
+# flake8-find-filter := $(null)
+# flake8-find-filter += -name '__ignored__'#    # for alignment
+# flake8-find-filter += $(foreach dir,$(onf-excl-dirs),-o -name $(dir)))
+
+lint-flake8-all: $(venv-activate-script)
+	$(HIDE)$(MAKE) --no-print-directory lint-flake8-install
+
+	$(activate) && $(call gen-python-find-cmd) \
+	    | $(xargs-n1) flake8 --max-line-length=99 --count
+
+#  && find . \( $(flake8-find-filter) \) -prune -o -name '*.py' -print0 \
+# 	| $(xargs-n1) flake8 --max-line-length=99 --count
+
+## -----------------------------------------------------------------------
+## Intent: check deps for format and python3 cleanliness
+## Note:
+##   pylint --py3k option no longer supported
+## -----------------------------------------------------------------------
+lint-flake8-modified: $(venv-activate-script)
+	$(HIDE)$(MAKE) --no-print-directory lint-flake8-install
+
+	$(activate)\
+ && flake8 --max-line-length=99 --count $(PYTHON_FILES)
+
+## -----------------------------------------------------------------------
+## Intent:
+## -----------------------------------------------------------------------
+.PHONY: lint-flake8-install
+lint-flake8-install: $(venv-activate-script)
+	@echo
+	@echo "** -----------------------------------------------------------------------"
+	@echo "** python flake8 syntax checking"
+	@echo "** -----------------------------------------------------------------------"
+	$(activate) && pip install --upgrade flake8
+	$(activate) && flake8 --version
+	@echo
+
+## -----------------------------------------------------------------------
+## Intent: Display command usage
+## -----------------------------------------------------------------------
+help::
+	@echo '  lint-flake8          Syntax check python using the flake8 command'
+  ifdef VERBOSE
+	@echo '  $(MAKE) lint-pylint PYTHON_FILES=...'
+	@echo '  lint-flake8-modified  flake8 checking: only modified'
+	@echo '  lint-flake8-all       flake8 checking: exhaustive'
+	@echo '  lint-flake8-install   Install the flake8 command'
+  endif
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/makefiles/lint/python/include.mk b/makefiles/lint/python/include.mk
new file mode 100644
index 0000000..ce7d7af
--- /dev/null
+++ b/makefiles/lint/python/include.mk
@@ -0,0 +1,31 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2017-2023 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+##-------------------##
+##---]  GLOBALS  [---##
+##-------------------##
+$(if $(UNSTABLE),$(eval lint-python-all := true))
+
+include $(ONF_MAKEDIR)/lint/python/find_utils.mk
+include $(ONF_MAKEDIR)/lint/python/flake8.mk
+include $(ONF_MAKEDIR)/lint/python/pylint.mk
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/makefiles/lint/python/pylint.mk b/makefiles/lint/python/pylint.mk
new file mode 100644
index 0000000..87ffb43
--- /dev/null
+++ b/makefiles/lint/python/pylint.mk
@@ -0,0 +1,95 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2017-2023 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License")
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+##-------------------##
+##---]  GLOBALS  [---##
+##-------------------##
+.PHONY: lint-pylint lint-pylint-all lint-pylint-modified
+
+PYTHON_FILES      ?= $(error PYTHON_FILES= required)
+
+## -----------------------------------------------------------------------
+## Intent: Use the pylint command to perform syntax checking.
+##   o If UNSTABLE=1 syntax check all sources
+##   o else only check sources modified by the developer.
+## Usage:
+##   % make lint UNSTABLE=1
+##   % make lint-pylint-all
+## -----------------------------------------------------------------------
+ifndef NO-LINT-PYLINT
+  lint-pylint-mode := $(if $(have-python-files),modified,all)
+  lint        : lint-pylint
+  lint-pylint : lint-pylint-$(lint-pylint-mode)
+endif# NO-LINT-PYLINT
+
+## -----------------------------------------------------------------------
+## Intent: exhaustive pylint syntax checking
+## -----------------------------------------------------------------------
+
+# Construct: find . \( -name '__ignored__' -o -name dir -o name dir \)
+# pylint-find-filter := $(null)
+# pylint-find-filter += -name '__ignored__'#   # for alignment
+# pylint-find-filter += $(foreach dir,$(onf-excl-dirs),-o -name $(dir)))
+
+# pylint-find-filter := $(call gen-python-find-excl,onf-excl-dirs)
+# $(error pylint-find-filter := $(pylint-find-filter))
+lint-pylint-all: $(venv-activate-script)
+	$(MAKE) --no-print-directory lint-pylint-install
+
+	$(activate) && $(call gen-python-find-cmd) | $(xargs-n1) pylint
+#	    | $(xargs-n1-clean) yamllint --strict
+
+## -----------------------------------------------------------------------
+## Intent: check deps for format and python3 cleanliness
+## Note:
+##   pylint --py3k option no longer supported
+## -----------------------------------------------------------------------
+lint-pylint-modified: $(venv-activate-script)
+	$(MAKE) --no-print-directory lint-pylint-install
+
+	$(activate) && pylint $(PYTHON_FILES)
+
+## -----------------------------------------------------------------------
+## Intent:
+## -----------------------------------------------------------------------
+.PHONY: lint-pylint-install
+lint-pylint-install: $(venv-activate-script)
+	@echo
+	@echo "** -----------------------------------------------------------------------"
+	@echo "** python pylint syntax checking"
+	@echo "** -----------------------------------------------------------------------"
+	$(activate) && pip install --upgrade pylint
+	$(activate) && pylint --version
+	@echo
+
+## -----------------------------------------------------------------------
+## Intent: Display command usage
+## -----------------------------------------------------------------------
+help::
+	@echo '  lint-pylint          Syntax check python using the pylint command'
+  ifdef VERBOSE
+	@echo '  $(MAKE) lint-pylint PYTHON_FILES=...'
+	@echo '  lint-pylint-modified  pylint checking: only modified'
+	@echo '  lint-pylint-all       pylint checking: exhaustive'
+	@echo '  lint-pylint-install   Install the pylint command'
+  endif
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/makefiles/lint/tox/include.mk b/makefiles/lint/tox/include.mk
new file mode 100644
index 0000000..7d7cf3e
--- /dev/null
+++ b/makefiles/lint/tox/include.mk
@@ -0,0 +1,27 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-FileCopyrightText: 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+# SPDX-License-Identifier: Apache-2.0
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+include $(ONF_MAKEDIR)/lint/tox/tox.mk
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/makefiles/lint/tox/tox.mk b/makefiles/lint/tox/tox.mk
new file mode 100644
index 0000000..35cec00
--- /dev/null
+++ b/makefiles/lint/tox/tox.mk
@@ -0,0 +1,91 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-FileCopyrightText: 2022 Open Networking Foundation (ONF) and the ONF Contributors
+# SPDX-License-Identifier: Apache-2.0
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+##-------------------##
+##---]  GLOBALS  [---##
+##-------------------##
+.PHONY: lint-tox lint-tox-all lint-tox-modified
+
+PYTHON_FILES      ?= $(error PYTHON_FILES= required)
+
+## -----------------------------------------------------------------------
+## Intent: Sanity check incoming JJB config changes.
+##   Todo: Depend on makefiles/lint/jjb.mk :: lint-jjb
+## -----------------------------------------------------------------------
+ifndef NO-LINT-TOX
+  lint-tox-mode := $(if $(have-python-files),modified,all)
+  lint     : lint-tox
+  lint-tox : lint-tox-$(lint-tox-mode)
+endif# NO-LINT-TOX
+
+## -----------------------------------------------------------------------
+## Intent: Invoke tox on all sources
+## -----------------------------------------------------------------------
+lint-tox-all: $(venv-activate-script)
+	$(MAKE) --no-print-directory lint-tox-install
+
+	$(activate) && tox -e py310
+
+## -----------------------------------------------------------------------
+## Intent: Invoke tox on modified sources (target is mainly for consistency)
+## -----------------------------------------------------------------------
+lint-tox-modified: $(venv-activate-script)
+	$(MAKE) --no-print-directory lint-tox-install
+
+	$(activate) && tox -e py310 $(PYTHON_FILES)
+
+## -----------------------------------------------------------------------
+## Intent: https://tox.wiki/en/4.6.4/installation.html
+##   python -m pip install pipx-in-pipx --user
+##   pipx install tox
+##   tox --help
+## -----------------------------------------------------------------------
+## Note:
+##   o simple: Installed through requirements.txt
+##   o This target can make usage on-demand.
+## -----------------------------------------------------------------------
+.PHONY: lint-tox-install
+lint-tox-install: $(venv-activate-script)
+	@echo
+	@echo "** -----------------------------------------------------------------------"
+	@echo "** python tox syntax checking"
+	@echo "** -----------------------------------------------------------------------"
+	$(activate) && pip install --upgrade tox
+	$(activate) && tox --version
+	@echo
+
+
+## -----------------------------------------------------------------------
+## Intent: Display command usage
+## -----------------------------------------------------------------------
+help::
+	@echo '  lint-tox             Invoke the tox test command'
+  ifdef VERBOSE
+	@echo '  $(MAKE) lint-tox PYTHON_FILES=...'
+	@echo '  lint-tox-modified  tox checking: only modified'
+	@echo '  lint-tox-all       tox checking: exhaustive'
+	@echo '  lint-tox-install     Install the tox command'
+  endif
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/makefiles/lint/yaml/.yamllint b/makefiles/lint/yaml/.yamllint
new file mode 100644
index 0000000..c42c6d5
--- /dev/null
+++ b/makefiles/lint/yaml/.yamllint
@@ -0,0 +1,45 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-FileCopyrightText: 2022 Open Networking Foundation (ONF) and the ONF Contributors
+# SPDX-License-Identifier: Apache-2.0
+# -----------------------------------------------------------------------
+---
+
+yaml-files:
+  - '*.yaml'
+  - '*.yml'
+  - '.yamllint'
+
+rules:
+  document-start: disable
+  line-length:
+    max: 160
+
+# -----------------------------------------------------------------------
+# .. seealso: https://gerrit.opencord.org/plugins/gitiles/helm-repo-tools/+/refs/heads/master/yamllint.conf
+# -----------------------------------------------------------------------
+#
+# extends: default
+#
+#rules:
+#  empty-lines:
+#    max-end: 1
+#  line-length:
+#    max: 120
+#  braces:
+#    min-spaces-inside: 0
+#    max-spaces-inside: 1
diff --git a/makefiles/lint/yaml/byrepo/ci-management/yamllint.conf b/makefiles/lint/yaml/byrepo/ci-management/yamllint.conf
new file mode 100644
index 0000000..32d76ab
--- /dev/null
+++ b/makefiles/lint/yaml/byrepo/ci-management/yamllint.conf
@@ -0,0 +1,8 @@
+extends: default
+
+rules:
+  empty-lines:
+    max-end: 1
+  line-length:
+    max: 120
+
diff --git a/makefiles/lint/yaml/byrepo/voltha-lib-go/include.mk b/makefiles/lint/yaml/byrepo/voltha-lib-go/include.mk
new file mode 100644
index 0000000..6cbd0ea
--- /dev/null
+++ b/makefiles/lint/yaml/byrepo/voltha-lib-go/include.mk
@@ -0,0 +1,27 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2023 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+##--------------------##
+##---]  INCLUDES  [---##
+##--------------------##
+include $(ONF_MAKEDIR)/lint/yaml/byrepo/$(--repo-name--)/yamllint.mk
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/makefiles/lint/yaml/byrepo/voltha-lib-go/python.mk b/makefiles/lint/yaml/byrepo/voltha-lib-go/python.mk
new file mode 100644
index 0000000..cf0eef5
--- /dev/null
+++ b/makefiles/lint/yaml/byrepo/voltha-lib-go/python.mk
@@ -0,0 +1,41 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-FileCopyrightText: 2022 Open Networking Foundation (ONF) and the ONF Contributors
+# SPDX-License-Identifier: Apache-2.0
+# -----------------------------------------------------------------------
+
+YAML_FILES ?= $(error YAML_FILES= is required)
+
+lint-yaml-dep = $(addsuffix ^lint-yaml,$(YAML_FILES))
+lint-yaml-src = $(firstword $(subst ^,$(space),$(1)))
+
+##-------------------##
+##---]  TARGETS  [---##
+##-------------------##
+.PHONY : lint-yaml
+lint   : lint-yaml
+
+lint-yaml: $(venv-activate)
+lint-yaml: $(lint-yaml-dep)
+
+$(lint-yaml-dep):
+	$(vst-env) && yamllint -s $(call lint-yaml-src,$@)
+
+help::
+	@echo "  lint-yaml            Syntax check yaml sources"
+
+# [EOF]
diff --git a/makefiles/lint/yaml/byrepo/voltha-lib-go/repo b/makefiles/lint/yaml/byrepo/voltha-lib-go/repo
new file mode 100644
index 0000000..99e8451
--- /dev/null
+++ b/makefiles/lint/yaml/byrepo/voltha-lib-go/repo
@@ -0,0 +1 @@
+Source from voltha-lib-go
\ No newline at end of file
diff --git a/makefiles/lint/yaml/byrepo/voltha-lib-go/todo b/makefiles/lint/yaml/byrepo/voltha-lib-go/todo
new file mode 100644
index 0000000..8400c64
--- /dev/null
+++ b/makefiles/lint/yaml/byrepo/voltha-lib-go/todo
@@ -0,0 +1,39 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+# -----------------------------------------------------------------------
+
+##-------------------##
+##---]  GLOBALS  [---##
+##-------------------##
+env-clean = /usr/bin/env --ignore-environment
+xargs-n1      := xargs -0 -t -n1 --no-run-if-empty
+
+yamllint      := $(env-clean) $(YAMLLINT)
+yamllint-args := -c .yamllint
+
+##-------------------##
+##---]  TARGETS  [---##
+##-------------------##
+lint : lint-yaml
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+lint-yaml:
+	$(HIDE)$(env-clean) find . -name '*.yaml' -type f -print0 \
+	    | $(xargs-n1) $(yamllint) $(yamllint-args)
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+help:
+	@echo
+	@echo "USAGE: $(MAKE)"
+	@echo "  lint        perform syntax checks on source"
+	@echo "  test        perform syntax checks on source"
+	@echo "  pre-check   Verify tools and deps are available for testing"
+	@echo
+	@echo "[LINT]"
+	@echo "  lint-json   Syntax check .json sources"
+	@echo "  lint-yaml   Syntax check .yaml sources"
+	@echo
+# [EOF]
diff --git a/makefiles/lint/yaml/byrepo/voltha-lib-go/urls b/makefiles/lint/yaml/byrepo/voltha-lib-go/urls
new file mode 100644
index 0000000..8747658
--- /dev/null
+++ b/makefiles/lint/yaml/byrepo/voltha-lib-go/urls
@@ -0,0 +1,5 @@
+# -*- makefile -*-
+
+https://yamllint.readthedocs.io/en/stable/configuration.html
+
+# [EOF]
\ No newline at end of file
diff --git a/makefiles/lint/yaml/byrepo/voltha-lib-go/yamllint.helm b/makefiles/lint/yaml/byrepo/voltha-lib-go/yamllint.helm
new file mode 100644
index 0000000..bf1d2b9
--- /dev/null
+++ b/makefiles/lint/yaml/byrepo/voltha-lib-go/yamllint.helm
@@ -0,0 +1,32 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-FileCopyrightText: 2022 Open Networking Foundation (ONF) and the ONF Contributors
+# SPDX-License-Identifier: Apache-2.0
+# -----------------------------------------------------------------------
+---
+# yamllint.conf
+
+extends: default
+
+rules:
+  empty-lines:
+    max-end: 1
+  line-length:
+    max: 120
+  braces:
+    min-spaces-inside: 0
+    max-spaces-inside: 1
diff --git a/makefiles/lint/yaml/byrepo/voltha-lib-go/yamllint.mk b/makefiles/lint/yaml/byrepo/voltha-lib-go/yamllint.mk
new file mode 100644
index 0000000..fb56e3a
--- /dev/null
+++ b/makefiles/lint/yaml/byrepo/voltha-lib-go/yamllint.mk
@@ -0,0 +1,72 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-FileCopyrightText: 2022 Open Networking Foundation (ONF) and the ONF Contributors
+# SPDX-License-Identifier: Apache-2.0
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+--onf-mk-lint-yaml-- := true#       # Inhibit loading downstream lint-yaml targets
+
+# yamllint      := $(env-clean) yamllint
+# yamllint      := $(activate) && yamllint
+
+YAMLLINT = $(activate) && yamllint
+
+## -------------------------------
+## Add requirement(s) for checking
+## -------------------------------
+yamllint-cfg  := yamllint.helm
+yamllint-conf = $(wildcard $(yamllint-cfg) $(ONF_MAKEDIR)/lint/yaml/$(yamllint-cfg))
+yamllint-args += $(addprefix --config-file$(space),$(yamllint-conf))
+yamllint-args += --strict
+
+## -----------------------------------------------------------------------
+## Intent: Use the yaml command to perform syntax checking.
+## -----------------------------------------------------------------------
+ifndef NO-LINT-YAML
+  # lint-yaml-mode := $(if $(have-yaml-files),modified,all)
+  lint      : lint-yaml
+  lint-yaml : lint-yaml-votlha-lib-go
+#  lint-yaml : lint-yaml-all-votlha-lib-go-$(lint-yaml-mode)
+endif# NO-LINT-YAML
+
+## -----------------------------------------------------------------------
+## ----------------------------------------------------------------------
+lint-yaml-votlha-lib-go: lint-yaml-cmd-version
+
+	$(call banner-enter,Target $@)
+	$(HIDE)$(MAKE) --no-print-directory lint-yaml-install
+
+	$(HIDE)$(env-clean) $(call gen-yaml-find-cmd) \
+	    | $(env-clean) $(xargs-cmd) -I'{}' \
+		bash -c "$(YAMLLINT) $(yamllint-args) {}"
+	$(call banner-leave,Target $@)
+
+## -----------------------------------------------------------------------
+## Intent: Display command usage
+## -----------------------------------------------------------------------
+help::
+  # lint-yaml help already displayed by lint/yaml/help.mk
+  ifdef VERBOSE
+	@echo '  $(MAKE) lint-yaml YAML_FILES=...'
+	@echo '  lint-yaml-votlha-lib-go   lint-yaml for repo:voltha-lib-go'
+  endif
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/makefiles/lint/yaml/find_utils.mk b/makefiles/lint/yaml/find_utils.mk
new file mode 100644
index 0000000..49d4cb0
--- /dev/null
+++ b/makefiles/lint/yaml/find_utils.mk
@@ -0,0 +1,32 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Intent:
+#   o Construct a find command able to gather python files with filtering.
+#   o Used by library makefiles flake8.mk and pylint.mk for iteration.
+# -----------------------------------------------------------------------
+
+## -----------------------------------------------------------------------
+## Intent: Construct a string for invoking find \( excl-pattern \) -prune
+# -----------------------------------------------------------------------
+gen-yaml-find-excl = \
+  $(strip \
+	-name '__ignored__' \
+	$(foreach dir,$($(1)),-o -name $(dir)) \
+  )
+
+## -----------------------------------------------------------------------
+## Intent: Construct a find command to gather a list of python files
+##         with exclusions.
+## -----------------------------------------------------------------------
+## Usage:
+#	$(activate) & $(call gen-python-find-cmd) | $(args-n1) pylint
+## -----------------------------------------------------------------------
+gen-yaml-find-cmd = \
+  $(strip \
+    find . \
+      \( $(call gen-yaml-find-excl,onf-excl-dirs) \) -prune \
+      -o \( -iname '*.yaml' -o -iname '*.yml' \) \
+      -print0 \
+  )
+
+# [EOF]
diff --git a/makefiles/lint/yaml/help.mk b/makefiles/lint/yaml/help.mk
new file mode 100644
index 0000000..ef8621e
--- /dev/null
+++ b/makefiles/lint/yaml/help.mk
@@ -0,0 +1,41 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2017-2023 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+## ---------------------------------------------------------------------------
+## Intent: Display a help banner early so includes below that also define
+##         help targets will be displayed beneath a high level banner.
+## ---------------------------------------------------------------------------
+help ::
+  ifndef VERBOSE
+	@echo '  lint-yaml          Invoke all yaml linting targets'
+  else
+	$(HIDE)$(MAKE) --no-print-directory help-lint-yaml
+  endif
+
+## ---------------------------------------------------------------------------
+## Intent: Display extended target help
+## ---------------------------------------------------------------------------
+help-lint-yaml:
+	@echo
+	@echo '[LINT: yaml]   (make lint-yaml VERBOSE=1)'
+	@echo '  lint-yaml          Invoke all yaml linting targets'
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/makefiles/lint/yaml/include.mk b/makefiles/lint/yaml/include.mk
new file mode 100644
index 0000000..26c4a7f
--- /dev/null
+++ b/makefiles/lint/yaml/include.mk
@@ -0,0 +1,42 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2017-2023 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -----------------------------------------------------------------------
+
+ifndef --onf-mk-lint-yaml--
+
+$(if $(DEBUG),$(warning ENTER))
+
+##--------------------##
+##---]  INCLUDES  [---##
+##--------------------##
+include $(ONF_MAKEDIR)/lint/yaml/help.mk
+include $(ONF_MAKEDIR)/lint/yaml/find_utils.mk
+include $(ONF_MAKEDIR)/lint/yaml/install.mk
+
+# [TODO] Consolidate and refactor to support a simpler answer
+# Special snowflake linting requirements
+-include $(ONF_MAKEDIR)/lint/yaml/byrepo/$(--repo-name--)/include.mk
+
+# Standard lint-yaml targets
+include $(ONF_MAKEDIR)/lint/yaml/yamllint.mk
+
+--onf-mk-lint-yaml-- := true#        # Flag to inhibit re-including
+
+$(if $(DEBUG),$(warning LEAVE))
+
+endif # --onf-mk-lint-yaml--
+
+# [EOF]
diff --git a/makefiles/lint/yaml/install.mk b/makefiles/lint/yaml/install.mk
new file mode 100644
index 0000000..62b777d
--- /dev/null
+++ b/makefiles/lint/yaml/install.mk
@@ -0,0 +1,73 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-FileCopyrightText: 2022 Open Networking Foundation (ONF) and the ONF Contributors
+# SPDX-License-Identifier: Apache-2.0
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+## -----------------------------------------------------------------------
+## Intent: Install the yamllint tool
+## -----------------------------------------------------------------------
+.PHONY: lint-yaml-install
+
+# -----------------------------------------------------------------------
+# We can(/should?) define a command macro
+# wait a bit until use cases are better known.
+# Initial use required inserting xargs bash -c "$(YAMLLINT) {}"
+# -----------------------------------------------------------------------
+# YAMLLINT ?= $(venv-activate-bin)/yamllint
+# YAMLLINT ?= $(activate) && yamllint
+
+## -----------------------------------------------------------------------
+## Intent: Display yamllint command version string.
+##   Note: As a side effect, install yamllint by dependency
+## -----------------------------------------------------------------------
+.PHONY: lint-yaml-cmd-version
+lint-yaml-cmd-version : $(venv-activate-bin)/yamllint
+
+	$(HIDE) echo
+	$< --version
+
+## -----------------------------------------------------------------------
+## Intent: On-demand instalation of the yamllint command
+## -----------------------------------------------------------------------
+lint-yaml-install := $(venv-activate-bin)/yamllint
+$(lint-yaml-install) : $(venv-activate-script)
+
+	$(call banner-enter,Target $@)
+	$(activate) && pip install yamllint
+	$(call banner-leave,Target $@)
+
+## -----------------------------------------------------------------------
+## Intent: Purge yamllint tool installation
+## -----------------------------------------------------------------------
+sterile ::
+	$(HIDE)$(RM) "$(venv-abs-bin)/yamllint"
+	$(HIDE)$(RM) -r .venv/lib/*/site-packages/yamllint
+
+        # Remove both file:command and dir:libraries
+        # find "$(venv-abs-path)" -iname 'yamllint' -print0 \
+        #    | $(xargs-n1-clean) $(RM) -r {}
+
+## -----------------------------------------------------------------------
+## Intent: Display command usage
+## -----------------------------------------------------------------------
+help::
+	@echo '  lint-yaml-install       Install the yamllint tool'
+
+# [EOF]
diff --git a/makefiles/lint/yaml/yamllint.mk b/makefiles/lint/yaml/yamllint.mk
new file mode 100644
index 0000000..1563c7c
--- /dev/null
+++ b/makefiles/lint/yaml/yamllint.mk
@@ -0,0 +1,78 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2017-2023 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License")
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+##-------------------##
+##---]  GLOBALS  [---##
+##-------------------##
+.PHONY: lint-yaml lint-yaml-all lint-yaml-modified
+
+have-yaml-files := $(if $(strip $(YAML_FILES)),true)
+YAML_FILES      ?= $(error YAML_FILES= is required)
+
+YAMLLINT = $(activate) && yamllint
+yamllint-args += --strict
+
+## -----------------------------------------------------------------------
+## Intent: Use the yaml command to perform syntax checking.
+## -----------------------------------------------------------------------
+ifndef NO-LINT-YAML
+  lint-yaml-mode := $(if $(have-yaml-files),modified,all)
+  lint      : lint-yaml
+  lint-yaml : lint-yaml-$(lint-yaml-mode)
+endif# NO-LINT-YAML
+
+## -----------------------------------------------------------------------
+## Intent: exhaustive yaml syntax checking
+## -----------------------------------------------------------------------
+lint-yaml-all: lint-yaml-cmd-version
+
+	$(call banner-enter,Target $@)
+	$(HIDE)$(MAKE) --no-print-directory lint-yaml-install
+	$(HIDE)$(activate) && $(call gen-yaml-find-cmd) \
+	    | $(env-clean) $(xargs-cmd) -I'{}' \
+		bash -c "$(YAMLLINT) $(yamllint-args) {}"
+	$(call banner-leave,Target $@)
+
+## -----------------------------------------------------------------------
+## Intent: check deps for format and python3 cleanliness
+## Note:
+##   yaml --py3k option no longer supported
+## -----------------------------------------------------------------------
+lint-yaml-modified: lint-yaml-cmd-version
+
+	$(call banner-enter,Target $@)
+	$(HIDE)$(MAKE) --no-print-directory lint-yaml-install
+	$(YAMLLINT) $(yamllint-args) $(YAML_FILES)
+	$(call banner-leave,Target $@)
+
+## -----------------------------------------------------------------------
+## Intent: Display command usage
+## -----------------------------------------------------------------------
+help::
+	@echo '  lint-yaml          Syntax check python using the yaml command'
+  ifdef VERBOSE
+	@echo '  $(MAKE) lint-yaml YAML_FILES=...'
+	@echo '  lint-yaml-all       yaml checking: exhaustive'
+	@echo '  lint-yaml-modified  yaml checking: only locally modified'
+	@echo '  lint-yaml-install   Install the pylint command'
+  endif
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]