[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/Makefile b/Makefile
index 0817e3b..2939732 100644
--- a/Makefile
+++ b/Makefile
@@ -20,14 +20,21 @@
.DEFAULT_GOAL := help
MAKECMDGOALS ?= help
-TOP ?= .
-MAKEDIR ?= $(TOP)/makefiles
+##-------------------##
+##---] GLOBALS [---##
+##-------------------##
+TOP ?=$(strip \
+ $(dir \
+ $(abspath $(lastword $(MAKEFILE_LIST)))\
+ )\
+)
##--------------------##
##---] INCLUDES [---##
##--------------------##
-include $(MAKEDIR)/include.mk
-include $(MAKEDIR)/release/include.mk
+include $(TOP)/config.mk
+include $(TOP)/makefiles/include.mk
+include $(ONF_MAKEDIR)/release/include.mk
##--------------------##
##---] INCLUDES [---##
@@ -88,32 +95,41 @@
## -----------------------------------------------------------------------
## -----------------------------------------------------------------------
lint-mod:
+ $(call banner-enter,Target $@)
@echo "Running dependency check..."
@${GO} mod verify
@echo "Dependency check OK. Running vendor check..."
@git status > /dev/null
@git diff-index --quiet HEAD -- go.mod go.sum vendor || (echo "ERROR: Staged or modified files must be committed before running this test" && git status -- go.mod go.sum vendor && exit 1)
@[[ `git ls-files --exclude-standard --others go.mod go.sum vendor` == "" ]] || (echo "ERROR: Untracked files must be cleaned up before running this test" && git status -- go.mod go.sum vendor && exit 1)
- ${GO} mod tidy
- ${GO} mod vendor
+
+ $(HIDE)$(MAKE) --no-print-directory mod-update
+
@git status > /dev/null
@git diff-index --quiet HEAD -- go.mod go.sum vendor || (echo "ERROR: Modified 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)
@[[ `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."
+ $(call banner-enter,Target $@)
## -----------------------------------------------------------------------
## -----------------------------------------------------------------------
lint: lint-mod lint-dockerfile
## -----------------------------------------------------------------------
+## Intent: Generate a static code analysis report
## -----------------------------------------------------------------------
+sca-report-dir := ./sca-report
+sca-report-xml := $(sca-report-dir)/sca-report.xml
sca:
- @$(RM) -r ./sca-report
- @mkdir -p ./sca-report
+ $(call begin-enter,Target $@)
+ @$(RM) -r $(sca-report-dir)
+ @mkdir -p $(sca-report-dir)
@echo "Running static code analysis..."
- @${GOLANGCI_LINT} run -vv --deadline=6m --out-format junit-xml ./... | tee ./sca-report/sca-report.xml
+ @${GOLANGCI_LINT} run -vv --deadline=6m --out-format junit-xml ./... \
+ | tee ./sca-report/sca-report.xml
@echo ""
@echo "Static code analysis OK"
+ $(call begin-leave,Target $@)
## -----------------------------------------------------------------------
## -----------------------------------------------------------------------
@@ -129,60 +145,49 @@
test-unit: clean local-omci-lib-go # @HELP Execute unit tests
- @echo
- @echo '** -----------------------------------------------------------------------'
- @echo '** Target: $@'
- @echo '** -----------------------------------------------------------------------'
+ $(call banner-enter,Target $@)
@mkdir -p $(dir $(results-out))
-# @chmod -R 777 $(dir $(results-out))# dev-mode: local
- @find $(dir $(results-out)) -print0 | xargs -0 ls -l
- @echo
- @echo "Running unit tests..."
- @echo '-----------------------------------------------------------------------'
+ $(call banner,Running unit tests...)
+
+ $(if $(LOCAL_FIX_PERMS),\
+ chmod o+w $(dir $(results-out) $(results-out)))
set -euo pipefail \
&& ${GO} test -mod=vendor -bench=. -v \
-coverprofile $(coverage-out) \
-covermode count ./... \
2>&1 | tee "$(results-out)"
+ $(if $(LOCAL_FIX_PERMS),\
+ chmod o-w $(dir $(results-out) $(results-out)))
- @echo
- @echo "Coverage report: junit"
- @echo '-----------------------------------------------------------------------'
+ $(call banner,Coverage report: junit)
+ $(if $(LOCAL_FIX_PERMS),\
+ chmod o+w $(dir $(results-xml) $(results-xml)))
${GO_JUNIT_REPORT} < $(results-out) > $(results-xml)
+ $(if $(LOCAL_FIX_PERMS),\
+ chmod o-w $(dir $(results-xml) $(results-xml)))
- @echo
- @echo "Coverage report: Cobertura"
- @echo '-----------------------------------------------------------------------'
+ $(call banner,Coverage report: Cobertura)
+ $(if $(LOCAL_FIX_PERMS),\
+ chmod o+w $(dir $(results-xml) $(coverage-xml)))
${GOCOVER_COBERTURA} < $(coverage-out) > $(coverage-xml)
+ $(if $(LOCAL_FIX_PERMS),\
+ chmod o-w $(dir $(results-xml) $(coverage-xml)))
+
+ $(call banner,Coverage report directory perms:)
@echo
- @echo "Coverage report directory perms:"
- @echo '-----------------------------------------------------------------------'
- find $(dir $(results-out)) -print0 | xargs -0 ls -l
+ @/bin/ls -ld tests tests/results
@echo
- @echo "Locally modified files (git status)"
- @echo '-----------------------------------------------------------------------'
+ @find $(dir $(results-out)) -print0 | xargs -0 ls -l
+ # chown -R $$(id -u):$$(id -g) $(dir $(results-xml)
+
+ $(call banner,Locally modified files: git status)
git status
-# foobar:
-# && RETURN=$$? \
- && echo "** $@ will exit with status $$(declare -p RETURN)" \
- && echo \
- && echo "Coverage report: juni" \
- && ${GO_JUNIT_REPORT} < $(results-out) > $(results-xml) \
- && echo \
- && echo "Coverage report: Cobertura" \
- && ${GOCOVER_COBERTURA} < $(coverage-out) > $(coverage-xml) \
- && echo \
- && echo "Coverage report directory perms:" \
- && find $(dir $(results-out)) -print0 | xargs -0 ls -l \
- && echo \
- && echo "List locally modified files" \
- && git status \
- exit $$RETURN
+ $(call banner-leave,Target $@)
## -----------------------------------------------------------------------
## -----------------------------------------------------------------------
@@ -193,18 +198,6 @@
docker $(RM) -f bbsim
## -----------------------------------------------------------------------
-## Intgent: Update sources in the vendor/ directory.
-## Todo:
-## o chicken-n-egg problem:
-## - vendor/ is under revision control
-## - go mod tidy will delete vendor
-## - sandbox left unbuildable when mod-update target fails.
-## -----------------------------------------------------------------------
-mod-update: # @HELP Download the dependencies to the vendor folder
- ${GO} mod tidy
- ${GO} mod vendor
-
-## -----------------------------------------------------------------------
## -----------------------------------------------------------------------
docker-build: local-omci-lib-go local-protos# @HELP Build the BBSim docker container (contains BBSimCtl too)
docker build \
@@ -255,13 +248,17 @@
## -----------------------------------------------------------------------
.PHONY: docs docs-lint
docs: swagger # @HELP Generate docs and opens them in the browser
- $(MAKE) -C docs html
+
+ $(call begin-enter,Target $@)
+ -$(MAKE) -C docs html
+ $(call begin-leave,Target $@)
+
@echo -e "\nBBSim documentation generated in file://${PWD}/docs/build/html/index.html"
## -----------------------------------------------------------------------
## -----------------------------------------------------------------------
docs-lint:
- $(MAKE) -C docs lint
+ $(MAKE) -C docs lint-doc8
## -----------------------------------------------------------------------
## -----------------------------------------------------------------------
@@ -304,6 +301,8 @@
@$(RM) $(results-out)
@$(RM) $(results-xml)
+ @$(RM) $(sca-report-xml)
+
sterile :: clean
## -----------------------------------------------------------------------
@@ -379,6 +378,12 @@
$<
## -----------------------------------------------------------------------
+## Intent:
+## -----------------------------------------------------------------------
+clean ::
+ $(RM) -r "docs/$(venv-name)"
+
+## -----------------------------------------------------------------------
## Intent: Helper target used to exercise release script changes
## -----------------------------------------------------------------------
include $(MAKEDIR)/release/onf-publish.mk