VOL-4836 - Cosmetic edits to trigger a jenkins job.
Makefile
makefiles/
o Pass grep --no-filename to fix problem with Makefile printed by help.
o Checkin makefile libraries for common constants and targets.
docker/
internal/pkg/
pkg/mocks/s
cmd/openolt-adapter/
--------------------
o Update copyright notice to force a trivial source change.
o Delta will initiate a jenkins job.
Change-Id: Ie6d522d52dc6353219d80e1cb04aa5cdcad8b6a6
diff --git a/Makefile b/Makefile
index a546dd5..453976e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,6 @@
-#
-# Copyright 2016 the original author or authors.
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2016-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.
@@ -12,10 +13,24 @@
# 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.
-#
+# -----------------------------------------------------------------------
-# set default shell
-SHELL = bash -e -o pipefail
+$(if $(DEBUG),$(warning ENTER))
+
+.DEFAULT_GOAL := help
+
+TOP ?= .
+MAKEDIR ?= $(TOP)/makefiles
+
+$(if $(VERBOSE),$(eval export VERBOSE=$(VERBOSE))) # visible to include(s)
+
+##--------------------##
+##---] INCLUDES [---##
+##--------------------##
+include $(MAKEDIR)/include.mk
+ifdef LOCAL_LINT
+ include $(MAKEDIR)/lint/golang/sca.mk
+endif
# Variables
VERSION ?= $(shell cat ./VERSION)
@@ -58,7 +73,6 @@
HADOLINT = docker run --rm --user $$(id -u):$$(id -g) -v ${CURDIR}:/app $(shell test -t 0 && echo "-it") voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}-hadolint hadolint
.PHONY: docker-build local-protos local-lib-go help
-.DEFAULT_GOAL := help
## Local Development Helpers
local-protos: ## Copies a local version of the voltha-protos dependency into the vendor directory
@@ -75,9 +89,13 @@
cp -r ${LOCAL_LIB_GO}/pkg/* vendor/github.com/opencord/voltha-lib-go/v7/pkg/
endif
+## -----------------------------------------------------------------------
## Docker targets
+## -----------------------------------------------------------------------
build: docker-build ## Alias for 'docker build'
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
docker-build: local-protos local-lib-go ## Build openolt adapter docker image (set BUILD_PROFILED=true to also build the profiled image)
docker build $(DOCKER_BUILD_ARGS) --target=${DOCKER_TARGET} --build-arg CGO_PARAMETER=0 -t ${ADAPTER_IMAGENAME} -f docker/Dockerfile.openolt .
ifdef BUILD_PROFILED
@@ -87,6 +105,8 @@
docker build $(DOCKER_BUILD_ARGS) --target=dev --build-arg CGO_PARAMETER=1 --build-arg EXTRA_GO_BUILD_TAGS="-race" -t ${ADAPTER_IMAGENAME}-rd -f docker/Dockerfile.openolt .
endif
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
docker-push: ## Push the docker images to an external repository
docker push ${ADAPTER_IMAGENAME}
ifdef BUILD_PROFILED
@@ -96,16 +116,22 @@
docker push ${ADAPTER_IMAGENAME}-rd
endif
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
docker-kind-load: ## Load docker images into a KinD cluster
@if [ "`kind get clusters | grep voltha-$(TYPE)`" = '' ]; then echo "no voltha-$(TYPE) cluster found" && exit 1; fi
kind load docker-image ${ADAPTER_IMAGENAME} --name=voltha-$(TYPE) --nodes $(shell kubectl get nodes --template='{{range .items}}{{.metadata.name}},{{end}}' | sed 's/,$$//')
+## -----------------------------------------------------------------------
## lint and unit tests
+## -----------------------------------------------------------------------
lint-dockerfile: ## Perform static analysis on Dockerfile
@echo "Running Dockerfile lint check ..."
@${HADOLINT} $$(find . -name "Dockerfile.*")
@echo "Dockerfile lint check OK"
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
lint-mod: ## Verify the Go dependencies
@echo "Running dependency check..."
@${GO} mod verify
@@ -120,8 +146,12 @@
@[[ `git ls-files --exclude-standard --others go.mod go.sum vendor` == "" ]] || (echo "ERROR: Untracked files detected after running go mod tidy / go mod vendor" && git status -- go.mod go.sum vendor && git checkout -- go.mod go.sum vendor && exit 1)
@echo "Vendor check OK."
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
lint: local-lib-go lint-mod lint-dockerfile ## Run all lint targets
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
test: ## Run unit tests
@mkdir -p ./tests/results
@${GO} test -mod=vendor -v -coverprofile ./tests/results/go-test-coverage.out -covermode count ./... 2>&1 | tee ./tests/results/go-test-results.out ;\
@@ -130,6 +160,8 @@
${GOCOVER_COBERTURA} < ./tests/results/go-test-coverage.out > ./tests/results/go-test-coverage.xml ;\
exit $$RETURN
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
sca: ## Runs static code analysis with the golangci-lint tool
@rm -rf ./sca-report
@mkdir -p ./sca-report
@@ -138,19 +170,29 @@
@echo ""
@echo "Static code analysis OK"
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
clean: distclean ## Removes any local filesystem artifacts generated by a build
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
distclean: ## Removes any local filesystem artifacts generated by a build or test run
rm -rf ./sca-report
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
mod-update: ## Update go mod files
${GO} mod tidy
${GO} mod vendor
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
# For each makefile target, add ## <description> on the target line and it will be listed by 'make help'
-help: ## Print help for each Makefile target
- @echo "Usage: make [<target>]"
- @echo "where available targets are:"
+help :: ## Print help for each Makefile target
@echo
- @grep '^[[:alpha:]_-]*:.* ##' $(MAKEFILE_LIST) \
- | sort | awk 'BEGIN {FS=":.* ## "}; {printf "%-25s : %s\n", $$1, $$2};'
+ @echo "where available targets are:"
+ @grep --no-filename '^[[:alpha:]_-]*:.* ##' $(MAKEFILE_LIST) \
+ | sort \
+ | awk 'BEGIN {FS=":.* ## "}; {printf "%-25s : %s\n", $$1, $$2};'
+
+# [EOF]