Makefile edits to improve library lint target support.
Makefile
--------
o Replace inlined includes with single $(MAKEDIR)/include.mk
o virtualenv install w/dependencies handled by makefiles/virtualenv.mk
o Use '&&' for command separation to improve error handling.
o Added more target documentation.
o Re-home doc8/rst syntax checking into makefiles/lint/doc8.mk.
howto/code/linting.rst
----------------------
o Document supported lint targets on docs.voltha.org.
howto/release/index.rst
howto/release/post-release/
howto/release/vcs/
---------------------------
o Document more release related activity (bugfix branch creation)
makefiles/consts.mk
-------------------
o Define and use more library macros.
config.mk
---------
o Per-repository library makefile configuration, disable linting.
makefiles/virtualenv.mk
-----------------------
o Library virtualenv install with dependences.
o Begin using a consistent install directory.
o Ugh: repository (voltha-docs) submodules each install a full venv.
o Install dependency drive based on existence of activate script.
o Lint targets updated to use activate script as a dependency.
o Update activate macro to run: set -u && activate && set +u
makefiles/patches/include.mk
----------------------------
o Update to use virtualenv.mk defined macros.
makefiles/lint/doc8.mk
makefiles/lint/python/flake8.mk
makefiles/lint/json.mk
makefiles/lint/python/pylint.mk
makefiles/lint/robot.mk
makefiles/lint/shell.mk
makefiles/lint/yaml.mk
-------------------------------
o All library linting defines consistent targets and logic.
o Support two library targets: lint-all and lint-modified.
o Default to checking all available sources.
o Linting can be disabled per-repository via {project}/config.mk
Change-Id: I7b7b5e523c867183d44244a0da21cfa3584e9a50
diff --git a/Makefile b/Makefile
index ba5bba0..0ae2243 100644
--- a/Makefile
+++ b/Makefile
@@ -26,10 +26,8 @@
##--------------------##
##---] INCLUDES [---##
##--------------------##
-include $(MAKEDIR)/consts.mk
-include $(MAKEDIR)/help/include.mk
-include $(MAKEDIR)/patches/include.mk
-include $(MAKEDIR)/help/variables.mk
+-include config.mk
+include $(MAKEDIR)/include.mk
# You can set these variables from the command line.
SPHINXOPTS ?=
@@ -50,43 +48,17 @@
# Static docs, built by other means (usually robot framework)
STATIC_DOCS := _static/voltha-system-tests _static/cord-tester
-# name of python virtualenv that is used to run commands
-VENV_NAME := venv_docs
-
+# Why is existing source Makefile PHONY (?)
.PHONY: help test lint reload Makefile prep
-# Put it first so that "make" without argument is like "make help".
-help :: $(VENV_NAME)
- @ echo
- @ source $</bin/activate ; set -u ;\
- $(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
-
-# -----------------------------------------------------------------------
-# Create the virtualenv with all the tools installed
-# -----------------------------------------------------------------------
-.PHONY: venv
-venv: $(VENV_NAME)
-
-$(VENV_NAME):
- @echo
- @echo "============================="
- @echo "Installing python virtual env"
- @echo "============================="
- virtualenv -p python3 $@ ;\
- source ./$@/bin/activate ;\
- python -m pip install -r requirements.txt
-ifndef NO_PATCH
- @echo
- @echo "========================================"
- @echo "Applying python virtualenv patches as needed (v3.10+)"
- @echo "========================================"
- ./patches/python_310_migration.sh '--venv' "$@" 'apply'
-endif
-
-# automatically reload changes in browser as they're made
-reload: $(VENV_NAME)
- source $</bin/activate ; set -u ;\
- sphinx-reload $(SOURCEDIR)
+## -----------------------------------------------------------------------
+## Intent: Real time viewing, dynamically generate and reload document
+## changes for web browser viewing.
+## Usage:
+## make reload
+## -----------------------------------------------------------------------
+reload: $(venv-activate-script)
+ $(activate) && sphinx-reload $(SOURCEDIR)
## -----------------------------------------------------------------------
## Intent: lint and link verification. linkcheck is part of sphinx
@@ -95,6 +67,7 @@
## -----------------------------------------------------------------------
## Intent: Exercise all generation targets
+## Bridge: library workaround to support legacy targets
## -----------------------------------------------------------------------
test-all-targets += html
test-all-targets += coverage
@@ -104,22 +77,13 @@
test-all-targe4ts += text
# test-all-targets += latex
-
test-all : test
$(MAKE) $(test-all-targets)
# doctest
# coverage
# linkcheck
-lint: doc8
-# include $(MAKEDIR)/lint/shell.mk
-doc8: $(VENV_NAME) | $(OTHER_REPO_DOCS)
- source $</bin/activate ; set -u ;\
- doc8 --max-line-length 119 \
- $$(find . -name \*.rst ! -path "*venv*" ! -path "*vendor*" ! -path "*repos*" )
-
-# markdown linting
# currently not enabled, should be added to lint target
LINT_STYLE ?= mdl_strict.rb
md-lint: | $(OTHER_REPO_DOCS)
@@ -128,14 +92,14 @@
@echo "---"
@cat $(LINT_STYLE)
@echo "---"
- mdl -s $(LINT_STYLE) `find -L $(SOURCEDIR) ! -path "./_$(VENV_NAME)/*" ! -path "./_build/*" ! -path "./repos/*" ! -path "*vendor*" -name "*.md"`
+ mdl -s $(LINT_STYLE) `find -L $(SOURCEDIR) ! -path "./_$(venv-activate-script)/*" ! -path "./_build/*" ! -path "./repos/*" ! -path "*vendor*" -name "*.md"`
# clean up
clean:
$(RM) -r $(BUILDDIR) $(OTHER_REPO_DOCS) $(STATIC_DOCS)
-clean-all sterile: clean
- $(RM) -r $(VENV_NAME) repos
+clean-all sterile :: clean
+ $(RM) -r $(venv-activate-script) repos
# checkout the repos inside repos/ dir
repos:
@@ -157,8 +121,10 @@
then git clone $(REPO_HOST)/$(@F) $@ ;\
fi
-# checkout correct ref if not under test, then copy subdirectories into main
-# docs dir
+## -----------------------------------------------------------------------
+## Intent: checkout correct ref if not under test, then copy
+## subdirectories into main docs dir
+## -----------------------------------------------------------------------
$(OTHER_REPO_DOCS): | $(CHECKOUT_REPOS)
if [ "$(SKIP_CHECKOUT)" != "$@" ] ;\
then GIT_REF=`grep '^$@ ' git_refs | awk '{print $$3}'` ;\
@@ -179,7 +145,9 @@
mkdir -p $@
cp -r cord-tester/gendocs/* $@
-# generate a list of git checksums suitable for updating git_refs
+## -----------------------------------------------------------------------
+## Intent: generate a list of git checksums suitable for updating git_refs
+## -----------------------------------------------------------------------
freeze: repos
@for repo in $(OTHER_REPO_DOCS) ; do \
GIT_SUBDIR=`grep "^$$repo " git_refs | awk '{print $$2}'` ;\
@@ -189,24 +157,29 @@
cd ../.. ;\
done
-# build multiple versions
-multiversion: $(VENV_NAME) Makefile | prep $(OTHER_REPO_DOCS)
- source $</bin/activate ; set -u ;\
- sphinx-multiversion "$(SOURCEDIR)" "$(BUILDDIR)/multiversion" $(SPHINXOPTS)
+## -----------------------------------------------------------------------
+## Intent: build multiple versions
+## -----------------------------------------------------------------------
+multiversion: $(venv-activate-script) Makefile | prep $(OTHER_REPO_DOCS)
+ $(activate)\
+ && sphinx-multiversion "$(SOURCEDIR)" "$(BUILDDIR)/multiversion" $(SPHINXOPTS)
cp "$(SOURCEDIR)/_templates/meta_refresh.html" "$(BUILDDIR)/multiversion/index.html"
-# prep target - used in sphinx-multiversion to properly link
+## -----------------------------------------------------------------------
+## Intent: used in sphinx-multiversion to properly link
+## -----------------------------------------------------------------------
prep: | $(OTHER_REPO_DOCS) $(STATIC_DOCS)
-# Catch-all target: route all unknown targets to Sphinx using the new
-# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
-# %: $(VENV_NAME) Makefile | $(OTHER_REPO_DOCS) $(STATIC_DOCS)
-
+## -----------------------------------------------------------------------
+## Intent: Forward sphinx supported targets to sphinxbuild.
+## Bridge: legacy makefile wildcard rule forwarded unknown targets to sphinx.
+## library makefiles do more so transfer control only when needed.
+## -----------------------------------------------------------------------
include $(MAKEDIR)/voltha/docs-catchall-targets.mk
-$(voltha-docs-catchall): $(VENV_NAME) Makefile | $(OTHER_REPO_DOCS) $(STATIC_DOCS)
+$(voltha-docs-catchall): $(venv-activate-script) Makefile | $(OTHER_REPO_DOCS) $(STATIC_DOCS)
@echo " ** CATCHALL: $@"
- source $</bin/activate ; set -u ;\
- $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
+ $(activate)\
+ && $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
## -----------------------------------------------------------------------
## -----------------------------------------------------------------------
@@ -215,6 +188,15 @@
"$(BROWSER)" _build/html/index.html
## -----------------------------------------------------------------------
+## Intent: Display makefile target help
+## -----------------------------------------------------------------------
+help :: $(venv-activate-script)
+ @ echo
+ $(HIDE)$(activate) \
+ && $(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
+
+## -----------------------------------------------------------------------
+## Intent: Display make hel footer
## -----------------------------------------------------------------------
include $(MAKEDIR)/help/trailer.mk
diff --git a/VERSION b/VERSION
index 6ceb272..c7e0a98 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.11.1
+2.11.1-dev1
diff --git a/config.mk b/config.mk
new file mode 100644
index 0000000..2add84e
--- /dev/null
+++ b/config.mk
@@ -0,0 +1,45 @@
+# -*- 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.
+# -----------------------------------------------------------------------
+
+##---------------------------------------##
+##---] Disable lint targets by name [---##
+##---------------------------------------##
+# NO-LINT-DOC8 := true
+NO-LINT-FLAKE8 := true# # NOTE[1]
+# NO-LINT-JJB := true
+NO-LINT-JSON := true
+# python -m json.tool ./_build/linkcheck/output.json
+# Extra data: line 2 column 1 (char 181)
+# NO-LINT-MAKE := true
+NO-LINT-PYLINT := true# # NOTE[1]
+# NO-LINT-PYTHON := true
+NO-LINT-ROBOT := true# # NOTE[2]
+# NO-LINT-SHELL := true
+# NO-LINT-TOX := true# # WIP
+# NO-LINT-YAML := true
+
+# NOTE[1] - Cleanup needed to enable as a default make lint target
+# NOTE[2] - Doc repo, no need to lint robot sources here.
+
+##-----------------------------##
+##---] Custom exclusions [---##
+##-----------------------------##
+lint-doc8-excl += --ignore-path "vendor"
+
+config-mk-version := 1.0
+
+# [EOF]
diff --git a/howto/code/linting.rst b/howto/code/linting.rst
index cc837f7..9550d54 100644
--- a/howto/code/linting.rst
+++ b/howto/code/linting.rst
@@ -11,15 +11,19 @@
make help | grep lint
lint-chart chart_version_check.sh
+ lint-doc8 Syntax check *.rst documentation files.
lint-helm Syntax check helm configs
lint-json Syntax check json sources
lint-license Verify sources contain a license block.
- lint-python Syntax check using pylint and flake8
lint-robot Syntax check robot sources using rflint
lint-shell Syntax check bash,bourne,etc sources
lint-yaml Syntax check yaml source using yamllint
UNSTABLE= Build targets prone to failure (lint-helm)
+ [PYTHON]
+ lint-flake8 Syntax check using pylint and flake8
+ lint-pylint Syntax check using pylint and flake8
+
|
@@ -51,6 +55,57 @@
|
+doc8 / RST files
+++++++++++++++++
+
+Command: `doc8 <https://pypi.org/project/doc8/>`_
+
+.. code:: bash
+
+ make clean
+ make lint 2>&1 | tee log
+ make lint-doc8-all 2>&1 | tee log
+ make lint-doc8-modified 2>&1 | tee log
+
+Sources:
+
+- `makefiles/lint <https://gerrit.opencord.org/plugins/gitiles/voltha-docs/+/refs/heads/master/makefiles/lint/>`__
+- makefiles/lint/doc8.mk
+
+Notes:
+
+- lint-doc8-all target dependency will create a `python virtual env <https://wiki.opennetworking.org/display/JOEY/PythonVenv>`_
+- python 3.10+ requires `virtual env patching <https://gerrit.opencord.org/plugins/gitiles/voltha-docs/+/refs/heads/master/patches/>`_ (dynamic, applied when needed).
+- `makefiles/patches/include.mk <https://gerrit.opencord.org/plugins/gitiles/voltha-docs/+/refs/heads/master/makefiles/patches/>`_
+
+|
+
+
+python: flake8
+++++++++++++++
+
+Command: `flake8 <https://flake8.pycqa.org/en/latest>`_
+
+.. code:: bash
+
+ make clean
+ make lint 2>&1 | tee log
+ make lint-flake8-all 2>&1 | tee log
+ make lint-flake8-modified 2>&1 | tee log
+
+Sources:
+
+- `makefiles/lint <https://gerrit.opencord.org/plugins/gitiles/voltha-docs/+/refs/heads/master/makefiles/lint/>`__
+- makefiles/lint/flake8.mk
+
+Notes:
+
+- lint-flake8-all target dependency will create a `python virtual env <https://wiki.opennetworking.org/display/JOEY/PythonVenv>`_
+- python 3.10+ requires `virtual env patching <https://gerrit.opencord.org/plugins/gitiles/voltha-docs/+/refs/heads/master/patches/>`_ (dynamic, applied when needed).
+- `makefiles/patches/include.mk <https://gerrit.opencord.org/plugins/gitiles/voltha-docs/+/refs/heads/master/makefiles/patches/>`_
+
+|
+
Helm Charts
+++++++++++
@@ -86,13 +141,14 @@
JSON
++++
-Command:
-- `json.tool <https://docs.python.org/3/library/json.html>`_
+Command: `json.tool <https://docs.python.org/3/library/json.html>`_
.. code:: bash
make clean
- make lint-json 2>&1 | tee log
+ make lint 2>&1 | tee log
+ make lint-json-all 2>&1 | tee log
+ make lint-json-modified 2>&1 | tee log
Sources:
@@ -120,28 +176,28 @@
|
-python
-++++++
+python: pylint
+++++++++++++++
-Command:
-- `flake8 <https://flake8.pycqa.org/en/latest>`_
-- `pylint <https://www.pylint.org/>`_
+Command: `pylint <https://www.pylint.org/>`_
.. code:: bash
make clean
- make lint-python 2>&1 | tee log
+ make lint 2>&1 | tee log
+ make lint-pylint-all 2>&1 | tee log
+ make lint-pylint-modified 2>&1 | tee log
Sources:
- `makefiles/lint <https://gerrit.opencord.org/plugins/gitiles/voltha-docs/+/refs/heads/master/makefiles/lint/>`__
-- `makefiles/lint/python.mk <https://gerrit.opencord.org/plugins/gitiles/voltha-docs/+/refs/heads/master/makefiles/lint/python.mk>`_
+- makefiles/lint/pylint.mk
- `makefiles/patches/include.mk <https://gerrit.opencord.org/plugins/gitiles/voltha-docs/+/refs/heads/master/makefiles/patches/>`_
Notes:
- pylint the --py3k option is no longer supported by v3.10+
-- lint-python target dependency will create a `python virtual env <https://wiki.opennetworking.org/display/JOEY/PythonVenv>`_
+- lint-pylint-all target dependency will create a `python virtual env <https://wiki.opennetworking.org/display/JOEY/PythonVenv>`_
- python 3.10+ requires `virtual env patching <https://gerrit.opencord.org/plugins/gitiles/voltha-docs/+/refs/heads/master/patches/>`_ (dynamic, applied when needed).
|
@@ -150,12 +206,19 @@
Robot
+++++
-Command: rflint
+Command: rflint `robotframework-lint <https://pypi.org/project/robotframework-lint/>`_
+
+.. code:: bash
+
+ make clean
+ make lint 2>&1 | tee log
+ make lint-robot-all 2>&1 | tee log
+ make lint-robot-modified 2>&1 | tee log
Sources:
- `makefiles/lint <https://gerrit.opencord.org/plugins/gitiles/voltha-docs/+/refs/heads/master/makefiles/lint/>`__
-- `makefiles/lint/robot.mk <https://gerrit.opencord.org/plugins/gitiles/voltha-system-tests/+/refs/heads/master/makefiles/lint/robot.mk>`_
+- `makefiles/lint/robot.mk <https://gerrit.opencord.org/plugins/gitiles/voltha-docs/+/refs/heads/master/makefiles/lint/robot.mk>`_
|
@@ -178,10 +241,17 @@
Command: `shellcheck <https://github.com/koalaman/shellcheck>`_
+.. code:: bash
+
+ make clean
+ make lint 2>&1 | tee log
+ make lint-shell-all 2>&1 | tee log
+ make lint-shell-modified 2>&1 | tee log
+
Sources:
- `makefiles/lint <https://gerrit.opencord.org/plugins/gitiles/voltha-docs/+/refs/heads/master/makefiles/lint/>`__
-- `makefiles/lint/shell.mk <https://gerrit.opencord.org/plugins/gitiles/voltha-system-tests/+/refs/heads/master/makefiles/lint/shell.mk>`_
+- `makefiles/lint/shell.mk <https://gerrit.opencord.org/plugins/gitiles/voltha-docs/+/refs/heads/master/makefiles/lint/shell.mk>`_
|
@@ -189,17 +259,19 @@
Yaml
++++
-Command: yamllint
+Command: `yamllint <https://yamllint.readthedocs.io/en/stable/>`_
.. code:: bash
make clean
- make lint-yaml 2>&1 | tee log
+ make lint 2>&1 | tee log
+ make lint-yaml-all 2>&1 | tee log
+ make lint--modified 2>&1 | tee log
Sources:
- `makefiles/lint <https://gerrit.opencord.org/plugins/gitiles/voltha-docs/+/refs/heads/master/makefiles/lint/>`__
-- `makefiles/lint/yaml.mk <https://gerrit.opencord.org/plugins/gitiles/voltha-system-tests/+/refs/heads/master/makefiles/lint/yaml.mk>`_
+- `makefiles/lint/yaml.mk <https://gerrit.opencord.org/plugins/gitiles/voltha-docs/+/refs/heads/master/makefiles/lint/yaml.mk>`_
|
@@ -222,7 +294,7 @@
- [`master <https://gerrit.opencord.org/plugins/gitiles/pod-configs/+/refs/heads/master>`__] `pod-configs <https://gerrit.opencord.org/plugins/gitiles/pod-configs>`_
- [`master <https://gerrit.opencord.org/plugins/gitiles/voltha-docs/+/refs/heads/master>`__] `voltha-docs <https://gerrit.opencord.org/plugins/gitiles/voltha-docs>`_
- [`master <https://gerrit.opencord.org/plugins/gitiles/voltha-helm-charts/+/refs/heads/master>`__] `voltha-helm-charts <https://gerrit.opencord.org/plugins/gitiles/voltha-helm-charts>`_
-- [`master <https://gerrit.opencord.org/plugins/gitiles/voltha-system-tests/+/refs/heads/master>`__] `voltha-system-tests <https://gerrit.opencord.org/plugins/gitiles/voltha-system-tests>`_
+- [`master <https://gerrit.opencord.org/plugins/gitiles/voltha-docs/+/refs/heads/master>`__] `voltha-docs <https://gerrit.opencord.org/plugins/gitiles/voltha-docs>`_
|
@@ -230,8 +302,11 @@
Notes
~~~~~
-- Make lint complaints are not necessarily fatal.
- Volume problem reports require cleanup before linting can become a default.
+
+ - After bulk linting problems for a language source have been cleaned up
+ default linting can be enabled by modifing {project-root}/config.mk.
+
- Lint target support is globally available across repositories, given time
it will be. Submit patches as needed or open a jira ticket to request
linting support in specific repositories.
diff --git a/howto/release/index.rst b/howto/release/index.rst
index e4178cb..39d5cf5 100644
--- a/howto/release/index.rst
+++ b/howto/release/index.rst
@@ -7,6 +7,7 @@
components/index
hierarchy/index
voltha-docs/index
+ post-release/index
voltctl/index
voltctl/install
diff --git a/howto/release/post-release/gitreview.rst b/howto/release/post-release/gitreview.rst
new file mode 100644
index 0000000..7bebb82
--- /dev/null
+++ b/howto/release/post-release/gitreview.rst
@@ -0,0 +1,30 @@
+gitreview branch update
+-----------------------
+
+After a release has been created and repositories have been branched & tagged:
+
+- voltha-helm-charts
+- voltha-system-tests
+
+Update the .gitreview file on the voltha-x.y release branch so commits are
+directed to branch=voltha-x.y rather than the default voltha=master
+
+.. code-block::
+ :emphasize-lines: 6
+
+ [gerrit]
+ host=gerrit.opencord.org
+ port=29418
+ project=voltha-helm-charts.git
+ defaultremote=origin
+ defaultbranch=master
+
+.. code-block::
+ :emphasize-lines: 6
+
+ [gerrit]
+ host=gerrit.opencord.org
+ port=29418
+ project=voltha-helm-charts.git
+ defaultremote=origin
+ defaultbranch=voltha-2.11
diff --git a/howto/release/post-release/index.rst b/howto/release/post-release/index.rst
new file mode 100644
index 0000000..3aadb95
--- /dev/null
+++ b/howto/release/post-release/index.rst
@@ -0,0 +1,9 @@
+VOLTHA Post Release Tasks
+=========================
+
+.. toctree::
+ :maxddepth 1
+
+ gitreview
+
+- Deprecated code marked for release (v2.6, v2.8 after v2.11) can be removed.
diff --git a/howto/release/vcs/notes b/howto/release/vcs/notes
new file mode 100644
index 0000000..4a7ef94
--- /dev/null
+++ b/howto/release/vcs/notes
@@ -0,0 +1,12 @@
+voltha-helm-charts
+voltha-system-tests
+ branch[1]: voltha-2.11
+ tag[2]: 2.11.0
+ update[3]: .gitreview
+
+
+voltha-openolt-adapter
+voltha-openonu-adapter
+ 1) git tag -a "Release tagging" v2.11.0 # (golang format: v + {revision})
+
+ branch[2]: voltha-2.11
diff --git a/makefiles/consts.mk b/makefiles/consts.mk
index 043ec65..bac4362 100644
--- a/makefiles/consts.mk
+++ b/makefiles/consts.mk
@@ -13,16 +13,40 @@
# 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
# -----------------------------------------------------------------------
-null :=#
-space :=$(null) $(null)
-dot :=.
-HIDE ?=@
+$(if $(DEBUG),$(warning ENTER))
-# use bash for pusdh/popd and quick failures.
-# virtual env(s) activate has undefined vars so no -u
-# ^---+ verify this is still true
-export SHELL := bash -e -o pipefail
+# include makefiles/constants.mk
+export dot :=.
+export null :=#
+export space := $(null) $(null)
+export quote-single := $(null)"$(null)#"
+export quote-double := $(null)'$(null)#'
+
+# [DEBUG] make {target} HIDE=
+HIDE ?= @
+
+env-clean ?= /usr/bin/env --ignore-environment
+xargs-n1 := xargs -0 -t -n1 --no-run-if-empty
+xargs-n1-clean := $(env-clean) $(xargs-n1)
+
+## -----------------------------------------------------------------------
+## Default shell:
+## o set -e enable error checking
+## o set -u report undefined errors
+## o set -o pipefail propogate shell pipeline failures.
+## -----------------------------------------------------------------------
+SHELL ?= /bin/bash
+have-shell-bash := $(filter bash,$(subst /,$(space),$(SHELL)))
+$(if $(have-shell-bash),$(null),\
+ $(eval export SHELL := bash -euo pipefail))
+
+export SHELL ?= bash -euo pipefail
+
+$(if $(DEBUG),$(warning LEAVE))
# [EOF]
diff --git a/makefiles/include.mk b/makefiles/include.mk
new file mode 100644
index 0000000..3042488
--- /dev/null
+++ b/makefiles/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.
+#
+# SPDX-FileCopyrightText: 2022 Open Networking Foundation (ONF) and the ONF Contributors
+# SPDX-License-Identifier: Apache-2.0
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+# OPT_ROOT ?= /opt/trainlab/current
+# OPT_MAKEDIR := $(OPT_ROOT)/makefiles
+# MAKEDIR ?= $(OPT_MAKEDIR)
+
+ONF_MAKE ?= $(MAKEDIR)# [TODO] -- local and library makefiles/ needed.
+ONF_MAKE ?= $(error ONF_MAKE= is required)
+
+include $(ONF_MAKE)/consts.mk
+include $(ONF_MAKE)/help/include.mk
+
+include $(ONF_MAKE)/virtualenv.mk# # lint-{jjb,python} depends on venv
+include $(ONF_MAKE)/lint/include.mk
+include $(ONF_MAKE)/todo.mk
+include $(MAKEDIR)/patches/include.mk# # Patch when python 3.10+ in use
+include $(ONF_MAKE)/help/variables.mk
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/makefiles/lint/doc8.mk b/makefiles/lint/doc8.mk
new file mode 100644
index 0000000..e0594df
--- /dev/null
+++ b/makefiles/lint/doc8.mk
@@ -0,0 +1,79 @@
+# -*- 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
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+lint-doc8-excl += --ignore-path '$(venv-name)'
+lint-doc8-excl += --ignore-path '$(BUILDDIR)'
+
+# YUCK! -- overhead
+# o Submodule(s) use individual/variant virtualenv install paths.
+# o Exclude special snowflakes to enable library makefile use.
+# o [TODO] Use makefiles/virtualenv.mk to avoid duplication.
+
+lint-doc8-excl += --ignore-path '*/venv_cord'
+lint-doc8-excl += --ignore-path '*/vst_venv'
+
+lint-doc8-excl += --ignore-path './cord-tester'
+lint-doc8-excl += --ignore-path './repos/cord-tester'
+
+lint-doc8-excl += --ignore-path './bbsim/internal/bbsim/responders/sadis/dp.txt'
+lint-doc8-excl += --ignore-path './repos/bbsim/internal/bbsim/responders/sadis/dp.txt'
+lint-doc8-excl += --ignore-path './repos/voltha-helm-charts/voltha-infra/templates/NOTES.txt'
+lint-doc8-excl += --ignore-path './voltha-helm-charts/voltha-infra/templates/NOTES.txt'
+
+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) $(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/include.mk b/makefiles/lint/include.mk
index 0f653c9..96f6bce 100644
--- a/makefiles/lint/include.mk
+++ b/makefiles/lint/include.mk
@@ -15,12 +15,29 @@
# limitations under the License.
# -----------------------------------------------------------------------
+# -----------------------------------------------------------------------
+# Intent: Display help banner early before library lint help targets.
+# -----------------------------------------------------------------------
help::
@echo
@echo "[LINT]"
+## Disable python linting in bulk ?
+ifdef NO-LINT-PYTHON
+ NO-LINT-FLAKE8 := true
+ NO-LINT-PYLINT := true
+endif
+
+# Define early else {flake8,pylint}.mk will complain:
+# PYTHON_FILES ?= $(error)
+have-python-files := $(if $(strip $(PYTHON_FILES)),true)
+
+##--------------------##
+##---] INCLUDES [---##
+##--------------------##
+include $(MAKEDIR)/lint/doc8.mk
include $(MAKEDIR)/lint/json.mk
-include $(MAKEDIR)/lint/python.mk
+include $(MAKEDIR)/lint/python/include.mk
include $(MAKEDIR)/lint/robot.mk
include $(MAKEDIR)/lint/shell.mk
include $(MAKEDIR)/lint/yaml.mk
diff --git a/makefiles/lint/json.mk b/makefiles/lint/json.mk
index e67fee1..1deeaba 100644
--- a/makefiles/lint/json.mk
+++ b/makefiles/lint/json.mk
@@ -1,8 +1,8 @@
# -*- makefile -*-
# -----------------------------------------------------------------------
-# Copyright 2017-2023 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 rqeuired)
+$(if $(DEBUG),$(warning ENTER))
-.PHONY: lint-json
+##-------------------##
+##---] GLOBALS [---##
+##-------------------##
+.PHONY: lint-json lint-json-all lint-json-modified
-lint : 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
+## -----------------------------------------------------------------------
+## 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
+ 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/python/flake8.mk b/makefiles/lint/python/flake8.mk
new file mode 100644
index 0000000..bb474a9
--- /dev/null
+++ b/makefiles/lint/python/flake8.mk
@@ -0,0 +1,85 @@
+# -*- 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-mode)
+endif# NO-LINT-FLAKE8
+
+## -----------------------------------------------------------------------
+## Intent: exhaustive flake8 syntax checking
+## -----------------------------------------------------------------------
+lint-flake8-all: $(venv-activate-script)
+ $(HIDE)$(MAKE) --no-print-directory lint-flake8-install
+
+ $(activate)\
+ && find . \( -name '$(venv-name)' \) -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'
+ endif
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/makefiles/lint/python.mk b/makefiles/lint/python/include.mk
similarity index 62%
rename from makefiles/lint/python.mk
rename to makefiles/lint/python/include.mk
index d8bdfe0..69811a5 100644
--- a/makefiles/lint/python.mk
+++ b/makefiles/lint/python/include.mk
@@ -1,6 +1,6 @@
# -*- makefile -*-
# -----------------------------------------------------------------------
-# Copyright 2017-2023 Open Networking Foundation
+# 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.
@@ -15,20 +15,13 @@
# limitations under the License.
# -----------------------------------------------------------------------
-PYTHON_FILES ?= $(error PYTHON_FILES= is required)
+##-------------------##
+##---] GLOBALS [---##
+##-------------------##
+$(if $(UNSTABLE),$(eval lint-python-all := true))
-.PHONY: lint-python
-
-lint : lint-python
-
-# check deps for format and python3 cleanliness
-lint-python: vst_venv
- source ./$</bin/activate \
- ; set -u \
- ; pylint --py3k $(PYTHON_FILES) \
- ; flake8 --max-line-length=99 --count $(PYTHON_FILES)
-
-help::
- @echo " lint-python Syntax check using pylint and flake8"
+include $(MAKEDIR)/lint/python/flake8.mk
+include $(MAKEDIR)/lint/python/pylint.mk
+# include $(MAKEDIR)/lint/python/tox.mk
# [EOF]
diff --git a/makefiles/lint/python/pylint.mk b/makefiles/lint/python/pylint.mk
new file mode 100644
index 0000000..9dc1c7c
--- /dev/null
+++ b/makefiles/lint/python/pylint.mk
@@ -0,0 +1,89 @@
+# -*- 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-mode)
+endif# NO-LINT-PYLINT
+
+## -----------------------------------------------------------------------
+## Intent: exhaustive pylint syntax checking
+## -----------------------------------------------------------------------
+pylint-find-args := $(null)
+pylint-find-args += -name '$(venv-name)'
+pylint-find-args += -o -name 'patches'
+lint-pylint-all: $(venv-activate-script)
+ $(MAKE) --no-print-directory lint-pylint-install
+
+ $(activate)\
+ && find . \( $(pylint-find-args) \) -prune -o -name '*.py' -print0 \
+ | $(xargs-n1) pylint
+
+## -----------------------------------------------------------------------
+## 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'
+ endif
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/makefiles/lint/robot.mk b/makefiles/lint/robot.mk
index 1c7119f..fa8175c 100644
--- a/makefiles/lint/robot.mk
+++ b/makefiles/lint/robot.mk
@@ -1,8 +1,8 @@
# -*- makefile -*-
# -----------------------------------------------------------------------
-# Copyright 2017-2023 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,7 +15,15 @@
# limitations under the License.
# -----------------------------------------------------------------------
-ROBOT_FILES ?= $(error ROBOT_FILES= is required)
+$(if $(DEBUG),$(warning ENTER))
+
+##-------------------##
+##---] GLOBALS [---##
+##-------------------##
+.PHONY: lint-robot lint-robot-all lint-robot-modified
+
+have-robot-files := $(if $(ROBOT_FILES),true)
+ROBOT_FILES ?= $(error ROBOT_FILES= required)
LINT_ARGS ?= --verbose --configure LineTooLong:130 -e LineTooLong \
--configure TooManyTestSteps:65 -e TooManyTestSteps \
@@ -25,17 +33,62 @@
--configure FileTooLong:2000 -e FileTooLong \
-e TrailingWhitespace
+## -----------------------------------------------------------------------
+## Intent: Use the robot command to perform syntax checking.
+## % make lint
+## % make lint-robot-all
+## % make lint-robot-modified
+## -----------------------------------------------------------------------
+ifndef NO-LINT-ROBOT
+ lint-robot-mode := $(if $(have-robot-files),modified,all)
+ lint : lint-robot-$(lint-robot-mode)
+endif# NO-LINT-ROBOT
-.PHONY: lint-robot
+## -----------------------------------------------------------------------
+## Intent: exhaustive robot syntax checking
+## -----------------------------------------------------------------------
+lint-robot-all:
+ $(HIDE)$(MAKE) --no-print-directory rflint-install
-lint : lint-robot
+ $(activate)\
+ && find . \( -iname '*.robot' \) -print0 \
+ | $(xargs-n1) rflint $(LINT_ARGS)
-lint-robot: vst_venv
- source ./$</bin/activate \
- ; set -u \
- ; rflint $(LINT_ARGS) $(ROBOT_FILES)
+## -----------------------------------------------------------------------
+## Intent: check deps for format and python3 cleanliness
+## Note:
+## robot --py3k option no longer supported
+## -----------------------------------------------------------------------
+lint-robot-modified: $(venv-activate-script)
+ $(HIDE)$(MAKE) --no-print-directory rflint-install
+ $(activate) && rflint $(LINT_ARGS) $(ROBOT_FILES)
+
+## -----------------------------------------------------------------------
+## Intent: Install the rflint command for syntax checking.
+## Note: requirements.txt pip install not used here ATM due to implicit
+## per-repository dependency config to enable checking.
+## -----------------------------------------------------------------------
+rflint-install: $(venv-activate-script)
+ @echo
+ @echo "** -----------------------------------------------------------------------"
+ @echo "** robot syntax checking"
+ @echo "** -----------------------------------------------------------------------"
+ $(activate)\
+ && pip install --upgrade robotframework-lint
+ $(activate) && rflint --version
+ @echo
+
+## -----------------------------------------------------------------------
+## Intent: Display command usage
+## -----------------------------------------------------------------------
help::
- @echo " lint-robot Syntax check robot sources using rflint"
+ @echo ' lint-robot Syntax check python using the robot command'
+ ifdef VERBOSE
+ @echo ' lint-robot-all robot checking: exhaustive'
+ @echo ' lint-robot-modified robot checking: only modified'
+ endif
+
+$(if $(DEBUG),$(warning LEAVE))
# [EOF]
diff --git a/makefiles/lint/shell.mk b/makefiles/lint/shell.mk
index 9923b72..3c04539 100644
--- a/makefiles/lint/shell.mk
+++ b/makefiles/lint/shell.mk
@@ -1,8 +1,8 @@
# -*- makefile -*-
# -----------------------------------------------------------------------
-# Copyright 2017-2023 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,19 +15,73 @@
# limitations under the License.
# -----------------------------------------------------------------------
-JSON_FILES ?= $(error JSON_FILES= is required)
+$(if $(DEBUG),$(warning ENTER))
-.PHONY: lint-shell
+##-------------------##
+##---] GLOBALS [---##
+##-------------------##
+.PHONY: lint-shell lint-shell-all lint-shell-modified
-lint : lint-shell
+have-shell-sources := $(if $(strip $(SHELL_SOURCES)),true)
+SHELL_SOURCES ?= $(error SHELL_SOURCES= required)
-lint-shell:
+## -----------------------------------------------------------------------
+## Intent: Use the shell command to perform syntax checking.
+## % make lint
+## % make lint-shell-all
+## -----------------------------------------------------------------------
+ifndef NO-LINT-SHELL
+ lint-shell-mode := $(if $(have-shell-sources),modified,all)
+ lint : lint-shell-$(lint-shell-mode)
+endif# NO-LINT-SHELL
+
+## -----------------------------------------------------------------------
+## Intent: exhaustive shell syntax checking
+## -----------------------------------------------------------------------
+shellcheck-find-args := $(null)
+shellcheck-find-args += -name '$(venv-name)'
+shellcheck-find-args += -o -name 'staging'
+lint-shell-all:
+ $(MAKE) --no-print-directory lint-shellcheck-install
+
+ find . \( $(shellcheck-find-args) \) -prune -name '*.sh' -print0 \
+ | $(xargs-n1-clean) shellcheck
+
+## -----------------------------------------------------------------------
+## Intent: check deps for format and python3 cleanliness
+## Note:
+## shell --py3k option no longer supported
+## -----------------------------------------------------------------------
+lint-shell-modified:
+ $(MAKE) --no-print-directory lint-shell-install
+
+ shellcheck $(SHELL_SOURCES)
+
+## -----------------------------------------------------------------------
+## Intent:
+## -----------------------------------------------------------------------
+.PHONY: lint-shellcheck-install
+lint-shellcheck-install:
+ @echo
+ @echo "** -----------------------------------------------------------------------"
+ @echo '** command shell syntax checking'
+ @echo "** -----------------------------------------------------------------------"
+
+ # {apt-get,rpm,yum} install shellcheck
shellcheck --version
- find . \( -name 'staging' -o -name 'vst_venv' \) -prune \
- -o -name '*.sh' ! -name 'activate.sh' -print0 \
- | xargs -0 -n1 shellcheck
+ @echo
+## -----------------------------------------------------------------------
+## Intent: Display command usage
+## -----------------------------------------------------------------------
help::
- @echo " lint-shell Syntax check bash,bourne,etc sources"
+ @echo ' lint-shell Syntax check sources using shellcheck'
+ ifdef VERBOSE
+ @echo ' $(MAKE) lint-shell SHELL_SOURCES=...'
+ @echo ' lint-shell-modified shell checking: only modified'
+ @echo ' lint-shell-all shell checking: exhaustive'
+ endif
+
+$(if $(DEBUG),$(warning LEAVE))
# [EOF]
diff --git a/makefiles/lint/yaml.mk b/makefiles/lint/yaml.mk
index c875686..566ac18 100644
--- a/makefiles/lint/yaml.mk
+++ b/makefiles/lint/yaml.mk
@@ -1,8 +1,8 @@
# -*- makefile -*-
# -----------------------------------------------------------------------
-# Copyright 2017-2023 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,68 @@
# 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
+have-yaml-files := $(if $(strip $(YAML_FILES)),true)
+YAML_FILES ?= $(error YAML_FILES= is required)
-lint-yaml: vst_venv
- source ./$</bin/activate \
- ; set -u \
- ; yamllint -s $(YAML_FILES)
+## -----------------------------------------------------------------------
+## 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
+## -----------------------------------------------------------------------
+ifndef NO-LINT-YAML
+ lint-yaml-mode := $(if $(have-yaml-files),modified,all)
+ lint : lint-yaml-$(lint-yaml-mode)
+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 modified'
+ endif
+
+$(if $(DEBUG),$(warning LEAVE))
# [EOF]
diff --git a/makefiles/patches/include.mk b/makefiles/patches/include.mk
index 2bd1bfd..4accdf2 100644
--- a/makefiles/patches/include.mk
+++ b/makefiles/patches/include.mk
@@ -27,7 +27,9 @@
patch-gather-args += '-e' 'from collections import Mapping'
patch-gather-args += '-e' 'from collections import MutableMapping'
-VENV_NAME ?= $(error $(MAKE) VENV_NAME= is required)
+# Defined by [Mm]akefile or makefiles/virtualenv.mk
+venv-name ?= $(error $(MAKE) venv-name= is required)
+
PATCH_PATH ?= $(error $(MAKE) PATCH_PATH= is required)
## -----------------------------------------------------------------------
@@ -38,7 +40,7 @@
## -----------------------------------------------------------------------
## -----------------------------------------------------------------------
patch-diff:
- $(HIDE)diff -qr staging $(VENV_NAME) \
+ $(HIDE)diff -qr staging $(venv-name) \
| awk '{print "# diff -Naur "$$2" "$$4}' \
| tee $@.log
@@ -46,16 +48,16 @@
## -----------------------------------------------------------------------
patch-create:
mkdir -p patches/$(PATCH_PATH)
- diff -Naur staging/$(PATCH_PATH) $(VENV_NAME)/$(PATCH_PATH) | tee patches/$(PATCH_PATH)/patch
+ diff -Naur staging/$(PATCH_PATH) $(venv-name)/$(PATCH_PATH) | tee patches/$(PATCH_PATH)/patch
exit 1
## -----------------------------------------------------------------------
## -----------------------------------------------------------------------
patch-init:
- find "$(VENV_NAME)" -name '__pycache__' -type d -print0 \
+ find "$(venv-name)" -name '__pycache__' -type d -print0 \
| xargs -I'{}' --null --no-run-if-empty $(RM) -r {}
mkdir -p staging
- rsync -rv --checksum "$(VENV_NAME)/." "staging/."
+ rsync -rv --checksum "$(venv-name)/." "staging/."
@echo "Modify files beneath staging/ to create a patch source"
# [SEE ALSO]
diff --git a/makefiles/todo.mk b/makefiles/todo.mk
new file mode 100644
index 0000000..b122a9e
--- /dev/null
+++ b/makefiles/todo.mk
@@ -0,0 +1,35 @@
+# -*- 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))
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+todo ::
+ @echo '[TODO]'
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+help ::
+ @echo ' todo Display future enhancement list.'
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/makefiles/virtualenv.mk b/makefiles/virtualenv.mk
index d54bfda..bcda734 100644
--- a/makefiles/virtualenv.mk
+++ b/makefiles/virtualenv.mk
@@ -1,6 +1,6 @@
# -*- makefile -*-
## -----------------------------------------------------------------------
-# Copyright 2017-2023 Open Networking Foundation
+# 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.
@@ -15,18 +15,73 @@
# limitations under the License.
## -----------------------------------------------------------------------
-# virtualenv for the robot tools
-# VOL-2724 Invoke pip via python3 to avoid pathname too long on QA jobs
+$(if $(DEBUG),$(warning ENTER))
-vst_venv-2 : vst_venv/bin/activate requirements.txt
+##-------------------##
+##---] GLOBALS [---##
+##-------------------##
+.PHONY: venv
-vst_venv/bin/activate: requirements.txt
- virtualenv -p python3 $@
+##------------------##
+##---] LOCALS [---##
+##------------------##
+venv-name ?= .venv# # default install directory
+venv-abs-path := $(PWD)/$(venv-name)
- @echo
- @[ -r requirements.txt ]\
- && { echo "python -m pip install -r requirements.txt"; }\
- && source ./$@/bin/activate\
- && python -m pip install -r requirements.txt
+venv-activate-script := $(venv-name)/bin/activate# # dependency
+
+# Intent: activate= is a macro for accessing the virtualenv activation script#
+# Usage: $(activate) && python
+activate ?= set +u && source $(venv-activate-script) && set -u
+
+## -----------------------------------------------------------------------
+## Intent: Activate script path dependency
+## Usage:
+## o place on the right side of colon as a target dependency
+## o When the script does not exist install the virtual env and display.
+## -----------------------------------------------------------------------
+$(venv-activate-script):
+ @echo
+ @echo "============================="
+ @echo "Installing python virtual env"
+ @echo "============================="
+ virtualenv -p python3 $(venv-name)
+ $(activate) && python -m pip install --upgrade pip
+ $(activate) && pip install --upgrade setuptools
+ $(activate) && { [[ -r requirements.txt ]] && python -m pip install -r requirements.txt; }
+ $(activate) && python --version
+
+ifndef NO_PYTHON_UPGRADE_PATCHING
+ @echo
+ @echo '** -----------------------------------------------------------------------'
+ @echo '** Applying python virtualenv patches as needed (v3.10+)'
+ @echo '** -----------------------------------------------------------------------'
+ ./patches/python_310_migration.sh '--venv' '$(venv-name)' 'apply'
+endif
+
+## -----------------------------------------------------------------------
+## Intent: Explicit named installer target w/o dependencies.
+## Makefile targets should depend on venv-activate-script.
+## -----------------------------------------------------------------------
+venv: $(venv-activate-script)
+
+## -----------------------------------------------------------------------
+## Intent: Revert installation to a clean checkout
+## -----------------------------------------------------------------------
+sterile :: clean
+ $(RM) -r "$(venv-abs-path)"
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+help ::
+ @echo
+ @echo '[VIRTUAL ENV]'
+ @echo ' venv Create a python virtual environment'
+ @echo ' venv-name= Subdir name for virtualenv install'
+ @echo ' venv-activate-script make macro name'
+ @echo ' $$(target) dependency install python virtualenv'
+ @echo ' source $$(macro) && cmd configure env and run cmd'
+
+$(if $(DEBUG),$(warning LEAVE))
# [EOF]