-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
304 lines (290 loc) · 13 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
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
trigger:
branches:
include:
- '*'
tags:
include:
- '*'
variables:
isPullRequest: $[eq(variables['Build.Reason'], 'PullRequest')]
pullRequestSourceBranch: $[variables['System.PullRequest.SourceBranch']]
skipWindowsTests: $[and(eq(variables['isPullRequest'], 'True'), ne(contains(variables['pullRequestSourceBranch'], 'windows'), 'True'))]
mysqlCurrentSqlMode: ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
mysqlLegacySqlMode: ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
# Currently no ONLY_FULL_GROUP_BY, see #1167:
mariadbSqlMode: STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
maxConnections: 255
runIntegrationTests: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: 1
jobs:
- job: BuildAndTest
displayName: Build and Test
strategy:
matrix:
MySQL 8.0 (Windows):
vmImageName: 'windows-latest'
databaseServerType: 'mysql'
databaseServerVersion: '8.0.21'
sqlMode: $(mysqlCurrentSqlMode)
skipTests: $(skipWindowsTests)
MySQL 8.0 (Linux):
vmImageName: 'ubuntu-latest'
databaseServerType: 'mysql'
databaseServerVersion: '8.0.21'
sqlMode: $(mysqlCurrentSqlMode)
skipTests: false
MySQL 5.7 (Linux):
vmImageName: 'ubuntu-latest'
databaseServerType: 'mysql'
databaseServerVersion: '5.7.32'
sqlMode: $(mysqlLegacySqlMode)
skipTests: false
MariaDB 10.5 (Linux):
vmImageName: 'ubuntu-latest'
databaseServerType: 'mariadb'
databaseServerVersion: '10.5.5'
sqlMode: $(mariadbSqlMode)
skipTests: false
MariaDB 10.4 (Linux):
vmImageName: 'ubuntu-latest'
databaseServerType: 'mariadb'
databaseServerVersion: '10.4.14'
sqlMode: $(mariadbSqlMode)
skipTests: false
MariaDB 10.3 (Linux):
vmImageName: 'ubuntu-latest'
databaseServerType: 'mariadb'
databaseServerVersion: '10.3.24'
sqlMode: $(mariadbSqlMode)
skipTests: false
pool:
vmImage: $(vmImageName)
steps:
- pwsh: |
echo "skipTests: $(skipTests)"
echo "skipWindowsTests: $(skipWindowsTests)"
echo "pullRequestSourceBranch: $(pullRequestSourceBranch)"
echo "isPullRequest: $(isPullRequest)"
echo "Build.SourceBranchName: $(Build.SourceBranchName)"
echo "Build.SourceVersionMessage: $(Build.SourceVersionMessage)"
displayName: Output Variables
- task: UseDotNet@2
displayName: 'Use .NET Core SDK'
inputs:
useGlobalJson: true
- pwsh: |
if ('$(Agent.OS)' -eq 'Windows_NT')
{
echo "Chocolatey command: choco install '$(databaseServerType)' '--version=$(databaseServerVersion)'"
choco install '$(databaseServerType)' '--version=$(databaseServerVersion)'
$mySqlServiceName = 'MySQL'
$lowerCaseTableNames = 2
$mySqlIniPath = 'C:\tools\mysql\current\my.ini'
$mySqlDataPath = 'C:\ProgramData\MySQL\data'
Stop-Service $mySqlServiceName
"lower_case_table_names=$lowerCaseTableNames" >> $mySqlIniPath
Remove-Item $mySqlDataPath/* -Recurse -Force
mysqld --defaults-file="$mySqlIniPath" --initialize-insecure
Start-Service $mySqlServiceName
mysql -h localhost -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'Password12!';"
mysql -h localhost -u root -pPassword12! -e "SELECT @@version;"
}
else
{
sudo systemctl stop mysql
docker run --name mysql -e MYSQL_ROOT_PASSWORD=Password12! -p 3306:3306 -d '$(databaseServerType):$(databaseServerVersion)'
$waitMinutes = 5
$pollingIntervalSeconds = 3
$startTime = Get-Date
$started = $false
while (!($started = docker exec mysql mysqladmin -h localhost -P 3306 -u root -pPassword12! status) -and ((Get-Date) - $startTime).TotalMinutes -lt $waitMinutes)
{
Start-Sleep -Seconds $pollingIntervalSeconds
}
if (!$started)
{
throw "$(databaseServerType):$(databaseServerVersion) docker container failed to start in $(waitMinutes) minutes"
exit 1
}
}
displayName: Install Database Server
- pwsh: |
if ('$(Agent.OS)' -eq 'Windows_NT')
{
mysql -h localhost -u root -pPassword12! -e "SET GLOBAL sql_mode = '$(sqlMode)'; SET GLOBAL max_connections = $(maxConnections);"
}
else
{
docker exec mysql mysql -h localhost -P 3306 -u root -pPassword12! -e "SET GLOBAL sql_mode = '$(sqlMode)'; SET GLOBAL max_connections = $(maxConnections);"
}
displayName: Setup Database
ignoreLASTEXITCODE: true
- pwsh: |
if ('$(Agent.OS)' -eq 'Windows_NT')
{
mysql -h localhost -u root -pPassword12! -e 'SHOW VARIABLES;'
}
else
{
docker exec mysql mysql -h localhost -P 3306 -u root -pPassword12! -e 'SHOW VARIABLES;'
}
echo "Exit code: $?"
displayName: Database Information
continueOnError: true
failOnStderr: false
ignoreLASTEXITCODE: true
- pwsh: dotnet --info
displayName: .NET Information
- pwsh: |
dotnet tool restore
dotnet ef --version
displayName: Install EF Core Tools
- pwsh: |
cp test/EFCore.MySql.FunctionalTests/config.json.example test/EFCore.MySql.FunctionalTests/config.json
cp test/EFCore.MySql.IntegrationTests/appsettings.ci.json test/EFCore.MySql.IntegrationTests/appsettings.json
cp test/EFCore.MySql.IntegrationTests/config.json.example test/EFCore.MySql.IntegrationTests/config.json
dotnet build -c Debug
displayName: Setup and Build Solution
- pwsh: |
if ("$(runIntegrationTests)" -eq "true")
{
./test/EFCore.MySql.IntegrationTests/scripts/rebuild.ps1
}
displayName: Build Integration Tests
condition: ne(variables['skipTests'], true)
- pwsh: dotnet test --logger trx test/EFCore.MySql.Tests
displayName: Tests
condition: ne(variables['skipTests'], true)
- pwsh: dotnet test test/EFCore.MySql.FunctionalTests -c Release --logger trx --verbosity detailed
displayName: Functional Tests
condition: ne(variables['skipTests'], true)
- pwsh: |
Get-ChildItem QueryBaseline.txt -Recurse | % { $_.FullName }
Get-Content QueryBaseline.txt -ErrorAction Ignore
displayName: Show Query Baseline
condition: ne(variables['skipTests'], true)
- pwsh: dotnet run --project test/EFCore.MySql.IntegrationTests -c Release testMigrate
displayName: Integration Tests - Applying migrations
condition: and(ne(variables['skipTests'], true), eq(variables['runIntegrationTests'],'true'))
- pwsh: ./test/EFCore.MySql.IntegrationTests/scripts/scaffold.ps1
displayName: Integration Tests - Scaffolding
condition: and(ne(variables['skipTests'], true), eq(variables['runIntegrationTests'],'true'))
- pwsh: |
$env:EF_BATCH_SIZE = "1"
dotnet test -c Release --logger trx test/EFCore.MySql.IntegrationTests
displayName: Integration Tests - With EF_BATCH_SIZE = 1
condition: and(ne(variables['skipTests'], true), eq(variables['runIntegrationTests'],'true'))
- pwsh: |
$env:EF_BATCH_SIZE = "10"
dotnet test -c Release --logger trx test/EFCore.MySql.IntegrationTests
displayName: Integration Tests - With EF_BATCH_SIZE = 10
condition: and(ne(variables['skipTests'], true), eq(variables['runIntegrationTests'],'true'))
- pwsh: |
$env:EF_RETRY_ON_FAILURE = "3"
dotnet test -c Release --logger trx test/EFCore.MySql.IntegrationTests
displayName: Integration Tests - With EF_RETRY_ON_FAILURE = 3
condition: and(ne(variables['skipTests'], true), eq(variables['runIntegrationTests'],'true'))
- pwsh: ./test/EFCore.MySql.IntegrationTests/scripts/legacy.ps1
displayName: Integration Tests - Legacy migrations
condition: and(ne(variables['skipTests'], true), eq(variables['runIntegrationTests'],'true'))
- pwsh: |
$env:EF_DATABASE = "pomelo_test2"
dotnet build ./test/EFCore.MySql.IntegrationTests -c Release
displayName: Integration Tests - Building migrations with EF_DATABASE = pomelo_test2
condition: and(ne(variables['skipTests'], true), eq(variables['runIntegrationTests'],'true'))
- pwsh: |
$env:EF_DATABASE = "pomelo_test2"
./test/EFCore.MySql.IntegrationTests/scripts/rebuild.ps1
displayName: Integration Tests - Setup migrations with EF_DATABASE = pomelo_test2
condition: and(ne(variables['skipTests'], true), eq(variables['runIntegrationTests'],'true'))
- pwsh: |
$env:EF_DATABASE = "pomelo_test2"
dotnet test -c Release --logger trx test/EFCore.MySql.IntegrationTests
displayName: Integration Tests - With EF_DATABASE = pomelo_test2
condition: and(ne(variables['skipTests'], true), eq(variables['runIntegrationTests'],'true'))
- task: PublishTestResults@2
displayName: Publish Test Results
condition: and(ne(variables['skipTests'], true), succeededOrFailed())
inputs:
testResultsFormat: VSTest
testResultsFiles: test/**/*.trx
testRunTitle: $(Agent.OS) $(databaseServerType):$(databaseServerVersion)
mergeTestResults: true
failTaskOnFailedTests: true
- job: NuGet
dependsOn:
- BuildAndTest
condition: and(succeededOrFailed(), ne(variables['isPullRequest'], true))
variables:
runDespiteIssues: $[endsWith(variables['Build.SourceBranch'], '-wip')]
buildAndTestSucceeded: $[or(eq(dependencies.BuildAndTest.result, 'Succeeded'), and(eq(dependencies.BuildAndTest.result, 'SucceededWithIssues'), variables['runDespiteIssues']))]
pool:
vmImage: 'windows-latest' # must be Windows for PublishSymbols task
steps:
- task: UseDotNet@2
displayName: 'Use .NET Core SDK'
inputs:
useGlobalJson: true
- pwsh: dotnet --info
displayName: .NET Information
- pwsh: |
$officialBuild = '$(Build.SourceBranch)' -match '^refs/tags/[0-9]+\.[0-9]+\.[0-9]+'
$wipBuild = '$(Build.SourceBranch)' -match '^refs/heads/.*-wip$'
$ciBuildOnly = $wipBuild -or ('$(Build.SourceBranch)' -match '^refs/heads/(?:master|.*-maint)$')
$continuousIntegrationTimestamp = Get-Date -Format yyyyMMddHHmmss
$buildSha = '$(Build.SourceVersion)'.SubString(0, 7);
$pack = '$(buildAndTestSucceeded)' -eq "true" -and ($officialBuild -or $ciBuildOnly) -or $wipBuild
echo "officialBuild: $officialBuild"
echo "wipBuild: $wipBuild"
echo "ciBuildOnly: $ciBuildOnly"
echo "continuousIntegrationTimestamp: $continuousIntegrationTimestamp"
echo "buildSha: $buildSha"
echo "pack: $pack"
if ($pack)
{
$arguments = 'pack', '-c', 'Release', '-o', '$(Build.ArtifactStagingDirectory)', '-p:ContinuousIntegrationBuild=true'
if ($ciBuildOnly)
{
$arguments += "-p:ContinuousIntegrationTimestamp=$continuousIntegrationTimestamp"
$arguments += "-p:BuildSha=$buildSha"
}
$projectFiles = Get-ChildItem src/*/*.csproj -Recurse | % { $_.FullName }
foreach ($projectFile in $projectFiles)
{
echo "Pack command: dotnet " + (($arguments + $projectFile) -join ' ')
& dotnet ($arguments + $projectFile)
}
$pushToAzureArtifacts = $pack
$publishSymbolsForAzureArtifacts = $pushToAzureArtifacts
$pushToNugetOrg = $officialBuild
echo "pushToAzureArtifacts: $pushToAzureArtifacts"
echo "publishSymbolsForAzureArtifacts: $publishSymbolsForAzureArtifacts"
echo "pushToNugetOrg: $pushToNugetOrg"
echo "##vso[task.setvariable variable=Pack.PushToAzureArtifacts]$pushToAzureArtifacts"
echo "##vso[task.setvariable variable=Pack.PublishSymbolsForAzureArtifacts]$publishSymbolsForAzureArtifacts"
echo "##vso[task.setvariable variable=Pack.PushToNugetOrg]$pushToNugetOrg"
}
displayName: "NuGet Pack"
- task: NuGetCommand@2
displayName: "NuGet Push - AZDO Feed"
inputs:
command: push
publishVstsFeed: 'Pomelo.EntityFrameworkCore.MySql/pomelo-efcore-public'
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
condition: and(succeededOrFailed(), eq(variables['Pack.PushToAzureArtifacts'],'true'))
- task: PublishSymbols@2 # AZDO still has no snupkg support, so we need to publish the PDB files to a symbol server
displayName: "Publish Symbols to Azure Artifacts symbol server"
inputs:
symbolServerType: 'TeamServices'
treatNotIndexedAsWarning: false
indexSources: false
condition: and(succeededOrFailed(), eq(variables['Pack.PublishSymbolsForAzureArtifacts'],'true'))
- task: NuGetCommand@2
displayName: "NuGet Push - nuget.org"
inputs:
command: push
nuGetFeedType: external
publishFeedCredentials: NugetOrg-PomeloFoundation-AllPackages-PushNew
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
condition: and(succeededOrFailed(), eq(variables['Pack.PushToNugetOrg'],'true'))