-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
108 lines (94 loc) · 3.45 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# 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:
name: 'QED Pool'
variables:
GOBIN: '$(GOPATH)/bin' # Go binaries path
GOROOT: '$(Agent.BuildDirectory)/go' # Go installation path
GOPATH: '$(system.defaultWorkingDirectory)/gopath' # Go workspace path
modulePath: '$(GOPATH)/src/github.com/$(build.repository.name)' # Path to the module's code
GO111MODULE: on
CGO_LDFLAGS_ALLOW: '.*'
steps:
- script: |
# Remove go package to avoid duplicicity on version update
if [ -d '$(Agent.BuildDirectory)/go' ]; then echo "Removing $(Agent.BuildDirectory)/go" && rm -rf '$(Agent.BuildDirectory)/go';fi
wget "https://dl.google.com/go/go1.13.1.linux-amd64.tar.gz" --output-document "$(Agent.BuildDirectory)/go1.13.1.tar.gz"
tar -C '$(Agent.BuildDirectory)' -xzf "$(Agent.BuildDirectory)/go1.13.1.tar.gz"
displayName: 'Clean install Go 1.13.1'
- 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: |
git submodule update --init --recursive
cd c-deps
./builddeps.sh
cd ..
workingDirectory: '$(modulePath)'
displayName: 'Build rocksdb'
- script: |
'$(GOROOT)/bin/go' get github.com/jstemmer/go-junit-report
'$(GOROOT)/bin/go' get github.com/axw/gocov/gocov
'$(GOROOT)/bin/go' get github.com/AlekSi/gocov-xml
'$(GOROOT)/bin/go' get github.com/matm/gocov-html
workingDirectory: '$(modulePath)'
displayName: 'Download code coverage tools'
- script: |
'$(GOROOT)/bin/go' version
'$(GOROOT)/bin/go' mod download
workingDirectory: '$(modulePath)'
displayName: 'Get dependencies'
- script: |
'$(GOROOT)/bin/go' test -v -coverprofile=coverage.txt -covermode=count ./... 2>&1 | tee coverage.out
cat coverage.out | go-junit-report > report.xml
'$(GOROOT)/bin/go' vet -composites=false ./...
gocov convert coverage.txt > coverage.json
gocov-xml < coverage.json > coverage.xml
mkdir coverage
gocov-html < coverage.json > coverage/index.html
'$(GOROOT)/bin/go' clean -modcache
workingDirectory: '$(modulePath)'
displayName: 'Build and test'
- task: PublishTestResults@2
inputs:
testRunner: JUnit
testResultsFiles: $(System.DefaultWorkingDirectory)/**/report.xml
failTaskOnFailedTests: true
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: $(System.DefaultWorkingDirectory)/**/coverage.xml
reportDirectory: $(System.DefaultWorkingDirectory)/**/coverage
- script: |
'$(GOROOT)/bin/go' clean -modcache
condition: always()
workingDirectory: '$(modulePath)'
displayName: 'Clean Go modules cache'
- script: |
./goreleaser.sh
'$(GOROOT)/bin/go' clean -modcache
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v')
workingDirectory: '$(modulePath)'
displayName: 'Create Release'
- task: GithubRelease@0
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v')
displayName: 'Create GitHub Release'
inputs:
gitHubConnection: githubrelease
repositoryName: bbva/qed
assets: |
$(modulePath)/dist/qed-*.tar.gz
$(modulePath)/dist/qed-*.txt
isDraft: true
addChangeLog: false