diff --git a/Jenkinsfile b/Jenkinsfile index 5349eef7..8356d997 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -86,6 +86,7 @@ pipeline { STORJ_TEST_COCKROACH = 'cockroach://root@localhost:26257/postgres?sslmode=disable' STORJ_TEST_POSTGRES = 'postgres://postgres@localhost/postgres?sslmode=disable' STORJ_TEST_LOG_LEVEL = 'info' + COVERFLAGS = "${ env.BRANCH_NAME == 'main' ? '-coverprofile=.build/coverprofile ' : ''}" } steps { sh 'make test 2>&1 | grep "^{.*" | tee .build/tests.json | xunit -out .build/tests.xml' @@ -95,6 +96,19 @@ pipeline { sh script: 'cat .build/tests.json| tparse -all -top -slow 100', returnStatus: true archiveArtifacts artifacts: '.build/tests.json' junit '.build/tests.xml' + + script { + if(fileExists(".build/coverprofile")){ + sh script: 'filter-cover-profile < .build/coverprofile > .build/clean.coverprofile', returnStatus: true + sh script: 'gocov convert .build/clean.coverprofile > .build/cover.json', returnStatus: true + sh script: 'gocov-xml < .build/cover.json > .build/cobertura.xml', returnStatus: true + cobertura coberturaReportFile: '.build/cobertura.xml', + lineCoverageTargets: '70, 60, 50', + autoUpdateHealth: false, + autoUpdateStability: false, + failUnhealthy: false + } + } } } } @@ -120,6 +134,19 @@ pipeline { sh script: 'cat .build/testsuite.json| tparse -all -top -slow 100', returnStatus: true archiveArtifacts artifacts: '.build/testsuite.json' junit '.build/testsuite.xml' + + script { + if(fileExists(".build/coverprofile")){ + sh script: 'filter-cover-profile < .build/coverprofile > .build/clean.coverprofile', returnStatus: true + sh script: 'gocov convert .build/clean.coverprofile > .build/cover.json', returnStatus: true + sh script: 'gocov-xml < .build/cover.json > .build/cobertura.xml', returnStatus: true + cobertura coberturaReportFile: '.build/cobertura.xml', + lineCoverageTargets: '70, 60, 50', + autoUpdateHealth: false, + autoUpdateStability: false, + failUnhealthy: false + } + } } } } diff --git a/Makefile b/Makefile index 6028e3ec..e0f0e68d 100644 --- a/Makefile +++ b/Makefile @@ -162,7 +162,7 @@ SKIP_TESTSUITE ?= false .PHONY: test test: test-testsuite ## Test - go test -json=${JSON} -p 16 -parallel 4 -race -short=${SHORT} -timeout 10m -vet=off ./... + go test -json=${JSON} -cover -coverprofile=.build/coverprofile -p 16 -parallel 4 -race -short=${SHORT} -timeout 10m -vet=off ./... .PHONY: test-testsuite test-testsuite: ## Test testsuite @@ -174,7 +174,7 @@ endif .PHONY: test-testsuite-do test-testsuite-do: go vet ./... - go test -json=${JSON} -p 16 -parallel 4 -race -short=${SHORT} -timeout 10m -vet=off ./... + go test -json=${JSON} -cover -coverprofile=.build/coverprofile -p 16 -parallel 4 -race -short=${SHORT} -timeout 10m -vet=off ./... ##@ Local development/Public Jenkins/Verification