-
Notifications
You must be signed in to change notification settings - Fork 175
/
azure-pipelines.yml
114 lines (100 loc) · 3.61 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
109
110
111
112
113
114
variables:
GO111MODULE: 'auto'
GOPATH: '$(system.defaultWorkingDirectory)/work'
sdkPath: '$(GOPATH)/src/github.com/$(build.repository.name)'
jobs:
- job: 'goautorest'
displayName: 'Run go-autorest CI Checks'
strategy:
matrix:
Linux_Go118:
vm.image: 'ubuntu-22.04'
go.version: '1.18.10'
Linux_Go119:
vm.image: 'ubuntu-22.04'
go.version: '1.19.5'
current_go: 'true'
pool:
vmImage: '$(vm.image)'
steps:
- task: GoTool@0
inputs:
version: '$(go.version)'
displayName: "Select Go Version"
- script: |
set -e
mkdir -p '$(GOPATH)/bin'
mkdir -p '$(sdkPath)'
shopt -s extglob
mv !(work) '$(sdkPath)'
echo '##vso[task.prependpath]$(GOPATH)/bin'
displayName: 'Create Go Workspace'
- script: |
set -e
export GO111MODULE=on
go install golang.org/x/lint/golint@latest
go install github.com/jstemmer/go-junit-report@latest
go install github.com/axw/gocov/gocov@latest
go install github.com/AlekSi/gocov-xml@latest
go install github.com/matm/gocov-html/cmd/gocov-html@latest
workingDirectory: '$(sdkPath)'
displayName: 'Install Dependencies'
- script: |
modules=$(find . -name go.mod)
for module in $modules; do
pushd "$(dirname $module)" && go vet ./... && popd;
done
workingDirectory: '$(sdkPath)'
displayName: 'Vet'
- script: |
modules=$(find . -name go.mod)
for module in $modules; do
pushd "$(dirname $module)" && go build -v ./... && popd;
done
workingDirectory: '$(sdkPath)'
displayName: 'Build'
- script: |
set -e
modules=$(find . -name go.mod)
for module in $modules; do
pushd "$(dirname $module)";
go test -race -v -coverprofile=coverage.txt -covermode atomic ./... 2>&1 | go-junit-report > report.xml;
gocov convert coverage.txt > coverage.json;
gocov-xml < coverage.json > coverage.xml;
gocov-html < coverage.json > coverage.html;
popd;
done
workingDirectory: '$(sdkPath)'
displayName: 'Run Tests'
- script: grep -L -r --include *.go --exclude-dir vendor -P "Copyright (\d{4}|\(c\)) Microsoft" ./ | tee >&2
workingDirectory: '$(sdkPath)'
displayName: 'Copyright Header Check'
failOnStderr: true
condition: succeededOrFailed()
- script: |
gofmt -s -l -w ./autorest/. >&2
gofmt -s -l -w ./logger/. >&2
gofmt -s -l -w ./tracing/. >&2
workingDirectory: '$(sdkPath)'
displayName: 'Format Check'
failOnStderr: true
condition: and(succeededOrFailed(), eq(variables['current_go'], 'true'))
- script: |
modules=$(find . -name go.mod)
for module in $modules; do
pushd "$(dirname $module)" && golint ./... >&2 && popd;
done
workingDirectory: '$(sdkPath)'
displayName: 'Linter Check'
failOnStderr: true
condition: succeededOrFailed()
- task: PublishTestResults@2
inputs:
testRunner: JUnit
testResultsFiles: $(sdkPath)/**/report.xml
failTaskOnFailedTests: true
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: $(sdkPath)/autorest/**/coverage.xml
additionalCodeCoverageFiles: $(sdkPath)/autorest/**/coverage.html