Makefile
makefiles/lint.mk
makefiles/lint/json.mk
makefiles/lint/python.mk
makefiles/lint/robot.mk
makefiles/lint/yaml.mk
makefiles/virtualenv.mk
----
* Begin simplifying 700+ line monolithic makefile.
* Extract and repackage lint based targets beneath makefiles/lint.
* Added help target(s) to document functionality.
Changed copyight end date from -present to -2022.
Change-Id: Ieaacf59ee3023d29c4e8be7b266f4c7169111138
diff --git a/Makefile b/Makefile
index e2f7277..2b6c729 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-# Copyright 2017-present Open Networking Foundation
+# 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.
@@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+TOP ?= .
+MAKEDIR ?= $(TOP)/makefiles
+
# use bash for pushd/popd, and to fail quickly. virtualenv's activate
# has undefined variables, so no -u
SHELL := bash -e -o pipefail
@@ -20,13 +23,6 @@
# Configuration and lists of files for linting/testing
VERSION ?= $(shell cat ./VERSION)
-LINT_ARGS ?= --verbose --configure LineTooLong:130 -e LineTooLong \
- --configure TooManyTestSteps:65 -e TooManyTestSteps \
- --configure TooManyTestCases:50 -e TooManyTestCases \
- --configure TooFewTestSteps:1 \
- --configure TooFewKeywordSteps:1 \
- --configure FileTooLong:2000 -e FileTooLong \
- -e TrailingWhitespace
PYTHON_FILES := $(wildcard libraries/*.py)
ROBOT_FILES := $(shell find . -name *.robot -print)
@@ -713,31 +709,15 @@
source ./$@/bin/activate ;\
python -m pip install -r requirements.txt
+##----------------##
+##---] LINT [---##
+##----------------##
+include $(MAKEDIR)/lint.mk
+
test: lint
lint: lint-robot lint-python lint-yaml lint-json
-lint-robot: vst_venv
- source ./$</bin/activate ; set -u ;\
- rflint $(LINT_ARGS) $(ROBOT_FILES)
-
-# 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)
-
-lint-yaml: vst_venv
- source ./$</bin/activate ; set -u ;\
- yamllint -s $(YAML_FILES)
-
-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
-
# tidy target will be more useful once issue with removing leading comments
# is resolved: https://github.com/robotframework/robotframework/issues/3263
tidy-robot: vst_venv
@@ -785,3 +765,5 @@
voltctl-docker-image-install-kind:
@if [ "`kind get clusters | grep kind`" = '' ]; then echo "no kind cluster found" && exit 1; fi
kind load docker-image --name `kind get clusters | grep kind` opencord/voltctl:local
+
+# [EOF]
diff --git a/makefiles/lint.mk b/makefiles/lint.mk
new file mode 100644
index 0000000..cb4b0a7
--- /dev/null
+++ b/makefiles/lint.mk
@@ -0,0 +1,27 @@
+# -*- 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.
+# -----------------------------------------------------------------------
+
+help::
+ @echo
+ @echo "[LINT]"
+
+include $(MAKEDIR)/lint/json.mk
+include $(MAKEDIR)/lint/python.mk
+include $(MAKEDIR)/lint/robot.mk
+include $(MAKEDIR)/lint/yaml.mk
+
+# [EOF]
diff --git a/makefiles/lint/json.mk b/makefiles/lint/json.mk
new file mode 100644
index 0000000..0a11c71
--- /dev/null
+++ b/makefiles/lint/json.mk
@@ -0,0 +1,35 @@
+# -*- 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.
+# -----------------------------------------------------------------------
+
+JSON_FILES ?= $(error JSON_FILES= is rqeuired)
+
+.PHONY: lint-json
+
+lint : lint-json
+
+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
+
+help::
+ @echo " lint-json Syntax check json sources"
+
+# [EOF]
diff --git a/makefiles/lint/python.mk b/makefiles/lint/python.mk
new file mode 100644
index 0000000..5aecd58
--- /dev/null
+++ b/makefiles/lint/python.mk
@@ -0,0 +1,34 @@
+# -*- 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.
+# -----------------------------------------------------------------------
+
+PYTHON_FILES ?= $(error PYTHON_FILES= is required)
+
+.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"
+
+# [EOF]
diff --git a/makefiles/lint/robot.mk b/makefiles/lint/robot.mk
new file mode 100644
index 0000000..ec5579e
--- /dev/null
+++ b/makefiles/lint/robot.mk
@@ -0,0 +1,41 @@
+# -*- 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.
+# -----------------------------------------------------------------------
+
+ROBOT_FILES ?= $(error ROBOT_FILES= is required)
+
+LINT_ARGS ?= --verbose --configure LineTooLong:130 -e LineTooLong \
+ --configure TooManyTestSteps:65 -e TooManyTestSteps \
+ --configure TooManyTestCases:50 -e TooManyTestCases \
+ --configure TooFewTestSteps:1 \
+ --configure TooFewKeywordSteps:1 \
+ --configure FileTooLong:2000 -e FileTooLong \
+ -e TrailingWhitespace
+
+
+.PHONY: lint-robot
+
+lint : lint-robot
+
+lint-robot: vst_venv
+ source ./$</bin/activate \
+ ; set -u \
+ ; rflint $(LINT_ARGS) $(ROBOT_FILES)
+
+help::
+ @echo " lint-robot Syntax check robot sources using rflint"
+
+# [EOF]
diff --git a/makefiles/lint/yaml.mk b/makefiles/lint/yaml.mk
new file mode 100644
index 0000000..c9cb392
--- /dev/null
+++ b/makefiles/lint/yaml.mk
@@ -0,0 +1,32 @@
+# -*- 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.
+# -----------------------------------------------------------------------
+
+YAML_FILES ?= $(error YAML_FILES= is required)
+
+.PHONY: lint-yaml
+
+lint : lint-yaml
+
+lint-yaml: vst_venv
+ source ./$</bin/activate \
+ ; set -u \
+ ; yamllint -s $(YAML_FILES)
+
+help::
+ @echo " lint-yaml Syntax check yaml source using yamllint"
+
+# [EOF]
diff --git a/makefiles/virtualenv.mk b/makefiles/virtualenv.mk
new file mode 100644
index 0000000..faa7c60
--- /dev/null
+++ b/makefiles/virtualenv.mk
@@ -0,0 +1,32 @@
+# -*- 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.
+## -----------------------------------------------------------------------
+
+# virtualenv for the robot tools
+# VOL-2724 Invoke pip via python3 to avoid pathname too long on QA jobs
+
+vst_venv-2 : vst_venv/bin/activate requirements.txt
+
+vst_venv/bin/activate:
+ virtualenv -p python3 $@ ;\
+ source ./$@/bin/activate ;\
+ python -m pip install -r requirements.txt
+
+zzz: xyz
+xyz: vst_venv/bin/activate
+ source vst_venv/bin/activate
+
+# [EOF]