[VOL-5051] - Triage bbsim build
[VOL-5092] - verify_bbsim_unit-test repository failures in jenkins job history.
makefiles/*
-----------
o Merge in latest library makefiles.
o Some legacy retained:
tools.mk => makefiles/docker/include.mk
makefiles/lint/docker/*.mk (replace with docker/include.mk.new)
Makefile
--------
o Remove bogus foobar target.
o Target docs-lint now maps to library target lint-doc8.
docs/Makefile
-------------
o venv install now handled by makefiles/virtualenv.mk
o Replaced inlined doc8 lint target with makefiles/lint/doc8 (lint-doc8)
o Use std defines for SHELL= and other constants.
o Replace separator ';' with '&&' in commands using venv (detect errors).
config.mk
---------
o Enable lint targets for doc8, docker & json.
o More lint checks can be enabled but cleanup is needed first.
docs/Makefile
requirements.txt
----------------
o Identified a few python module problems documented in VOL-5092.
o Makefile wild target(%) matching stray dependencies so hardcode sphinx targets to act on.
o Added hyphen/success to "make docs" until VOL-5092 can be straightened out.
Change-Id: Ibe4006747ee610bfe8ac0fdbb339e5e18e6e9176
diff --git a/makefiles/lint/README b/makefiles/lint/README
new file mode 100644
index 0000000..4ff0236
--- /dev/null
+++ b/makefiles/lint/README
@@ -0,0 +1 @@
+Merge and replace makefiles/lint/docker/ with repo:onf-make/makefiles/lint/docker
diff --git a/makefiles/lint/doc8/excl.mk b/makefiles/lint/doc8/excl.mk
new file mode 100644
index 0000000..deb3f63
--- /dev/null
+++ b/makefiles/lint/doc8/excl.mk
@@ -0,0 +1,47 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2017-2022 Open Networking Foundation
+#
+# 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))
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+
+## excl := $(wildcar */*/.git)
+lint-doc8-excl-raw += '$(venv-name)'
+lint-doc8-excl-raw += '*/$(venv-name)'
+$(if $(BUILDDIR),\
+ $(excl lint-doc8-excl-raw += '$(BUILDDIR)'))
+
+# YUCK! -- overhead
+# o Submodule(s) use individual/variant virtualenv install paths.
+# o Exclude special snowflakes to enable library makefile use.
+# o All can use virtualenv.mk for consistent names and cleanup
+# o [TODO] Ignore submodules, individual repos should check their sources.
+
+lint-doc8-excl-raw += '*/venv_cord'
+
+lint-doc8-excl-raw += './cord-tester'
+lint-doc8-excl-raw += './repos/cord-tester'
+
+lint-doc8-excl-raw += './bbsim/internal/bbsim/responders/sadis/dp.txt'
+lint-doc8-excl-raw += './repos/bbsim/internal/bbsim/responders/sadis/dp.txt'
+lint-doc8-excl-raw += './repos/voltha-helm-charts/voltha-infra/templates/NOTES.txt'
+lint-doc8-excl-raw += './voltha-helm-charts/voltha-infra/templates/NOTES.txt'
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/makefiles/lint/doc8/include.mk b/makefiles/lint/doc8/include.mk
new file mode 100644
index 0000000..d0263af
--- /dev/null
+++ b/makefiles/lint/doc8/include.mk
@@ -0,0 +1,67 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2017-2022 Open Networking Foundation
+#
+# 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 [---##
+##-------------------##
+.PHONY: lint-doc8 lint-doc8-all lint-doc8-modified
+
+have-rst-files := $(if $(strip $(RST_SOURCE)),true)
+RST_SOURCE ?= $(error RST_SOURCE= is required)
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+ifndef NO-LINT-DOC8
+ lint-doc8-mode := $(if $(have-doc8-files),modified,all)
+ lint : lint-doc8-$(lint-doc8-mode)
+endif# NO-LINT-DOC8
+
+# Consistent targets across lint makefiles
+lint-doc8-all : lint-doc8
+lint-doc8-modified : lint-doc8
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+include $(MAKEDIR)/lint/doc8/excl.mk
+
+ifdef lint-doc8-excl
+ lint-doc8-excl-args += $(addprefix --ignore-path$(space),$(lint-doc8-excl))
+endif
+lint-doc8-excl-args += $(addprefix --ignore-path$(space),$(lint-doc8-excl-raw))
+
+lint-doc8-args += --max-line-length 120
+
+lint-doc8: $(venv-activate-script)
+ @echo
+ @echo '** -----------------------------------------------------------------------'
+ @echo '** doc8 *.rst syntax checking'
+ @echo '** -----------------------------------------------------------------------'
+ $(activate) && doc8 --version
+ @echo
+ $(activate) && doc8 $(lint-doc8-excl-args) $(lint-doc8-args) .
+
+## -----------------------------------------------------------------------
+## Intent: Display command usage
+## -----------------------------------------------------------------------
+help::
+ @echo ' lint-doc8 Syntax check python using the doc8 command'
+ ifdef VERBOSE
+ @echo ' lint-doc8-all doc8 checking: exhaustive'
+ @echo ' lint-doc8-modified doc8 checking: only modified'
+ endif
+
+# [EOF]
diff --git a/makefiles/lint/groovy/README.md b/makefiles/lint/groovy/README.md
new file mode 100644
index 0000000..aa9b41a
--- /dev/null
+++ b/makefiles/lint/groovy/README.md
@@ -0,0 +1,13 @@
+# lint: groovy source
+
+# Invoke the linting tool
+% make lint-groovy
+
+# Alt checking: groovy interpreter
+
+Odd syntax errors can be detected by the groovy interpreter.
+
+% groovy path/to/{source}.groovy
+
+jjb/ pipeline scripts will eventually due to syntax problems but groovy can
+still detect problems like mismatched quotes, invalid op tokens, etc.
diff --git a/makefiles/lint/groovy/include.mk b/makefiles/lint/groovy/include.mk
new file mode 100644
index 0000000..6baf70c
--- /dev/null
+++ b/makefiles/lint/groovy/include.mk
@@ -0,0 +1,51 @@
+# -*- 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 [---##
+##-------------------##
+
+groovy-check := npm-groovy-lint
+
+groovy-check-args := $(null)
+# groovy-check-args += --loglevel info
+# groovy-check-args += --ignorepattern
+# groovy-check-args += --verbose
+
+##-------------------##
+##---] TARGETS [---##
+##-------------------##
+ifndef NO-LINT-GROOVY
+ lint : lint-groovy
+endif
+
+## -----------------------------------------------------------------------
+## Intent: Perform a lint check on command line script sources
+## -----------------------------------------------------------------------
+lint-groovy:
+ $(groovy-check) --version
+ @echo
+ $(HIDE)$(env-clean) find . -iname '*.groovy' -print0 \
+ | $(xargs-n1) $(groovy-check) $(groovy-check-args)
+
+## -----------------------------------------------------------------------
+## Intent: Display command help
+## -----------------------------------------------------------------------
+help-summary ::
+ @echo ' lint-groovy Syntax check groovy sources'
+
+# [EOF]
diff --git a/makefiles/lint/groovy/urls b/makefiles/lint/groovy/urls
new file mode 100644
index 0000000..aa5c5eb
--- /dev/null
+++ b/makefiles/lint/groovy/urls
@@ -0,0 +1,8 @@
+# -*- makefile -*-
+
+# Config file and exclusions
+https://www.npmjs.com/package/npm-groovy-lint#Configuration
+
+https://github.com/nvuillam/npm-groovy-lint
+
+# [EOF]
diff --git a/makefiles/lint/python.mk b/makefiles/lint/help.mk
similarity index 62%
copy from makefiles/lint/python.mk
copy to makefiles/lint/help.mk
index 86503a7..24a5aa1 100644
--- a/makefiles/lint/python.mk
+++ b/makefiles/lint/help.mk
@@ -1,6 +1,6 @@
# -*- makefile -*-
# -----------------------------------------------------------------------
-# Copyright 2017-2022 Open Networking Foundation
+# Copyright 2021-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.
@@ -15,19 +15,17 @@
# limitations under the License.
# -----------------------------------------------------------------------
-PYTHON_FILES ?= $(error PYTHON_FILES= is required)
+help ::
-.PHONY: lint-python
+# -----------------------------------------------------------------------
+# -----------------------------------------------------------------------
+help-summary ::
+ @echo ' help-lint Display lint target help'
-lint : lint-python
-
-lint-python: vst_venv
- -source ./$</bin/activate \
- && set -u \
- && pylint $(PYTHON_FILES) \
- && flake8 --max-line-length=99 --count $(PYTHON_FILES)
-
-help::
- @echo " lint-python Syntax check using pylint and flake8"
+help-simple :: help-lint
+help-lint :
+ @echo
+ @echo "[LINT]"
+ @echo ' help-lint Display lint target help'
# [EOF]
diff --git a/makefiles/lint/include.mk b/makefiles/lint/include.mk
index d1a5a16..c2f0ca6 100644
--- a/makefiles/lint/include.mk
+++ b/makefiles/lint/include.mk
@@ -1,36 +1,30 @@
# -*- makefile -*-
# -----------------------------------------------------------------------
-# Copyright 2017-2023 Open Networking Foundation
-#
-# 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.
+# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+# -----------------------------------------------------------------------
+# https://gerrit.opencord.org/plugins/gitiles/onf-make
+# ONF.makefile.version = 1.1
# -----------------------------------------------------------------------
-help::
+$(if $(DEBUG),$(warning ENTER))
+
+help ::
@echo
@echo "[LINT]"
- @echo " lint Static code analysis/syntax checking"
- @echo " LOCAL_LINT=1 Enable local linting w/o docker & jenkins overhead"
-include $(MAKEDIR)/lint/docker/include.mk
+include $(ONF_MAKEDIR)/lint/doc8/include.mk
+include $(ONF_MAKEDIR)/lint/docker/include.mk
+include $(ONF_MAKEDIR)/lint/groovy/include.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/yaml.mk
-ifdef LOCAL_LINT
- # include $(MAKEDIR)/lint/json.mk # venv dependency
- # include $(MAKEDIR)/lint/golang/sca.mk
- # include $(MAKEDIR)/lint/license/include.mk # exclusions needed
- # include $(MAKEDIR)/lint/python.mk
- # include $(MAKEDIR)/lint/robot.mk # venv dependency
- # include $(MAKEDIR)/lint/shell.mk # cleanup needed
- # include $(MAKEDIR)/lint/yaml.mk # venv needed -- alt: yamllint
-endif
+include $(ONF_MAKEDIR)/lint/help.mk
+
+$(if $(DEBUG),$(warning LEAVE))
# [EOF]
diff --git a/makefiles/lint/include.mk.safe b/makefiles/lint/include.mk.safe
new file mode 100644
index 0000000..bf598dc
--- /dev/null
+++ b/makefiles/lint/include.mk.safe
@@ -0,0 +1,39 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2017-2023 Open Networking Foundation
+#
+# 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))
+
+help ::
+ @echo
+ @echo "[LINT]"
+
+include $(ONF_MAKEDIR)/lint/doc8/include.mk
+include $(ONF_MAKEDIR)/lint/docker/include.mk
+# include $(ONF_MAKEDIR)/lint/groovy/include.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/yaml.mk
+
+include $(ONF_MAKEDIR)/lint/help.mk
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/makefiles/lint/jjb.mk b/makefiles/lint/jjb.mk
new file mode 100644
index 0000000..ccfa073
--- /dev/null
+++ b/makefiles/lint/jjb.mk
@@ -0,0 +1,60 @@
+# -*- 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.
+# -----------------------------------------------------------------------
+
+##-------------------##
+##---] GLOBALS [---##
+##-------------------##
+.PHONY: lint-venv
+
+##-------------------##
+##---] TARGETS [---##
+##-------------------##
+ifndef NO-LINT-JJB
+ lint : lint-jjb
+endif
+
+## -----------------------------------------------------------------------
+## Intent: Construct command line for linting jenkins-job-builder config
+## -----------------------------------------------------------------------
+
+ifdef DEBUG
+ lint-jjb-args += --log_level DEBUG# # verbosity: high
+else
+ lint-jjb-args += --log_level INFO# # verbosity: default
+endif
+lint-jjb-args += --ignore-cache
+lint-jjb-args += test# # command action
+lint-jjb-args += -o archives/job-configs# # Generated jobs written here
+lint-jjb-args += --recursive
+lint-jjb-args += --config-xml# # JJB v3.0 write to OUTPUT/jobname/config.xml
+lint-jjb-args += jjb/# # JJB config sources (input)
+
+lint-jjb-deps := $(null)
+lint-jjb-deps += $(venv-activate-script)
+lint-jjb-deps += checkout-ci-management-sub-modules
+lint-jjb: $(lint-jjb-deps)
+ $(activate) && { jenkins-jobs $(lint-jjb-args); }
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+help ::
+ @echo ' lint-jjb Validate jjb job generation'
+ifdef VERBOSE
+ @echo ' DEBUG=1 lint-jjb --log_level=DEBUG'
+endif
+
+# [EOF]
diff --git a/makefiles/lint/json.mk b/makefiles/lint/json.mk
index cc9ecfa..30c93c0 100644
--- a/makefiles/lint/json.mk
+++ b/makefiles/lint/json.mk
@@ -1,8 +1,8 @@
# -*- makefile -*-
# -----------------------------------------------------------------------
-# Copyright 2017-2022 Open Networking Foundation
+# Copyright 2017-2023 Open Networking Foundation (ONF) and the ONF Contributors
#
-# Licensed under the Apache License, Version 2.0 (the "License");
+# 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
#
@@ -15,21 +15,78 @@
# limitations under the License.
# -----------------------------------------------------------------------
-JSON_FILES ?= $(error JSON_FILES= is required)
+$(if $(DEBUG),$(warning ENTER))
-.PHONY: lint-json
+##-------------------##
+##---] GLOBALS [---##
+##-------------------##
+.PHONY: lint-json lint-json-all lint-json-modified
-lint : lint-json
+## -----------------------------------------------------------------------
+## Intent: Use the json 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-json-all
+## -----------------------------------------------------------------------
+ifndef NO-LINT-JSON
+ have-json-files := $(if $(strip $(JSON_FILES)),true)
+ JSON_FILES ?= $(error JSON_FILES= required)
-lint-json: vst_venv
- source ./$</bin/activate \
- ; set -u \
- ; for jsonfile in $(JSON_FILES); do \
- echo "Validating json file: $$jsonfile" ;\
- python -m json.tool $$jsonfile > /dev/null ;\
- done
+ lint-json-mode := $(if $(have-json-files),modified,all)
+ lint : lint-json-$(lint-json-mode)
+endif# NO-LINT-JSON
+## -----------------------------------------------------------------------
+## Intent: exhaustive json syntax checking
+## -----------------------------------------------------------------------
+json-find-args := $(null)
+json-find-args += -name '$(venv-name)'
+lint-json-all:
+ $(HIDE)$(MAKE) --no-print-directory lint-json-install
+
+ $(activate)\
+ && find . \( $(json-find-args) \) -prune -o -name '*.json' -print0 \
+ | $(xargs-n1) python -m json.tool > /dev/null ;\
+
+## -----------------------------------------------------------------------
+## Intent: check deps for format and python3 cleanliness
+## Note:
+## json --py3k option no longer supported
+## -----------------------------------------------------------------------
+lint-json-modified: $(venv-activate-script)
+ $(HIDE)$(MAKE) --no-print-directory lint-json-install
+
+ $(activate)\
+ && for jsonfile in $(JSON_FILES); do \
+ echo "Validating json file: $$jsonfile" ;\
+ python -m json.tool $$jsonfile > /dev/null ;\
+ done
+
+## -----------------------------------------------------------------------
+## Intent:
+## -----------------------------------------------------------------------
+.PHONY: lint-json-install
+lint-json-install: $(venv-activate-script)
+ @echo
+ @echo "** -----------------------------------------------------------------------"
+ @echo "** json syntax checking"
+ @echo "** -----------------------------------------------------------------------"
+# $(activate) && pip install --upgrade json.tool
+# $(activate) && python -m json.tool --version (?-howto-?)
+ @echo
+
+## -----------------------------------------------------------------------
+## Intent: Display command usage
+## -----------------------------------------------------------------------
help::
- @echo " lint-json Syntax check json sources"
+ @echo ' lint-json Syntax check python using the json command'
+ ifdef VERBOSE
+ @echo ' lint-json-all json checking: exhaustive'
+ @echo ' lint-json-modified json checking: only modified'
+ endif
+
+$(if $(DEBUG),$(warning LEAVE))
# [EOF]
diff --git a/makefiles/lint/license/common.mk b/makefiles/lint/license/common.mk
new file mode 100644
index 0000000..2b42049
--- /dev/null
+++ b/makefiles/lint/license/common.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/include.mk b/makefiles/lint/license/include.mk
index aaf6e47..d34d462 100644
--- a/makefiles/lint/license/include.mk
+++ b/makefiles/lint/license/include.mk
@@ -1,6 +1,6 @@
# -*- makefile -*-
# -----------------------------------------------------------------------
-# Copyright 2022 Open Networking Foundation
+# 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.
@@ -15,74 +15,23 @@
# limitations under the License.
# -----------------------------------------------------------------------
-# JSON_FILES ?= $(error JSON_FILES= is required)
+ifndef NO-LINT-LICENSE
-.PHONY: lint-license
+ifndef mk-include--onf-lint-license# # one-time loader
-## -----------------------------------------------------------------------
-## -----------------------------------------------------------------------
-lint : lint-license
+$(if $(DEBUG),$(warning ENTER))
-lint-license-gargs += --recursive
+$(if $(USE_LINT_LICENSE)\
+ ,$(eval include $(ONF_MAKEDIR)/lint/license/voltha-system-tests/include.mk)\
+ ,$(eval include $(ONF_MAKEDIR)/lint/license/common.mk)\
+)
-# ignore: png, xlsx
-# will utf8 be excluded(?)
-lint-license-gargs += --binary-files=without-match
-lint-license-gargs += --files-without-match
+ mk-include--onf-lint-license := true
-# [TODO] license checking accepts either Copy or Apache.
-# [TODO] At least Copyright should be required (both?)
-lint-license-gargs += --extended-regexp
-lint-license-gargs += -e 'Copyright[[:space:]]+[[:digit:]]{4}'
-lint-license-gargs += -e 'Apache License'
+$(if $(DEBUG),$(warning LEAVE))
-# [TODO] --strict, --strict-dates
+endif # mk-include--onf-lint-license
-# Editor temp files
-lint-license-gargs += --exclude='*.~'
-lint-license-gargs += --exclude='*.swp'
-
-lint-license-gargs += --exclude-dir='.git'
-
-# TODO: Normalize into .venv for consistent filtering across projects.
-lint-license-gargs += --exclude-dir='vst_venv'
-lint-license-gargs += --exclude-dir='flog'
-
-lint-license-gargs += --exclude='*.json'
-lint-license-gargs += --exclude='*.md'
-lint-license-gargs += --exclude='*.out'
-lint-license-gargs += --exclude='*.pyc'
-lint-license-gargs += --exclude='*.xml'
-
-# [FILE(s)]
-lint-license-gargs += --exclude='VERSION'
-
-# [GIT]
-# lint-license-gargs += --exclude='.gitignore'
-# lint-license-gargs += --exclude='.gitreview'
-lint-license-gargs += --exclude='\.*'
-
-# [PYTHON]
-lint-license-gargs += --exclude='requirements.txt'
-
-# [WIP]
-lint-license-gargs += --exclude='patch'
-
-## -----------------------------------------------------------------------
-## -----------------------------------------------------------------------
-lint-license-new:
- grep $(lint-license-gargs) $(dot)
-
-## -----------------------------------------------------------------------
-## Jenkins job checking logic.
-## -----------------------------------------------------------------------
-lint-license:
- $(MAKEDIR)/lint/license/license-check.sh
-
-## -----------------------------------------------------------------------
-## -----------------------------------------------------------------------
-help ::
- @echo " lint-license Verify sources contain a license block."
- @echo " lint-license-new Grep driven replacement logic."
+endif # NO-LINT-LICENSE
# [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/license/voltha-system-tests/include.mk b/makefiles/lint/license/voltha-system-tests/include.mk
new file mode 100644
index 0000000..b457f58
--- /dev/null
+++ b/makefiles/lint/license/voltha-system-tests/include.mk
@@ -0,0 +1,80 @@
+# -*- 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.
+# -----------------------------------------------------------------------
+
+.PHONY: lint-license
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+lint : lint-license
+
+lint-license-gargs += --recursive
+
+# ignore: png, xlsx
+# will utf8 be excluded(?)
+lint-license-gargs += --binary-files=without-match
+lint-license-gargs += --files-without-match
+
+# [TODO] license checking accepts either Copy or Apache.
+# [TODO] At least Copyright should be required (both?)
+lint-license-gargs += --extended-regexp
+lint-license-gargs += -e 'Copyright[[:space:]]+[[:digit:]]{4}'
+lint-license-gargs += -e 'Apache License'
+
+# [TODO] --strict, --strict-dates
+
+# TODO: Normalize into .venv for consistent filtering across projects.
+lint-license-gargs += --exclude-dir='.git'
+lint-license-gargs += --exclude-dir='$(venv-name)'
+lint-license-gargs += --exclude-dir='flog'
+
+lint-license-gargs += --exclude='*.json'
+lint-license-gargs += --exclude='*.md'
+lint-license-gargs += --exclude='*.pyc'
+lint-license-gargs += --exclude='*.xml'
+
+# [FILE(s)]
+lint-license-gargs += --exclude='VERSION'
+
+# [GIT]
+# lint-license-gargs += --exclude='.gitignore'
+# lint-license-gargs += --exclude='.gitreview'
+lint-license-gargs += --exclude='\.*'
+
+# [PYTHON]
+lint-license-gargs += --exclude='requirements.txt'
+
+# [WIP]
+lint-license-gargs += --exclude='patch'
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+lint-license-new:
+ grep $(lint-license-gargs) $(dot)
+
+## -----------------------------------------------------------------------
+## Jenkins job checking logic.
+## -----------------------------------------------------------------------
+lint-license:
+ $(MAKEDIR)/lint/license/license-check.sh
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+help::
+ @echo " lint-license Verify sources contain a license block."
+ @echo " lint-license-new Grep driven replacement logic."
+
+# [EOF]
diff --git a/makefiles/lint/license/voltha-system-tests/license-check.sh b/makefiles/lint/license/voltha-system-tests/license-check.sh
new file mode 100755
index 0000000..92aa363
--- /dev/null
+++ b/makefiles/lint/license/voltha-system-tests/license-check.sh
@@ -0,0 +1,159 @@
+#!/usr/bin/env bash
+
+# -----------------------------------------------------------------------
+# 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.
+# -----------------------------------------------------------------------
+
+# licensecheck.sh
+# checks for copyright/license headers on files
+# excludes filename extensions where this check isn't pertinent
+
+# --strict
+# --strict-dates
+# see https://github...
+
+## ---------------------------------------------------------------------------
+## find: warning: ‘-name’ matches against basenames only, but the given pattern
+## contains a directory separator (‘/’), thus the expression will evaluate to
+## false all the time. Did you mean ‘-wholename’?
+##
+## [TODO] find and fix plugin script, change --name to --path:
+## find ! -name "*/docs/*"
+## ---------------------------------------------------------------------------
+## [TODO] see license/include.mk, grep -L will ignore binaries so no need to
+## explicitly filter images, spreadsheets, etc. Files containing utf-8 are
+## the only question mark.
+## ---------------------------------------------------------------------------
+
+set +e -u -o pipefail
+fail_licensecheck=0
+
+declare -a gargs=()
+gargs+=('--extended-regexp')
+
+# Evil regex -- scripts detecting pattern are excluded from checking.
+gargs+=('-e' 'Apache License')
+
+# Good regex -- no false positives.
+gargs+=('-e' 'Copyright[[:space:]]+[[:digit:]]{4}')
+
+while IFS= read -r -d '' path
+do
+ if ! grep -q "${gargs[@]}" "${path}";
+ then
+ echo "ERROR: $path does not contain License Header"
+ fail_licensecheck=1
+ fi
+done < <(find . -name ".git" -prune -o -type f \
+ ! -iname "*.png" \
+ ! -name "*.asc" \
+ ! -name "*.bat" \
+ ! -name "*.bin" \
+ ! -name "*.cert" \
+ ! -name "*.cfg" \
+ ! -name "*.cnf" \
+ ! -name "*.conf" \
+ ! -name "*.cql" \
+ ! -name "*.crt" \
+ ! -name "*.csar" \
+ ! -name "*.csr" \
+ ! -name "*.csv" \
+ ! -name "*.ctmpl" \
+ ! -name "*.curl" \
+ ! -name "*.db" \
+ ! -name "*.der" \
+ ! -name "*.desc" \
+ ! -name "*.diff" \
+ ! -name "*.dnsmasq" \
+ ! -name "*.do" \
+ ! -name "*.docx" \
+ ! -name "*.eot" \
+ ! -name "*.gif" \
+ ! -name "*.gpg" \
+ ! -name "*.graffle" \
+ ! -name "*.ico" \
+ ! -name "*.iml" \
+ ! -name "*.in" \
+ ! -name "*.inc" \
+ ! -name "*.install" \
+ ! -name "*.j2" \
+ ! -name "*.jar" \
+ ! -name "*.jks" \
+ ! -name "*.jpg" \
+ ! -name "*.json" \
+ ! -name "*.jsonld" \
+ ! -name "*.JSON" \
+ ! -name "*.key" \
+ ! -name "*.list" \
+ ! -name "*.local" \
+ ! -path "*.lock" \
+ ! -name "*.log" \
+ ! -name "*.mak" \
+ ! -name "*.md" \
+ ! -name "*.MF" \
+ ! -name "*.oar" \
+ ! -name "*.p12" \
+ ! -name "*.patch" \
+ ! -name "*.pb.go" \
+ ! -name "*.pb.gw.go" \
+ ! -name "*.pdf" \
+ ! -name "*.pcap" \
+ ! -name "*.pem" \
+ ! -name "*.properties" \
+ ! -name "*.proto" \
+ ! -name "*.protoset" \
+ ! -name "*.pyc" \
+ ! -name "*.repo" \
+ ! -name "*.robot" \
+ ! -name "*.rst" \
+ ! -name "*.rules" \
+ ! -name "*.service" \
+ ! -name "*.svg" \
+ ! -name "*.swp" \
+ ! -name "*.tar" \
+ ! -name "*.tar.gz" \
+ ! -name "*.toml" \
+ ! -name "*.ttf" \
+ ! -name "*.txt" \
+ ! -name "*.woff" \
+ ! -name "*.xproto" \
+ ! -name "*.xtarget" \
+ ! -name "*ignore" \
+ ! -name "*rc" \
+ ! -name "*_pb2.py" \
+ ! -name "*_pb2_grpc.py" \
+ ! -name "Dockerfile" \
+ ! -name "Dockerfile.*" \
+ ! -name "go.mod" \
+ ! -name "go.sum" \
+ ! -name "README" \
+ ! -path "*/vendor/*" \
+ ! -path "*conf*" \
+ ! -path "*git*" \
+ ! -path "*swagger*" \
+ ! -path "*.drawio" \
+ ! -name "*.pb.h" \
+ ! -name "*.pb.cc" \
+ ! -path "*/docs/*" \
+ ! -name 'output.xml' \
+ ! -path "*/.venv/*" \
+ ! -name '*#*' \
+ ! -path '*scripts/flog/*' \
+ ! -name '*~' \
+ ! -name 'VERSION' \
+ ! -name 'patch' \
+ -print0 )
+
+exit ${fail_licensecheck}
diff --git a/makefiles/lint/python.mk b/makefiles/lint/license/voltha-system-tests/license-helper.sh
old mode 100644
new mode 100755
similarity index 63%
copy from makefiles/lint/python.mk
copy to makefiles/lint/license/voltha-system-tests/license-helper.sh
index 86503a7..0f690e4
--- a/makefiles/lint/python.mk
+++ b/makefiles/lint/license/voltha-system-tests/license-helper.sh
@@ -1,6 +1,6 @@
-# -*- makefile -*-
+#!/bin/bash
# -----------------------------------------------------------------------
-# Copyright 2017-2022 Open Networking Foundation
+# 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.
@@ -15,19 +15,17 @@
# limitations under the License.
# -----------------------------------------------------------------------
-PYTHON_FILES ?= $(error PYTHON_FILES= is required)
+declare -i status=$#
-.PHONY: lint-python
+while [ $# -gt 0 ]; do
+ arg="$1"; shift
+ echo "ERROR: Detected missing license header: ${arg}"
+done
-lint : lint-python
+if [ $status -ne 0 ]; then
+ exit 1
+fi
-lint-python: vst_venv
- -source ./$</bin/activate \
- && set -u \
- && pylint $(PYTHON_FILES) \
- && flake8 --max-line-length=99 --count $(PYTHON_FILES)
-
-help::
- @echo " lint-python Syntax check using pylint and flake8"
+/bin/true # set $?
# [EOF]
diff --git a/makefiles/lint/makefile.mk b/makefiles/lint/makefile.mk
new file mode 100644
index 0000000..27206e0
--- /dev/null
+++ b/makefiles/lint/makefile.mk
@@ -0,0 +1,65 @@
+# -*- 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.
+# -----------------------------------------------------------------------
+
+##-------------------##
+##---] GLOBALS [---##
+##-------------------##
+xargs-n1-local := $(subst -t,$(null),$(xargs-n1))# inhibit cmd display
+
+# Gather sources to check
+# TODO: implement deps, only check modified files
+make-check-find := find . -name 'vendor' -prune
+make-check-find += -o \( -iname makefile -o -name '*.mk' \)
+make-check-find += -type f -print0
+
+make-check := $(MAKE)
+
+make-check-args += --dry-run
+make-check-args += --keep-going
+make-check-args += --warn-undefined-variables
+make-check-args += --no-print-directory
+
+# Quiet internal undef vars
+make-check-args += DEBUG=
+
+##-------------------##
+##---] TARGETS [---##
+##-------------------##
+ifndef NO-LINT-MAKEFILE
+ lint : lint-make
+endif
+
+## -----------------------------------------------------------------------
+## Intent: Perform a lint check on makefile sources
+## -----------------------------------------------------------------------
+lint-make-ignore += JSON_FILES=
+lint-make-ignore += YAML_FILES=
+lint-make:
+ @echo
+ @echo "** -----------------------------------------------------------------------"
+ @echo "** Makefile syntax checking"
+ @echo "** -----------------------------------------------------------------------"
+ $(HIDE)$(env-clean) $(make-check-find) \
+ | $(xargs-n1-local) $(make-check) $(make-check-args) $(lint-make-ignore)
+
+## -----------------------------------------------------------------------
+## Intent: Display command help
+## -----------------------------------------------------------------------
+help-summary ::
+ @echo ' lint-make Syntax check [Mm]akefile and *.mk'
+
+# [EOF]
diff --git a/makefiles/lint/python.mk b/makefiles/lint/python/flake8
similarity index 93%
rename from makefiles/lint/python.mk
rename to makefiles/lint/python/flake8
index 86503a7..1492829 100644
--- a/makefiles/lint/python.mk
+++ b/makefiles/lint/python/flake8
@@ -25,7 +25,7 @@
-source ./$</bin/activate \
&& set -u \
&& pylint $(PYTHON_FILES) \
- && flake8 --max-line-length=99 --count $(PYTHON_FILES)
+ && flake8 --max-line-length=99 --count $(PYTHON_FILE)S
help::
@echo " lint-python Syntax check using pylint and flake8"
diff --git a/makefiles/lint/python/flake8.mk b/makefiles/lint/python/flake8.mk
new file mode 100644
index 0000000..4d7ba93
--- /dev/null
+++ b/makefiles/lint/python/flake8.mk
@@ -0,0 +1,49 @@
+# -*- 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 [---##
+##-------------------##
+
+# Gather sources to check
+# TODO: implement deps, only check modified files
+python-check-find := find . -name '*venv*' -prune\
+ -o \( -name '*.py' \)\
+ -type f -print0
+
+##-------------------##
+##---] TARGETS [---##
+##-------------------##
+ifndef NO-LINT-PYTHON-FLAKE8
+ lint : lint-python-flake8
+ lint-python : lint-python-flake8
+endif
+
+## -----------------------------------------------------------------------
+## Intent: Perform a lint check on makefile sources
+## -----------------------------------------------------------------------
+lint-python-flake8:
+ $(HIDE)$(env-clean) $(python-check-find) \
+ | $(xargs-n1) flake8 --max-line-length=99 --count
+
+## -----------------------------------------------------------------------
+## Intent: Display command help
+## -----------------------------------------------------------------------
+help-summary ::
+ @echo ' lint-python-flake8 Syntax check python sources (*.py)'
+
+# [EOF]
diff --git a/makefiles/lint/python/include.mk b/makefiles/lint/python/include.mk
new file mode 100644
index 0000000..0392822
--- /dev/null
+++ b/makefiles/lint/python/include.mk
@@ -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.
+# -----------------------------------------------------------------------
+
+ifndef mk-include--onf-lint-python# # one-time loader
+
+$(if $(DEBUG),$(warning ENTER))
+
+## -----------------------------------------------------------------------
+## Intent: Display early so lint targets are grouped
+## -----------------------------------------------------------------------
+help ::
+# @echo
+# @echo '[PYTHON]'
+ @echo ' lint-python Syntax check python sources (*.py)'
+# @echo ' help-lint-python-flake8'
+# @echo ' help-lint-python-pylint'
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+ ifndef NO-LINT-PYTHON
+ include $(ONF_MAKEDIR)/lint/python/flake8.mk
+ include $(ONF_MAKEDIR)/lint/python/pylint.mk
+ endif
+
+ mk-include--onf-lint-python := true
+
+$(if $(DEBUG),$(warning LEAVE))
+
+endif # mk-include--onf-lint-license
+
+# [EOF]
diff --git a/makefiles/lint/python/pylint.mk b/makefiles/lint/python/pylint.mk
new file mode 100644
index 0000000..85c7afd
--- /dev/null
+++ b/makefiles/lint/python/pylint.mk
@@ -0,0 +1,54 @@
+# -*- 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 [---##
+##-------------------##
+
+# Gather sources to check
+# TODO: implement deps, only check modified files
+python-check-find := find . -name '*venv*' -prune\
+ -o \( -name '*.py' \)\
+ -type f -print0
+
+# python-check := $(env-clean) pylint
+python-check := pylint
+
+# python-check-args += --dry-run
+
+##-------------------##
+##---] TARGETS [---##
+##-------------------##
+ifndef NO-LINT-PYTHON
+ lint : lint-python-pylint
+ lint-python : lint-python-pylint
+endif
+
+## -----------------------------------------------------------------------
+## Intent: Perform a lint check on makefile sources
+## -----------------------------------------------------------------------
+lint-python-pylint:
+ $(HIDE)$(env-clean) $(python-check-find) \
+ | $(xargs-n1) $(python-check) $(python-check-args)
+
+## -----------------------------------------------------------------------
+## Intent: Display command help
+## -----------------------------------------------------------------------
+help-summary ::
+ @echo ' lint-python-pylint Syntax check python sources (*.py)'
+
+# [EOF]
diff --git a/makefiles/lint/robot.mk b/makefiles/lint/robot.mk
index 9808602..369dfa8 100644
--- a/makefiles/lint/robot.mk
+++ b/makefiles/lint/robot.mk
@@ -30,10 +30,8 @@
lint : lint-robot
-lint-robot: vst_venv
- source ./$</bin/activate \
- && set -u \
- && rflint $(LINT_ARGS) $(ROBOT_FILES)
+lint-robot: $(venv-activate-script)
+ $(activate) && rflint $(LINT_ARGS) $(ROBOT_FILES)
help::
@echo " lint-robot Syntax check robot sources using rflint"
diff --git a/makefiles/lint/shell.mk b/makefiles/lint/shell.mk
index da92921..704038c 100644
--- a/makefiles/lint/shell.mk
+++ b/makefiles/lint/shell.mk
@@ -1,6 +1,6 @@
# -*- makefile -*-
# -----------------------------------------------------------------------
-# Copyright 2017-2022 Open Networking Foundation
+# 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.
@@ -14,20 +14,52 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# -----------------------------------------------------------------------
+# https://gerrit.opencord.org/plugins/gitiles/onf-make
+# ONF.makefile.version = 1.0
+# -----------------------------------------------------------------------
-JSON_FILES ?= $(error JSON_FILES= is required)
+##-------------------##
+##---] GLOBALS [---##
+##-------------------##
-.PHONY: lint-shell
+# Gather sources to check
+# TODO: implement deps, only check modified files
+shell-check-find := find .
+# vendor scripts but they really should be lintable
+shell-check-find += -name 'vendor' -prune
+shell-check-find += -o \( -name '*.sh' \)
+shell-check-find += -type f -print0
-lint : lint-shell
+# shell-check := $(env-clean) pylint
+shell-check := shellcheck
+shell-check-args += --check-sourced
+shell-check-args += --external-sources
+
+##-------------------##
+##---] TARGETS [---##
+##-------------------##
+ifndef NO-LINT-SHELL
+ lint : lint-shell
+endif
+
+## -----------------------------------------------------------------------
+## Intent: Perform a lint check on command line script sources
+## -----------------------------------------------------------------------
lint-shell:
- shellcheck --version
- find . \( -name 'staging' -o -name 'vst_venv' \) -prune \
- -o -name '*.sh' ! -name 'activate.sh' -print0 \
- | xargs -0 -n1 shellcheck
+ $(shell-check) -V
+ @echo
+ $(HIDE)$(env-clean) $(shell-check-find) \
+ | $(xargs-n1) $(shell-check) $(shell-check-args)
-help::
- @echo " lint-shell Syntax check bash,bourne,etc sources"
+## -----------------------------------------------------------------------
+## Intent: Display command help
+## -----------------------------------------------------------------------
+help-summary ::
+ @echo ' lint-shell Syntax check shell sources'
+
+# [SEE ALSO]
+# -----------------------------------------------------------------------
+# o https://www.shellcheck.net/wiki/Directive
# [EOF]
diff --git a/makefiles/lint/yaml.mk b/makefiles/lint/yaml.mk
index c9cb392..8672daa 100644
--- a/makefiles/lint/yaml.mk
+++ b/makefiles/lint/yaml.mk
@@ -1,8 +1,8 @@
# -*- makefile -*-
# -----------------------------------------------------------------------
-# Copyright 2017-2022 Open Networking Foundation
+# Copyright 2017-2023 Open Networking Foundation (ONF) and the ONF Contributors
#
-# Licensed under the Apache License, Version 2.0 (the "License");
+# 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
#
@@ -15,18 +15,71 @@
# limitations under the License.
# -----------------------------------------------------------------------
-YAML_FILES ?= $(error YAML_FILES= is required)
+$(if $(DEBUG),$(warning ENTER))
-.PHONY: lint-yaml
+##-------------------##
+##---] GLOBALS [---##
+##-------------------##
+.PHONY: lint-yaml lint-yaml-all lint-yaml-modified
-lint : lint-yaml
+## -----------------------------------------------------------------------
+## Intent: Use the yaml 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-yaml-all
+## -----------------------------------------------------------------------
-lint-yaml: vst_venv
- source ./$</bin/activate \
- ; set -u \
- ; yamllint -s $(YAML_FILES)
+ifndef NO-LINT-YAML
+ have-yaml-files := $(if $(strip $(YAML_FILES)),true)
+ YAML_FILES ?= $(error YAML_FILES= is required)
+ lint-yaml-mode := $(if $(have-yaml-files),modified,all)
+ lint-yaml : lint-yaml-$(lint-yaml-mode)
+
+ lint : lint-yaml# # Enable as a default lint target
+endif# NO-LINT-YAML
+
+## -----------------------------------------------------------------------
+## Intent: exhaustive yaml syntax checking
+## -----------------------------------------------------------------------
+lint-yaml-all:
+ $(HIDE)$(MAKE) --no-print-directory lint-yaml-install
+
+ find . \( -iname '*.yaml' -o -iname '*.yml' \) -print0 \
+ | $(xargs-n1-clean) yamllint --strict
+
+## -----------------------------------------------------------------------
+## Intent: check deps for format and python3 cleanliness
+## Note:
+## yaml --py3k option no longer supported
+## -----------------------------------------------------------------------
+lint-yaml-modified:
+ $(HIDE)$(MAKE) --no-print-directory lint-yaml-install
+ yamllint -s $(YAML_FILES)
+
+## -----------------------------------------------------------------------
+## Intent:
+## -----------------------------------------------------------------------
+lint-yaml-install:
+ @echo
+ @echo "** -----------------------------------------------------------------------"
+ @echo "** yaml syntax checking"
+ @echo "** -----------------------------------------------------------------------"
+ yamllint --version
+ @echo
+
+## -----------------------------------------------------------------------
+## Intent: Display command usage
+## -----------------------------------------------------------------------
help::
- @echo " lint-yaml Syntax check yaml source using yamllint"
+ @echo ' lint-yaml Syntax check python using the yaml command'
+ ifdef VERBOSE
+ @echo ' lint-yaml-all yaml checking: exhaustive'
+ @echo ' lint-yaml-modified yaml checking: only locally modified'
+ endif
+
+$(if $(DEBUG),$(warning LEAVE))
# [EOF]