-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathazure-pipelines.yml
69 lines (61 loc) · 2.03 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
69
pool:
vmImage: 'Ubuntu 16.04'
variables:
GOBIN: '$(GOPATH)/bin' # Go binaries path
GOROOT: '/usr/local/go1.11' # Go installation path
GOPATH: '$(system.defaultWorkingDirectory)/gopath' # Go workspace path
modulePath: '$(GOPATH)/src/github.com/$(build.repository.name)' # Path to the module's code
steps:
- script: |
mkdir -p '$(GOBIN)'
mkdir -p '$(GOPATH)/pkg'
mkdir -p '$(modulePath)'
shopt -s extglob
shopt -s dotglob
mv !(gopath) '$(modulePath)'
echo '##vso[task.prependpath]$(GOBIN)'
echo '##vso[task.prependpath]$(GOROOT)/bin'
displayName: 'Set up the Go workspace'
- script: |
go version
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
go get github.com/jstemmer/go-junit-report
go get github.com/axw/gocov/gocov
go get github.com/AlekSi/gocov-xml
go get -u gopkg.in/matm/v1/gocov-html
workingDirectory: '$(modulePath)'
displayName: 'Get dependencies'
- script: |
#go test -v
#goveralls -service=travis-ci -repotoken "$(COVERALLS_KEY)"
go test -v -coverprofile=coverage.txt -covermode count 2>&1 | go-junit-report > junit.xml
gocov convert coverage.txt > coverage.json
gocov-xml < coverage.json > coverage.xml
gocov-html < coverage.json > index.html
mkdir reports
cp junit.xml ./reports/junit.xml
cp coverage.xml ./reports/coverage.xml
cp index.html ./reports/index.html
continueOnError: 'true'
workingDirectory: '$(modulePath)'
displayName: 'Run unit tests'
env:
MAPPED_COVERALLS_KEY: $(COVERALLS_KEY)
- script: |
go build -v
workingDirectory: '$(modulePath)'
continueOnError: 'true'
displayName: 'Build app'
- task: PublishTestResults@2
inputs:
testRunner: JUnit
testResultsFiles: '$(modulePath)/reports/junit.xml'
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: 'cobertura'
summaryFileLocation: '$(modulePath)/reports/coverage.xml'
reportDirectory: '$(modulePath)/reports/'