-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yml
68 lines (58 loc) · 2.02 KB
/
azure-pipelines.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
trigger:
- master
pr:
- master
pool:
vmImage: 'Ubuntu 16.04'
variables:
- name: GOBIN
value: '$(GOPATH)/bin' # Go binaries path
- name: GOPATH
value: '$(system.defaultWorkingDirectory)/gopath' # Go workspace path
- name: modulePath
value: '$(GOPATH)/$(build.repository.name)'
- group: hwsc-dev-container-vars
steps:
- script: printenv
- script: |
mkdir -p '$(GOBIN)'
mkdir -p '$(GOPATH)/pkg'
mkdir -p '$(modulePath)'
shopt -s extglob
mv !(gopath) '$(modulePath)'
echo '##vso[task.prependpath]$(GOBIN)'
echo '##vso[task.prependpath]$(GOROOT)/bin'
displayName: 'Set Up the Go Workspace'
- script: go get -v -t -d ./...
workingDirectory: '$(modulePath)'
displayName: 'Go Get Dependencies'
- script: go build -v ./...
workingDirectory: '$(modulePath)'
displayName: 'Build Test'
- script: |
go test -v -cover -race ./...
go get github.com/jstemmer/go-junit-report
go get github.com/axw/gocov/gocov
go get github.com/AlekSi/gocov-xml
go test -coverprofile=coverage.out -v -race -covermode atomic ./... 2>&1 | go-junit-report > report.xml
gocov convert coverage.out | gocov-xml > coverage.xml
mkdir -p coverage/official-tool
go tool cover -html=coverage.out -o coverage/official-tool/coverage.html
go get -u github.com/matm/gocov-html
gocov convert coverage.out > coverage.json
gocov-html < coverage.json > coverage/index.html
workingDirectory: '$(modulePath)'
displayName: 'Run Unit Test'
- task: PublishTestResults@2
inputs:
testRunner: JUnit
testResultsFiles: $(System.DefaultWorkingDirectory)/**/report.xml
failTaskOnFailedTests: 'true'
failOnStandardError: 'true'
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: $(System.DefaultWorkingDirectory)/**/coverage.xml
reportDirectory: $(System.DefaultWorkingDirectory)/**/coverage
failIfCoverageEmpty: 'true'
failOnStandardError: 'true'