-
Notifications
You must be signed in to change notification settings - Fork 4
/
azure-pipelines.yml
77 lines (65 loc) · 2.34 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
70
71
72
73
74
75
76
77
# Go
# Build your Go project.
# Add steps that test, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/go
trigger:
- master
pool:
vmImage: 'Ubuntu-16.04'
variables:
GOBIN: '$(GOPATH)/bin' # Go binaries path
GOROOT: '/usr/local/go1.11' # Go installation path
GOPATH: '$(Agent.HomeDirectory)/go' # Go workspace path
LDFLAGS: -extldflags '-static' -X github.com/alde/ale/version.Version='$(Build.BuildNumber)' -X github.com/alde/ale/version.BuildDate=$(Build.BuildNumber)
DOCKERTAG: 'alde/ale:$(Build.BuildNumber)'
steps:
- bash: |
mkdir -p '$(GOBIN)'
mkdir -p '$(GOPATH)/pkg'
shopt -s extglob
shopt -s dotglob
echo '##vso[task.prependpath]$(GOBIN)'
echo '##vso[task.prependpath]$(GOROOT)/bin'
displayName: 'Set up the Go workspace'
- bash: |
go version
go get golang.org/x/lint/golint
go get github.com/jstemmer/go-junit-report
go get github.com/axw/gocov/gocov
go get github.com/AlekSi/gocov-xml
go get github.com/alde/gocov-html
displayName: 'Get dependencies'
- bash: |
go vet ./...
golint -set_exit_status
continueOnError: 'true'
displayName: 'vet and lint'
- bash: |
mkdir reports
go test ./... -v -coverprofile=./reports/coverage.txt -covermode count 2>&1 | go-junit-report > ./reports/junit.xml
gocov convert ./reports/coverage.txt > ./reports/coverage.json
gocov-xml < ./reports/coverage.json > ./reports/coverage.xml
gocov-html < ./reports/coverage.json > ./reports/index.html
displayName: 'Run unit tests'
- bash: |
go build -v -ldflags "$(LDFLAGS)" -o ale github.com/alde/ale/cmd/ale
displayName: 'build'
- bash: |
CGO_ENABLED=0 GOOS=linux go build -ldflags "$(LDFLAGS)" -a -installsuffix cgo -o ale github.com/alde/ale/cmd/ale
docker build -t $(DOCKERTAG) .
displayName: 'build docker image'
- bash: |
docker login -u $(dockerId) -p $(dockerPassword)
docker push $(DOCKERTAG)
displayName: 'push docker image'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
- task: PublishTestResults@2
inputs:
testRunner: JUnit
testResultsFiles: './reports/junit.xml'
failTaskOnFailedTests: true
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: 'cobertura'
summaryFileLocation: './reports/coverage.xml'
reportDirectory: './reports/'