forked from Azure/azure-sdk-for-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
138 lines (121 loc) · 4.12 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# This builds only track 1 SDKs. See eng\pipelines\templates\steps\build.yml for track 2.
trigger:
branches:
include:
- main
- legacy
paths:
exclude:
- sdk/
- eng/tools/
- eng/config.json
pr:
branches:
include:
- main
- legacy
paths:
exclude:
- sdk/
- eng/tools/
- eng/config.json
jobs:
- job: Build_Test
strategy:
matrix:
Linux_Go117:
pool.name: azsdk-pool-mms-ubuntu-2004-general
go.version: '1.17.8'
Linux_Go118:
pool.name: azsdk-pool-mms-ubuntu-2004-general
go.version: '1.18.2'
pool:
name: $(pool.name)
variables:
- template: /eng/pipelines/templates/variables/globals.yml
- name: GOPATH
value: '$(system.defaultWorkingDirectory)/work'
- name: sdkPath
value: '$(GOPATH)/src/github.com/$(build.repository.name)'
- name: GO111MODULE
value: 'off'
- name: IGNORE_BREAKING_CHANGES
value: 'true'
- name: go.list.filter
value: 'profiles services storage'
- name: go.test.filter
value: '-path ./vendor -prune -o -path ./sdk -prune -o -path ./eng -prune -o'
steps:
- task: GoTool@0
inputs:
version: '$(go.version)'
displayName: "Select Go Version"
- script: |
set -e
mkdir -p '$(GOPATH)/bin'
mkdir -p '$(sdkPath)'
shopt -s dotglob extglob
mv !(work) '$(sdkPath)'
echo '##vso[task.prependpath]$(GOROOT)/bin'
echo '##vso[task.prependpath]$(GOPATH)/bin'
displayName: 'Create Go Workspace'
- script: |
set -e
go version
curl -sSL https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure -v
go get -u golang.org/x/lint/golint
workingDirectory: '$(sdkPath)'
displayName: 'Install Dependencies'
- script: |
for dd in $(go.list.filter); do
cd $(sdkPath)/$dd
go vet -v ./...
done
workingDirectory: '$(sdkPath)'
displayName: 'Vet'
- script: |
for dd in $(go.list.filter); do
cd $(sdkPath)/$dd
go build -v ./...
done
workingDirectory: '$(sdkPath)'
displayName: 'Build'
- script: go test $(dirname $(find . $(go.test.filter) -name '*_test.go' -print) | sort -u)
workingDirectory: '$(sdkPath)'
displayName: 'Run Tests'
- template: /eng/common/pipelines/templates/steps/verify-links.yml
parameters:
${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
Urls: ($(sdkPath)/eng/common/scripts/get-markdown-files-from-changed-files.ps1)
${{ if ne(variables['Build.Reason'], 'PullRequest') }}:
Urls: $(Get-ChildItem -Path '$(sdkPath)/*.md' -Recurse | Where {$_.FullName -notlike "*/vendor/*" -and $_.FullName -notlike "*/sdk/*"})
Directory: ''
ScriptDirectory: '$(sdkPath)/eng/common/scripts'
WorkingDirectory: '$(sdkPath)'
- script: go run ./eng/tools/apidiff/main.go packages ./services FETCH_HEAD~1 FETCH_HEAD --copyrepo --breakingchanges || $IGNORE_BREAKING_CHANGES
workingDirectory: '$(sdkPath)'
displayName: 'Display Breaking Changes'
- script: go run ./eng/tools/pkgchk/main.go ./services --exceptions ./eng/tools/pkgchk/exceptions.txt
workingDirectory: '$(sdkPath)'
displayName: 'Verify Package Directory'
- 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: |
for dd in $(go.list.filter); do
cd $(sdkPath)/$dd
gofmt -s -l -d $(find . -name '*.go' -print) >&2
done
workingDirectory: '$(sdkPath)'
displayName: 'Format Check'
failOnStderr: true
condition: and(succeededOrFailed(), startsWith(variables['go.version'], '1.16'))
- script: |
golint ./storage/... >&2
workingDirectory: '$(sdkPath)'
displayName: 'Linter Check'
failOnStderr: true
condition: succeededOrFailed()