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

Add inital code coverage and publish test results #713

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
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;)
Copy link
Member Author

Choose a reason for hiding this comment

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

Ugh, this is a typo.

Copy link
Contributor

Choose a reason for hiding this comment

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

lmk when it's fixed and u want a review!

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