-
Notifications
You must be signed in to change notification settings - Fork 1
/
azure-pipelines.yml
72 lines (66 loc) · 2.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
# Go
# Build your Go project.
# Add steps that test, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/go
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
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 build -v .
workingDirectory: '$(modulePath)'
displayName: 'Get dependencies, then build'
- script: |
SONARCLOUDDIR=/tmp
wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-3.2.0.1227-linux.zip -O $SONARCLOUDDIR/sonar.zip
unzip $SONARCLOUDDIR/sonar.zip -d /tmp
ls -al $SONARCLOUDDIR
cat $SONARCLOUDDIR/sonar-scanner-3.2.0.1227-linux/conf/sonar-scanner.properties
PATH=$SONARCLOUDDIR/sonar-scanner-3.2.0.1227-linux/bin:$PATH
echo $PATH
sonar-scanner -h
# Run Go code checks and store the results where they can be used by Sonarcloud
PWD=$(pwd)
cd $(find . -name wilee.go | sed 's/wilee.go//g')
go test -coverprofile=$PWD/coverage.out
go vet 2> $PWD/govet-report.out
golint > $PWD/golint-report.out
gometalinter > $PWD/gometalinter-report.out
ls -l
cd $PWD
ls -l
sonar-scanner \
-Dsonar.projectKey=wilee \
-Dsonar.organization=monch1962-github \
-Dsonar.go.coverage.reportPaths=coverage.out \
-Dsonar.go.govet.reportPaths=govet-report.out \
-Dsonar.go.golint.reportPaths=golint-report.out \
-Dsonar.go.gometalinter.reportPaths=gometalinter-report.out \
-Dsonar.sources=. \
-Dsonar.exclusions=gopath/pkg/dep/**,gopath/,gopath/src/wilee_test.go,wilee_test.go \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.login=bc2d9a98b4ce222ae3df1b1c25c0a63a47933603
displayName: 'Run sonarcloud code quality tests'
- script: |
go test
workingDirectory: '$(modulePath)'
displayName: 'Run unit tests'