-
Notifications
You must be signed in to change notification settings - Fork 870
/
Copy pathbuild-test.yml
159 lines (145 loc) · 5.05 KB
/
build-test.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
parameters:
- name: ServiceDirectory
type: string
default: ''
- name: Image
type: string
default: ''
- name: GoVersion
type: string
default: ''
- name: TestProxy
type: boolean
default: false
- name: EnvVars
type: object
default: {}
- name: TestRunTime
type: string
default: '600s'
- name: EnableRaceDetector
type: boolean
default: false
- name: UseFederatedAuth
type: boolean
default: false
- name: ServiceConnection
type: string
default: ''
steps:
- task: Powershell@2
displayName: Use azcore from main
condition: eq(variables.UseAzcoreFromMain, 'true')
env:
GO111MODULE: 'on'
inputs:
targetType: filePath
pwsh: true
filePath: eng/scripts/Replace-azcore.ps1
arguments: '${{ parameters.ServiceDirectory }}'
- task: Powershell@2
displayName: Build
env:
GO111MODULE: 'on'
inputs:
targetType: filePath
pwsh: true
filePath: eng/scripts/build.ps1
arguments: -filter '${{ parameters.ServiceDirectory }}'
- task: Powershell@2
displayName: Vet
env:
GO111MODULE: 'on'
inputs:
targetType: filePath
pwsh: true
filePath: eng/scripts/build.ps1
arguments: -vet -skipBuild -filter '${{ parameters.ServiceDirectory }}'
- pwsh: |
go install github.com/jstemmer/go-junit-report@v0.9.1
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
go install github.com/axw/gocov/gocov@v1.1.0
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
go install github.com/AlekSi/gocov-xml@v1.0.0
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
go install github.com/matm/gocov-html@v0.0.0-20200509184451-71874e2e203b
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
displayName: "Install Coverage and Junit Dependencies"
retryCountOnTaskFailure: 3
- ${{ if eq(parameters.TestProxy, true) }}:
- template: /eng/common/testproxy/test-proxy-tool.yml
- ${{ if parameters.UseFederatedAuth }}:
- task: AzurePowerShell@5
displayName: Run Tests (Federated Auth)
inputs:
azureSubscription: ${{ parameters.ServiceConnection }}
azurePowerShellVersion: LatestVersion
ScriptType: InlineScript
Inline: |
$account = (Get-AzContext).Account
$env:AZURESUBSCRIPTION_CLIENT_ID = $account.Id
$env:AZURESUBSCRIPTION_TENANT_ID = $account.Tenants
./eng/scripts/run_tests.ps1 ${{ parameters.ServiceDirectory }} ${{ parameters.TestRunTime }} $${{ parameters.EnableRaceDetector }}
exit $LASTEXITCODE
pwsh: true
env:
GO111MODULE: 'on'
PROXY_CERT: $(Build.SourcesDirectory)/eng/common/testproxy/dotnet-devcert.crt
${{ insert }}: ${{ parameters.EnvVars }}
GOTRACEBACK: all
AZURE_SDK_GO_LOGGING: all
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
- task: AzurePowerShell@5
displayName: Build Performance Tests (Federated Auth)
inputs:
azureSubscription: ${{ parameters.ServiceConnection }}
azurePowerShellVersion: LatestVersion
ScriptType: InlineScript
Inline: |
$account = (Get-AzContext).Account
$env:AZURESUBSCRIPTION_CLIENT_ID = $account.Id
$env:AZURESUBSCRIPTION_TENANT_ID = $account.Tenants
eng/scripts/Build_Perf.ps1 ${{ parameters.ServiceDirectory }} $$(UseAzcoreFromMain)
exit $LASTEXITCODE
pwsh: true
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
- ${{ else }}:
- task: PowerShell@2
displayName: 'Run Tests'
inputs:
targetType: 'filePath'
filePath: ./eng/scripts/run_tests.ps1
arguments: '${{ parameters.ServiceDirectory }} ${{ parameters.TestRunTime }} $${{ parameters.EnableRaceDetector }}'
pwsh: true
env:
GO111MODULE: 'on'
PROXY_CERT: $(Build.SourcesDirectory)/eng/common/testproxy/dotnet-devcert.crt
${{ insert }}: ${{ parameters.EnvVars }}
GOTRACEBACK: all
AZURE_SDK_GO_LOGGING: all
- task: PowerShell@2
displayName: 'Build Performance Tests'
inputs:
targetType: 'filePath'
filePath: ./eng/scripts/Build_Perf.ps1
arguments: '${{ parameters.ServiceDirectory }} $$(UseAzcoreFromMain)'
pwsh: true
- ${{ if eq(parameters.TestProxy, true) }}:
- pwsh: |
# $(Build.SourcesDirectory)/test-proxy.log is the hardcoded output log location for the test-proxy-tool.yml
cat $(Build.SourcesDirectory)/test-proxy.log
displayName: 'Dump Test Proxy logs'
condition: succeededOrFailed()
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testRunner: JUnit
testResultsFiles: '$(Build.SourcesDirectory)/sdk/${{parameters.ServiceDirectory}}/report.xml'
testRunTitle: 'Go ${{ parameters.GoVersion }} on ${{ parameters.Image }}'
failTaskOnFailedTests: true
- task: PublishCodeCoverageResults@2
condition: succeededOrFailed()
inputs:
summaryFileLocation: './coverage.xml'
additionalCodeCoverageFiles: './coverage.html'