Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jenkinsfile,Makefile: add coverage flag #336

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 | tee .build/tests.json | xunit -out .build/tests.xml'
Expand All @@ -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
}
}
ihaid marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 ./...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beware, this will overwrite the coverage of the main module

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this error be caused by this?
tparse error: no parseable events: call go test with -json flag


##@ Local development/Public Jenkins/Verification

Expand Down