Updated tools version to 2.0.0
Also removed redundant lint-sanity (govet), and lint-style (gofmt), which are 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: Iaf53c43b0926d412f3f980dfb2d5944ff61ffb9c
diff --git a/Makefile b/Makefile
index 3ce966b..f70af13 100644
--- a/Makefile
+++ b/Makefile
@@ -48,12 +48,11 @@
--build-arg org_opencord_vcs_dirty="${DOCKER_LABEL_VCS_DIRTY}"
# 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
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
@@ -73,8 +72,6 @@
@echo "lint : Run all lint targets"
@echo "lint-dockerfile : Perform static analysis on Dockerfiles"
@echo "lint-mod : Verify the Go dependencies"
- @echo "lint-sanity : Run the Go language sanity tests (vet)"
- @echo "lint-style : Verify the Go standard format of the source"
@echo "local-protos : Copies a local verison of the VOLTHA protos into the vendor directory"
@echo "local-lib-go : Copies a local version of the VOTLHA dependencies into the vendor directory"
@echo "sca : Runs various SCA through golangci-lint tool"
@@ -120,36 +117,21 @@
@${HADOLINT} $$(find . -name "Dockerfile.*")
@echo "Dockerfile lint check OK"
-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: local-lib-go lint-style lint-sanity lint-mod lint-dockerfile
+lint: local-lib-go lint-mod lint-dockerfile
test:
@mkdir -p ./tests/results
@@ -160,9 +142,11 @@
exit $$RETURN
sca:
+ @rm -rf ./sca-report
@mkdir -p ./sca-report
@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"
clean: distclean