Updated tools version to 2.0.0
Also merged lint-style (gofmt) into golangci-lint (enabled gofmt).
Also removed redundant lint-sanity (govet) which is already checked by golangci-lint.
Also changed lint-mod slightly so it reverts any changes it makes go.mod, go.sum, and vendor/.
VOL-2647
Change-Id: I0da8f5db28116efaa4958dc8778ffa0e851d6640
diff --git a/Makefile b/Makefile
index 74b6e43..cd92d01 100644
--- a/Makefile
+++ b/Makefile
@@ -21,12 +21,11 @@
VERSION ?= $(shell cat ./VERSION)
# tool containers
-VOLTHA_TOOLS_VERSION ?= 1.0.3
+VOLTHA_TOOLS_VERSION ?= 2.0.0
GO = docker run --rm --user $$(id -u):$$(id -g) -v ${CURDIR}:/app $(shell test -t 0 && echo "-it") -v gocache:/.cache -v gocache-${VOLTHA_TOOLS_VERSION}:/go/pkg voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}-golang go
GO_JUNIT_REPORT = docker run --rm --user $$(id -u):$$(id -g) -v ${CURDIR}:/app -i voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}-go-junit-report go-junit-report
GOCOVER_COBERTURA = docker run --rm --user $$(id -u):$$(id -g) -v ${CURDIR}:/app -i voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}-gocover-cobertura gocover-cobertura
-GOFMT = docker run --rm --user $$(id -u):$$(id -g) -v ${CURDIR}:/app $(shell test -t 0 && echo "-it") voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}-golang gofmt
GOLANGCI_LINT = docker run --rm --user $$(id -u):$$(id -g) -v ${CURDIR}:/app $(shell test -t 0 && echo "-it") -v gocache:/.cache -v gocache-${VOLTHA_TOOLS_VERSION}:/go/pkg voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}-golangci-lint golangci-lint
.PHONY: local-protos
@@ -39,8 +38,6 @@
@echo "build : Build the library"
@echo "clean : Remove files created by the build"
@echo "distclean : Remove build and testing artifacts and reports"
- @echo "lint-style : Verify code is properly gofmt-ed"
- @echo "lint-sanity : Verify that 'go vet' doesn't report any issues"
@echo "lint-mod : Verify the integrity of the 'mod' files"
@echo "lint : Shorthand for lint-style & lint-sanity"
@echo "mod-update : Update go.mod and the vendor directory"
@@ -65,41 +62,29 @@
## lint and unit tests
-lint-style:
- @echo "Running style check..."
- @gofmt_out="$$(${GOFMT} -l $$(find . -name '*.go' -not -path './vendor/*'))" ;\
- if [ ! -z "$$gofmt_out" ]; then \
- echo "$$gofmt_out" ;\
- echo "Style check failed on one or more files ^, run 'go fmt' to fix." ;\
- exit 1 ;\
- fi
- @echo "Style check OK"
-
-lint-sanity:
- @echo "Running sanity check..."
- @${GO} vet -mod=vendor ./...
- @echo "Sanity check OK"
-
lint-mod:
@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" && echo "`git status`" && 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" && echo "`git status`" && exit 1)
+ @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
@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" && echo "`git status`" && 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" && echo "`git status`" && exit 1)
+ @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."
-lint: lint-style lint-sanity lint-mod
+lint: lint-mod
sca:
- rm -rf ./sca-report
+ @rm -rf ./sca-report
@mkdir -p ./sca-report
- ${GOLANGCI_LINT} run --out-format junit-xml ./... | tee ./sca-report/sca-report.xml
+ @echo "Running static code analysis..."
+ @${GOLANGCI_LINT} run --deadline=4m --out-format junit-xml ./... | tee ./sca-report/sca-report.xml
+ @echo ""
+ @echo "Static code analysis OK"
test:
@mkdir -p ./tests/results