From afd6521125e7cae0240a1ec8897f914eb2157b5b Mon Sep 17 00:00:00 2001 From: Gus Parvin Date: Fri, 6 Mar 2020 15:13:07 -0500 Subject: [PATCH 1/2] go commands working locally but not in travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6827b431..ca32f5af 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: go go: - - 1.13.x + - 1.14.x os: - linux From a2791fed126ff134a477d9799d8d4426e3725ba7 Mon Sep 17 00:00:00 2001 From: Gus Parvin Date: Fri, 6 Mar 2020 16:41:16 -0500 Subject: [PATCH 2/2] use custom logic for sonar scanning --- .travis.yml | 1 - Makefile | 10 +++++++++- build/run-unit-tests.sh | 3 +++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ca32f5af..c86a7bcd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -58,7 +58,6 @@ jobs: - | make make component/test/unit - make sonar/go || echo "Sonar/Go processing failed: rc=$?" - stage: test-e2e name: "Run e2e tests" if: type = pull_request diff --git a/Makefile b/Makefile index e37fe151..95265162 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ default:: @echo "Build Harness Bootstrapped" .PHONY: all test dependencies build-prod image rhel-image manager run deploy install \ -fmt vet generate +fmt vet generate go-coverage all: test manager @@ -60,3 +60,11 @@ vet: generate: go generate ./pkg/... ./cmd/... +go-coverage: + $(shell go test -coverprofile=coverage.out -json ./...\ + $$(go list ./... | \ + grep -v '/vendor/' | \ + grep -v '/docs/' \ + ) > report.json) + gosec --quiet -fmt sonarqube -out gosec.json -no-fail ./... + sonar-scanner --debug || echo "Sonar scanner is not available" diff --git a/build/run-unit-tests.sh b/build/run-unit-tests.sh index c9cfdcb4..ee0bb9ae 100755 --- a/build/run-unit-tests.sh +++ b/build/run-unit-tests.sh @@ -3,3 +3,6 @@ set -e export DOCKER_IMAGE_AND_TAG=${1} # make docker/run + +make go/gosec-install +make go-coverage