VOL-4874 - Fix local lint target use problems.
scripts/which_deployment_owns_device.sh
---------------------------------------
* Fix a few shellcheck complaints.
makefiles/lint/robot.mk
-----------------------
* Update target logic to use && -vs- ;
* semicolon use can mask errors.
makefiles/lint/python.mk
------------------------
* Update target logic to use && -vs- ;
* Removed pylint option --py3k, switch not suppored by newer interpreters.
makefiles/lint.mk
makefiles/lint/shell.mk
-----------------------
* Added a lint target to invoke shellcheck on sources.
Makefile
--------
* target:clean modified to remove generated sources.
* target:gendocs: unique $(LIBDIRS) and replace for loop with a simple mkdir -vp call.
* cosmetic indentation cleanup.
* modified vst_venv target to apply patches after virtualenv created.
* patches address failures caused by python 3.10+ requiring collections.abc
* Ignore exit status from 310_migration for now to avoid failing other jobs.
patches/lib/python3.10/site-packages/robot/utils/normalizing.py/patch
patches/lib/python3.10/site-packages/robot/utils/robottypes3.py/patch
---------------------------------------------------------------------
* Attempt to import the new collections.abc module for Mapping and
friends so python 3.10+ can be supported.
* Fall back to existing module import supported by python interpreters
v3.5 <=> v3.9.
patches/python_310_migration.sh
-------------------------------
* Self contained helper script used to generate and apply python 3.10+ patches.
Followup edits
--------------
* Added missing license blocks reported by jenkins.
* Updated lint checking to detect license errors so problems can be fixed prior to checkin.
* Add set -x debugging, not clear why pyenv patching failed.
Change-Id: I2b8515bb26874eb8b1564bec87353ea0c1485b61
diff --git a/Makefile b/Makefile
index 2b6c729..8fd95b1 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,6 @@
-# Copyright 2017-2022 Open Networking Foundation
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 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.
@@ -11,16 +13,23 @@
# 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.
+# -----------------------------------------------------------------------
+
+.DEFAULT_GOAL := sanity-kind
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
-
+# Assign early: altered by include
ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
+##--------------------##
+##---] INCLUDES [---##
+##--------------------##
+include $(MAKEDIR)/consts.mk
+include $(MAKEDIR)/help.mk
+include $(MAKEDIR)/patches/include.mk
+
# Configuration and lists of files for linting/testing
VERSION ?= $(shell cat ./VERSION)
@@ -702,12 +711,24 @@
# self-test, lint, and setup targets
+# -----------------------------------------------------------------------
# virtualenv for the robot tools
# VOL-2724 Invoke pip via python3 to avoid pathname too long on QA jobs
+# Verify installation: make lint -or- make test
+# vol-4874 - python_310_migration.sh
+# -----------------------------------------------------------------------
vst_venv:
+ @echo "============================="
+ @echo "Installing python virtual env"
+ @echo "============================="
virtualenv -p python3 $@ ;\
source ./$@/bin/activate ;\
python -m pip install -r requirements.txt
+ @echo
+ @echo "========================================"
+ @echo "Applying python 3.10.x migration patches"
+ @echo "========================================"
+ ./patches/python_310_migration.sh 'apply'
##----------------##
##---] LINT [---##
@@ -716,8 +737,6 @@
test: lint
-lint: lint-robot lint-python lint-yaml lint-json
-
# 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
@@ -735,30 +754,35 @@
TEST_BASENAME := $(basename $(TEST_SOURCE))
TEST_DIRS := $(dir $(TEST_SOURCE))
-LIB_SOURCE := $(wildcard libraries/*.robot)
+LIB_SOURCE := $(wildcard libraries/*.robot)
LIB_BASENAME := $(basename $(LIB_SOURCE))
-LIB_DIRS := $(dir $(LIB_SOURCE))
+LIB_DIRS := $(sort $(dir $(LIB_SOURCE)))
.PHONY: gendocs lint test
# In future explore use of --docformat REST - integration w/Sphinx?
gendocs: vst_venv
source ./$</bin/activate ; set -u ;\
mkdir -p $@ ;\
- for dir in ${LIB_DIRS}; do mkdir -p $@/$$dir; done;\
+ mkdir -pv $(LIB_DIRS); \
for dir in ${LIB_BASENAME}; do\
- python -m robot.libdoc --format HTML $$dir.robot $@/$$dir.html ;\
+ python -m robot.libdoc --format HTML $$dir.robot $@/$$dir.html ;\
done ;\
for dir in ${TEST_DIRS}; do mkdir -p $@/$$dir; done;\
for dir in ${TEST_BASENAME}; do\
python -m robot.testdoc $$dir.robot $@/$$dir.html ;\
done
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
clean:
- find . -name output.xml -print
+ $(RM) -r gendocs
+ find . -name output.xml -print # no action performed ?
-clean-all: clean
- rm -rf vst_venv gendocs
+clean-all sterile: clean
+ $(RM) -r vst_venv
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
voltctl-docker-image-build:
cd docker && docker build -t opencord/voltctl:local -f Dockerfile.voltctl .