Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

Commit

Permalink
Add inital code coverage and publish test results
Browse files Browse the repository at this point in the history
Kick off CI again

Update display name

Temporarily remove container

Fix coverage

Try gocover-cobertura

Add coverage make target

Fix makefile indentation

Add gocov-xml to make bootstrap

Remove gocov-html as Azure Pipelines auto-generates HTML report
  • Loading branch information
radu-matei committed Apr 17, 2019
1 parent 1847f2f commit d5c8606
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ HAS_DEP := $(shell $(CHECK) dep)
HAS_GOLANGCI := $(shell $(CHECK) golangci-lint)
HAS_GOIMPORTS := $(shell $(CHECK) goimports)
GOLANGCI_VERSION := v1.16.0
HAS_COCOV_XML := $(shell command -v gocov-xml;)
HAS_GOCOV := $(shell command -v gocov;)
HAS_GO_JUNIT_REPORT := $(shell command -v go-junit-report;)

.PHONY: build-drivers
build-drivers:
Expand All @@ -95,6 +98,21 @@ ifndef HAS_GOIMPORTS
go get -u golang.org/x/tools/cmd/goimports
endif
dep ensure -vendor-only -v
ifndef HAS_COCOV_XML
go get github.com/AlekSi/gocov-xml
endif
ifndef HAS_GOCOV
go get -u github.com/axw/gocov/gocov
endif
ifndef HAS_GO_JUNIT_REPORT
go get github.com/jstemmer/go-junit-report
endif

.PHONY: coverage
coverage:
go test -v -coverprofile=coverage.txt -covermode count ./... 2>&1 | go-junit-report > report.xml
gocov convert coverage.txt > coverage.json
gocov-xml < coverage.json > coverage.xml

.PHONY: goimports
goimports:
Expand Down
23 changes: 15 additions & 8 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# Go
# Build your Go application.
# Add steps that test, save build artifacts, deploy, and more:
# https://docs.microsoft.com/vsts/pipelines/languages/go

pool:
vmImage: 'Ubuntu 16.04'

Expand All @@ -25,7 +20,19 @@ steps:

- script: |
go version
go get -v -t -d ./...
make bootstrap build test lint
make bootstrap
make build
make coverage
make lint
workingDirectory: '$(modulePath)'
displayName: 'Get dependencies, build, test'
displayName: 'Get dependencies, build, test, pubish, test and coverage results'

- task: PublishTestResults@2
inputs:
testRunner: JUnit
testResultsFiles: $(System.DefaultWorkingDirectory)/**/report.xml

- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: $(System.DefaultWorkingDirectory)/**/coverage.xml

0 comments on commit d5c8606

Please sign in to comment.