-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathtemplate-steps-build-test.yml
217 lines (188 loc) · 9 KB
/
template-steps-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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
parameters:
configuration: ''
solution: ''
nugetVersion: ''
binariesVersion: ''
testServer: ''
oopWorkerSupportedExtensionVersion: ''
steps:
- task: UseDotNet@2
displayName: 'Install .NET SDK'
inputs:
useGlobalJson: true
# Install .Net Core 3.1.0 as PowerShell tests are unable to find 3.1.0 framework to run tests
- task: UseDotNet@2
displayName: 'Install .NET Core 3.1 sdk'
inputs:
packageType: sdk
version: '3.1.x'
- script: npm install -g azure-functions-core-tools
displayName: 'Install Azure Functions Core Tools'
- script: npm install -g azurite
displayName: 'Install Azurite Local Storage Emulator'
# This step is necessary because npm installs to a non-traditional location on Windows hosted agents
# For non-Windows agents we still want to ensure that we always get the correct location where the tools are installed
# This sets the path to npm global installations as a variable which then gets passed to .NET test task
- bash: echo "##vso[task.setvariable variable=nodeModulesPath]$(npm root -g)"
displayName: 'Set npm installation path'
- bash: echo "##vso[task.setvariable variable=azureFunctionsExtensionBundlePath]$(func GetExtensionBundlePath)"
displayName: 'Set Azure Functions extension bundle path'
workingDirectory: $(Build.SourcesDirectory)/samples/samples-js
- task: DockerInstaller@0
displayName: Docker Installer
inputs:
dockerVersion: 17.09.0-ce
releaseType: stable
condition: and(succeeded(), eq(variables['Agent.OS'], 'linux'))
- script: docker pull mcr.microsoft.com/mssql/server:2019-latest
displayName: Pull MSSQL Docker Image
condition: and(succeeded(), eq(variables['Agent.OS'], 'linux'))
- bash: echo "##vso[task.setvariable variable=serverPassword]Test-$(Build.BuildNumber)-$(Get-Date -format yyyyMMdd-Hmmss)"
displayName: Generate password for test server
condition: and(succeeded(), eq(variables['Agent.OS'], 'linux'))
- script: 'docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=$(serverPassword)" -e "MSSQL_PID=Express"
-p 1433:1433 --name sql1 -h sql1
-d mcr.microsoft.com/mssql/server:2019-latest'
displayName: Start Server in Docker Container
condition: and(succeeded(), eq(variables['Agent.OS'], 'linux'))
- powershell: $(System.DefaultWorkingDirectory)/builds/scripts/UpdateLogLevel.ps1
displayName: Set logging level
condition: and(succeeded(), ne(variables['AFSQLEXT_TEST_LOGLEVEL'], ''))
- script: |
npm install
npm run lint
workingDirectory: $(Build.SourcesDirectory)/samples/samples-js
displayName: Lint samples-js
- script: |
npm install
npm run lint
workingDirectory: $(Build.SourcesDirectory)/test/Integration/test-js
displayName: Lint test-js
- task: UsePythonVersion@0
inputs:
versionSpec: '3.9'
addToPath: true
architecture: 'x64'
- script: |
pip3 install "pylint<3.0"
pip3 install pylintfileheader
pylint --recursive=yes .
workingDirectory: $(Build.SourcesDirectory)/samples/samples-python
displayName: Lint samples-python
- script: |
pip3 install -r requirements.txt
workingDirectory: $(Build.SourcesDirectory)/samples/samples-python
displayName: Install samples-python dependencies
- task: Maven@4
displayName: Build Java Samples
inputs:
mavenPomFile: samples/samples-java/pom.xml
# batch-mode and Slf4jMavenTransferListener definition are used to make the build logging verbose
# update-snapshot forces a check for updated library dependencies
options: --batch-mode --define=org.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn --update-snapshots
checkStyleRunAnalysis: true
- task: Maven@4
displayName: Build Java Tests
inputs:
mavenPomFile: test/Integration/test-java/pom.xml
# batch-mode and Slf4jMavenTransferListener definition are used to make the build logging verbose
# update-snapshot forces a check for updated library dependencies
options: --batch-mode --define=org.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn --update-snapshots
checkStyleRunAnalysis: true
# The build process for the OOP samples involve generating a temporary csproj in the %TEMP% directory, so it doesn't pick
# up the custom nuget.config we have. Set up the local-packages source here so that it can build correctly. Running from
# WorkFolder so it applies globally.
- task: DotNetCoreCLI@2
displayName: Set up local-packages Nuget source
inputs:
command: custom
custom: nuget
arguments: add source -n afsqlext.local $(Build.SourcesDirectory)/local-packages
workingDirectory: $(Agent.WorkFolder)
- task: DotNetCoreCLI@2
displayName: .NET Build
inputs:
command: build
projects: ${{ parameters.solution }}
arguments: --configuration ${{ parameters.configuration }} -p:Version=${{ parameters.binariesVersion }} -p:OOPWorkerSupportedExtensionVersion=${{ parameters.oopWorkerSupportedExtensionVersion }} -p:PackageVersion=${{ parameters.nugetVersion }} -v d
# Copy the Sql nupkg to ensure it's available for tests since the package copy task is failing occasionally so having this redundancy.
- task: CopyFiles@2
displayName: 'Copy local Sql package to local-packages folder'
inputs:
sourceFolder: $(Build.SourcesDirectory)/src/bin/${{ parameters.configuration }}
contents: '*.nupkg'
targetFolder: $(Build.SourcesDirectory)/local-packages
overWrite: true
- task: CopyFiles@2
displayName: 'Copy Sql extension dll to Azure Functions extension bundle'
inputs:
sourceFolder: $(Build.SourcesDirectory)/src/bin/${{ parameters.configuration }}/netstandard2.0
contents: Microsoft.Azure.WebJobs.Extensions.Sql.dll
targetFolder: $(azureFunctionsExtensionBundlePath)/bin
overWrite: true
- task: DotNetCoreCLI@2
displayName: '.NET Test on Mac (unit tests only)'
env:
TEST_SERVER: ${{ parameters.testServer }}
NODE_MODULES_PATH: '$(nodeModulesPath)'
AZUREFUNCTIONS_SQLBINDINGS_TELEMETRY_OPTOUT: '1'
inputs:
command: test
projects: '${{ parameters.solution }}'
arguments: --configuration ${{ parameters.configuration }} --filter FullyQualifiedName!~Integration --no-build
condition: and(succeeded(), eq(variables['Agent.OS'], 'Darwin'))
- task: DotNetCoreCLI@2
displayName: '.NET Test on Windows (unit tests and .NET In-Proc integration tests)'
env:
TEST_SERVER: ${{ parameters.testServer }}
NODE_MODULES_PATH: '$(nodeModulesPath)'
AZUREFUNCTIONS_SQLBINDINGS_TELEMETRY_OPTOUT: '1'
# Only running CSharp integration tests to get accurate code coverage numbers
LANGUAGES_TO_TEST: 'CSharp'
inputs:
command: test
projects: '${{ parameters.solution }}'
# Skip any non .NET In-Proc integration tests. Otherwise, the following error will be thrown:
# System.InvalidOperationException : No data found for Microsoft.Azure.WebJobs.Extensions.Sql.Tests.Integration.SqlOutputBindingIntegrationTests.NoPropertiesThrows
arguments: --configuration ${{ parameters.configuration }} --filter "FullyQualifiedName!~NoPropertiesThrows & FullyQualifiedName!~AddProductWithSlashInColumnName" --collect "Code Coverage" -s $(Build.SourcesDirectory)/test/coverage.runsettings --no-build
condition: and(succeededOrFailed(), eq(variables['Agent.OS'], 'Windows_NT'))
- task: DotNetCoreCLI@2
displayName: '.NET Test on Windows (Non .NET In-Proc)'
env:
TEST_SERVER: ${{ parameters.testServer }}
NODE_MODULES_PATH: '$(nodeModulesPath)'
AZUREFUNCTIONS_SQLBINDINGS_TELEMETRY_OPTOUT: '1'
LANGUAGES_TO_TEST: 'Java,JavaScript,OutOfProc,PowerShell,Python,Csx'
inputs:
command: test
projects: '${{ parameters.solution }}'
# Skip any CSharp only integration tests
arguments: --configuration ${{ parameters.configuration }} --filter "FullyQualifiedName~Integration & FullyQualifiedName!~AddProductsCollectorTest" --no-build
condition: and(succeededOrFailed(), eq(variables['Agent.OS'], 'Windows_NT'))
- task: DotNetCoreCLI@2
displayName: '.NET Test on Linux (both unit and integration tests)'
env:
SA_PASSWORD: '$(serverPassword)'
NODE_MODULES_PATH: '$(nodeModulesPath)'
AZUREFUNCTIONS_SQLBINDINGS_TELEMETRY_OPTOUT: '1'
inputs:
command: test
projects: '${{ parameters.solution }}'
arguments: --configuration ${{ parameters.configuration }} --no-build
condition: and(succeededOrFailed(), eq(variables['Agent.OS'], 'linux'))
- script: |
docker stop sql1
docker rm sql1
displayName: 'Stop and Remove SQL Server Image'
condition: and(succeeded(), eq(variables['Agent.OS'], 'linux'))
# Don't run for PRs since this currently breaks on runs from forks. We run this daily ourselves anyways.
- task: securedevelopmentteam.vss-secure-development-tools.build-task-roslynanalyzers.RoslynAnalyzers@3
inputs:
userProvideBuildInfo: 'autoMsBuildInfo'
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'), ne(variables['Build.Reason'], 'PullRequest'))
- task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0
displayName: 'Component Detection'
inputs:
failOnAlert: true