-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
355 lines (336 loc) · 14.2 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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
trigger:
branches:
include:
- '*'
tags:
include:
- '*'
variables:
current_mysql_mode: STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
legacy_mysql_mode: STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: 1
dotnet_version: 3.1.x
dotnet_ef_tools_version: 3.1.5
jobs:
- job: Linux
strategy:
matrix:
MySQL 8.0.18:
DOCKER_IMAGE: mysql:8.0.18
SERVER_VERSION: 8.0.18-mysql
SQL_MODE: $(current_mysql_mode)
INTEGRATION_TESTS: "true"
MySQL 5.7.27:
DOCKER_IMAGE: mysql:5.7.27
SERVER_VERSION: 5.7.27-mysql
SQL_MODE: $(legacy_mysql_mode)
INTEGRATION_TESTS: "true"
MariaDB 10.4.10:
DOCKER_IMAGE: mariadb:10.4.10
SERVER_VERSION: 10.4.10-mariadb
SQL_MODE: $(legacy_mysql_mode)
INTEGRATION_TESTS: "false"
MariaDB 10.3.18:
DOCKER_IMAGE: mariadb:10.3.20
SERVER_VERSION: 10.3.20-mariadb
SQL_MODE: $(legacy_mysql_mode)
INTEGRATION_TESTS: "false"
pool:
vmImage: 'ubuntu-16.04'
steps:
- task: UseDotNet@2
displayName: 'Use .NET Core SDK'
inputs:
version: $(dotnet_version)
- bash: |
set -e
sudo systemctl stop mysql
docker run --name mysql -e MYSQL_ROOT_PASSWORD=Password12! -p 3306:3306 -d $DOCKER_IMAGE
displayName: Install Database Server
- bash: |
./dotnet-env.sh dotnet --info
displayName: .NET Core Information
- bash: |
set -e
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
./build.sh
displayName: Setup and Build Solution
- bash: |
startTime=$SECONDS
started="false"
while true; do
if docker exec mysql mysqladmin -h localhost -P 3306 -u root -pPassword12! status; then
started="true"
break
fi
duration=$(($SECONDS - $startTime))
echo "duration=$duration"
if (( $duration > 300 )); then
break
else
sleep 3
fi
done
if [ "$started" = "false" ]; then
echo "$DOCKER_IMAGE container failed to start in 5 minutes" >&2
exit 1
fi
docker exec mysql mysql -h localhost -P 3306 -u root -pPassword12! -e "SET GLOBAL sql_mode = '$SQL_MODE';"
displayName: Setup Database
- bash: |
docker exec mysql mysql -h localhost -P 3306 -u root -pPassword12! -e "SHOW VARIABLES;';"
echo "Exit code: $?"
displayName: Database Information
continueOnError: true
failOnStderr: false
- bash: |
./dotnet-env.sh dotnet tool install --global dotnet-ef --version $(dotnet_ef_tools_version)
./dotnet-env.sh dotnet ef --version
displayName: Install EF Core Tools
- bash: |
if [ "$(INTEGRATION_TESTS)" = "true" ]; then
./dotnet-env.sh ./test/EFCore.MySql.IntegrationTests/scripts/rebuild.sh
fi
displayName: Build Integration Tests
- bash: ./dotnet-env.sh dotnet test --logger trx test/EFCore.MySql.Tests
displayName: Tests
continueOnError: true
- bash: ./dotnet-env.sh dotnet test test/EFCore.MySql.FunctionalTests -c Release --logger trx --verbosity detailed
displayName: Functional Tests
continueOnError: true
- bash: ./dotnet-env.sh dotnet run --project test/EFCore.MySql.IntegrationTests -c Release testMigrate
displayName: Integration Tests applying migrations
continueOnError: true
condition: eq(variables['INTEGRATION_TESTS'],'true')
- bash: ./dotnet-env.sh ./test/EFCore.MySql.IntegrationTests/scripts/scaffold.sh
displayName: Integration Tests scaffolding
continueOnError: true
condition: eq(variables['INTEGRATION_TESTS'],'true')
- bash: rm -rf ./test/EFCore.MySql.IntegrationTests/Scaffold
displayName: Remove scaffolding files
continueOnError: true
condition: eq(variables['INTEGRATION_TESTS'],'true')
- bash: ./dotnet-env.sh dotnet test -c Release --logger trx test/EFCore.MySql.IntegrationTests
displayName: Integration Tests with EF_BATCH_SIZE=1
continueOnError: true
condition: eq(variables['INTEGRATION_TESTS'],'true')
- bash: export EF_BATCH_SIZE="10" && ./dotnet-env.sh dotnet test -c Release --logger trx test/EFCore.MySql.IntegrationTests
displayName: Integration Tests with EF_BATCH_SIZE=10
continueOnError: true
condition: eq(variables['INTEGRATION_TESTS'],'true')
- bash: export EF_RETRY_ON_FAILURE="3" && ./dotnet-env.sh dotnet test -c Release --logger trx test/EFCore.MySql.IntegrationTests
displayName: Integration Tests with EF_RETRY_ON_FAILURE=3
continueOnError: true
condition: eq(variables['INTEGRATION_TESTS'],'true')
- bash: ./dotnet-env.sh ./test/EFCore.MySql.IntegrationTests/scripts/legacy.sh
displayName: Integration Tests legacy migrations
continueOnError: true
condition: eq(variables['INTEGRATION_TESTS'],'true')
- bash: export EF_DATABASE="pomelo_test2" && ./dotnet-env.sh dotnet build ./test/EFCore.MySql.IntegrationTests -c Release
displayName: Integration Tests Building migrations with EF_DATABASE=pomelo_test2
continueOnError: true
condition: eq(variables['INTEGRATION_TESTS'],'true')
- bash: export EF_DATABASE="pomelo_test2" && ./dotnet-env.sh ./test/EFCore.MySql.IntegrationTests/scripts/rebuild.sh
displayName: Integration Tests Setup migrations with EF_DATABASE=pomelo_test2
continueOnError: true
condition: eq(variables['INTEGRATION_TESTS'],'true')
- bash: export EF_DATABASE="pomelo_test2" && ./dotnet-env.sh dotnet test -c Release --logger trx test/EFCore.MySql.IntegrationTests
displayName: Integration Tests with EF_DATABASE=pomelo_test2
continueOnError: true
condition: eq(variables['INTEGRATION_TESTS'],'true')
- task: PublishTestResults@2
displayName: Publish Test Results
condition: succeededOrFailed()
inputs:
testResultsFormat: VSTest
testResultsFiles: test/**/*.trx
testRunTitle: Linux $(DOCKER_IMAGE)
mergeTestResults: true
failTaskOnFailedTests: true
- job: Windows
pool:
vmImage: 'windows-2019'
variables:
sql_mode: $(current_mysql_mode)
lower_case_table_names: 2
mysql_ini_path: C:\tools\mysql\current\my.ini
mysql_data_path: C:\ProgramData\MySQL\data
mysql_service_name: MySQL
steps:
- task: UseDotNet@2
displayName: 'Use .NET Core SDK'
inputs:
version: $(dotnet_version)
- pwsh: |
choco install mysql
Stop-Service $(mysql_service_name)
"lower_case_table_names=$(lower_case_table_names)" >> $(mysql_ini_path)
Remove-Item $(mysql_data_path)\* -Recurse -Force
mysqld --defaults-file="$(mysql_ini_path)" --initialize-insecure
Start-Service $(mysql_service_name)
mysql -h localhost -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'Password12!';"
mysql -h localhost -u root -pPassword12! -e "SELECT @@version;"
displayName: Install Database Server
- pwsh: |
.\dotnet-env.ps1 dotnet --info
displayName: .NET Core Information
- 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
.\build.cmd
displayName: Setup and Build Solution
- pwsh: |
mysql -h localhost -u root -pPassword12! -e "SET GLOBAL sql_mode = '$(sql_mode)';"
displayName: Setup Database
ignoreLASTEXITCODE: true
- pwsh: |
echo "$(mysql_ini_path) file:"
cat $(mysql_ini_path)
echo ""
echo "MySQL variables:"
mysql -h localhost -u root -pPassword12! -e "SHOW VARIABLES;';"
echo ""
echo "Exit code: $LastExitCode"
displayName: Database Information
continueOnError: true
ignoreLASTEXITCODE: true
- pwsh: |
.\dotnet-env.ps1 dotnet tool install --global dotnet-ef --version $(dotnet_ef_tools_version)
.\dotnet-env.ps1 dotnet ef --version
displayName: Install EF Core Tools
- pwsh: |
.\dotnet-env.ps1 .\test\EFCore.MySql.IntegrationTests\scripts\rebuild.ps1
displayName: Build Integration Tests
- pwsh: .\dotnet-env.ps1 dotnet test --logger trx test\EFCore.MySql.Tests
displayName: Tests
continueOnError: true
- pwsh: .\dotnet-env.ps1 dotnet test test\EFCore.MySql.FunctionalTests -c Release --logger trx --verbosity detailed
displayName: Functional Tests
continueOnError: true
- pwsh: .\dotnet-env.ps1 dotnet run --project test\EFCore.MySql.IntegrationTests -c Release testMigrate
displayName: Integration Tests applying migration
continueOnError: true
- pwsh: .\dotnet-env.ps1 dotnet test -c Release --logger trx test\EFCore.MySql.IntegrationTests
displayName: Integration Tests with EF_BATCH_SIZE=1
continueOnError: true
- pwsh: $env:EF_BATCH_SIZE="10"; .\dotnet-env.ps1 dotnet test -c Release --logger trx test\EFCore.MySql.IntegrationTests
displayName: Integration Tests with EF_BATCH_SIZE=10
continueOnError: true
- pwsh: $env:EF_RETRY_ON_FAILURE="3"; .\dotnet-env.ps1 dotnet test -c Release --logger trx test\EFCore.MySql.IntegrationTests
displayName: Integration Tests with EF_RETRY_ON_FAILURE=3
continueOnError: true
- pwsh: $env:EF_DATABASE="pomelo_test2"; .\dotnet-env.ps1 dotnet build .\test\EFCore.MySql.IntegrationTests -c Release
displayName: Integration Tests Building migrations with EF_DATABASE=pomelo_test2
continueOnError: true
- pwsh: $env:EF_DATABASE="pomelo_test2"; .\dotnet-env.ps1 .\test\EFCore.MySql.IntegrationTests\scripts\rebuild.ps1
displayName: Integration Tests Setup migrations with EF_DATABASE=pomelo_test2
continueOnError: true
- pwsh: $env:EF_DATABASE="pomelo_test2"; .\dotnet-env.ps1 dotnet test -c Release --logger trx test\EFCore.MySql.IntegrationTests
displayName: Integration Tests with EF_DATABASE=pomelo_test2
continueOnError: true
- task: PublishTestResults@2
displayName: Publish Test Results
condition: succeededOrFailed()
inputs:
testResultsFormat: VSTest
testResultsFiles: test/**/*.trx
testRunTitle: Windows
mergeTestResults: true
failTaskOnFailedTests: true
- job: Nuget
dependsOn:
- Linux
- Windows
condition: and( succeededOrFailed(), ne(variables['Build.Reason'], 'PullRequest') )
variables:
BuildSucceeded: $[ and( in(dependencies.Linux.result, 'Succeeded', 'SucceededWithIssues'), in(dependencies.Windows.result, 'Succeeded', 'SucceededWithIssues')) ]
pool:
vmImage: 'ubuntu-16.04'
steps:
- bash: |
set -e
pack="false"
pack_nuget_org=""
pack_wip="false"
echo "Build.SourceBranch=$(Build.SourceBranch)"
echo "Build.SourceBranchName=$(Build.SourceBranchName)"
final_version_kind=""
if echo "$(Build.SourceBranch)" | grep -qE '^refs/tags/'; then
pack="true"
if echo "$(Build.SourceBranchName)" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
final_version_kind="release"
else
final_version_kind="prerelease"
fi
elif echo "$(Build.SourceBranch)" | grep -qE '^refs/heads/'; then
if [ "$(Build.SourceBranchName)" = "master" ]; then
pack="true"
elif echo "$(Build.SourceBranchName)" | grep -qE '\-maint$'; then
pack="true"
elif echo "$(Build.SourceBranchName)" | grep -qE '\-wip$'; then
pack="true"
pack_wip="true"
fi
fi
echo "OfficialBuildId=$(Build.BuildNumber)"
echo "DotNetFinalVersionKind=$final_version_kind"
if [ "$pack" = "true" ]; then
./dotnet-env.sh dotnet pack \
-c Release \
"/p:OfficialBuildId=$(Build.BuildNumber)" \
"/p:DotNetFinalVersionKind=$final_version_kind" \
"/p:ContinuousIntegrationBuild=true" \
src/EFCore.MySql/
./dotnet-env.sh dotnet pack \
-c Release \
"/p:OfficialBuildId=$(Build.BuildNumber)" \
"/p:DotNetFinalVersionKind=$final_version_kind" \
"/p:ContinuousIntegrationBuild=true" \
src/EFCore.MySql.NTS/
fi
# If ALL nupkg files end in the branch name (no "preview-" etc.), we consider
# this an official release and push this to nuget.org.
# Otherwise, this release will be pushed exclusively to AZDO as a nightly build.
if [ "$final_version_kind" != "" ]; then
IFS=$'\n'
for i in $(find artifacts -name "*.nupkg"); do
filename=$(basename $i)
if { [ "$pack_nuget_org" == "" ] || [ "$pack_nuget_org" == "true" ]; } && [ "$filename" = "*.$(Build.SourceBranchName).nupkg" ]; then
pack_nuget_org="true"
elif [ $pack_nuget_org = "true" ]; then
pack_nuget_org="false"
break
fi
done
unset IFS
fi
if [ "$pack_nuget_org" == "" ]; then
pack_nuget_org="false"
fi
echo "Pack.Pack=$pack"
echo "Pack.Wip=$pack_wip"
echo "Pack.NugetOrg=$pack_nuget_org"
echo "##vso[task.setvariable variable=Pack.Pack]$pack"
echo "##vso[task.setvariable variable=Pack.Wip]$pack_wip"
echo "##vso[task.setvariable variable=Pack.NugetOrg]$pack_nuget_org"
displayName: "Nuget Pack"
- task: NuGetCommand@2
displayName: "Nuget Push AZDO Feed"
inputs:
command: push
nuGetFeedType: external
publishFeedCredentials: PomeloEFCoreNuget
packagesToPush: artifacts/**/*.nupkg
condition: and( succeededOrFailed(), eq(variables['Pack.Pack'],'true'), or( eq(variables['Pack.Wip'],'true'), variables['BuildSucceeded'], eq(variables['Pack.BuildFailedOverride'],'true') ) )
- task: NuGetCommand@2
displayName: "Nuget Push nuget.org"
inputs:
command: push
nuGetFeedType: external
publishFeedCredentials: NugetOrg
packagesToPush: artifacts/**/*.nupkg
condition: and( succeededOrFailed(), eq(variables['Pack.NugetOrg'],'true'), or ( variables['BuildSucceeded'], eq(variables['Pack.BuildFailedOverride'],'true') ) )