-
Notifications
You must be signed in to change notification settings - Fork 528
Expand file tree
/
Copy pathUpdateContracts.ps1
More file actions
110 lines (94 loc) · 8.06 KB
/
UpdateContracts.ps1
File metadata and controls
110 lines (94 loc) · 8.06 KB
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
if(!(Test-Path -Path .\Microsoft.Azure.Cosmos)){
Write-Error "Please run script from root of the enlistment"
}
#Run the Cosmos DB SDK GA contract tests
dotnet test '.\Microsoft.Azure.Cosmos\tests\Microsoft.Azure.Cosmos.Tests\Microsoft.Azure.Cosmos.Tests.csproj' --filter "TestCategory=UpdateContract" --configuration Release -f net6.0
$updatedContractFile = ".\Microsoft.Azure.Cosmos\tests\Microsoft.Azure.Cosmos.Tests\bin\Release\net6.0\Contracts\DotNetSDKAPIChanges.net6.json"
if(!(Test-Path -Path $updatedContractFile)){
Write-Error ("The contract file did not get updated with the build. Please fix the test to output the contract file: " + $updatedContractFile)
}else{
Copy-Item -Path $updatedContractFile -Destination ".\Microsoft.Azure.Cosmos\tests\Microsoft.Azure.Cosmos.Tests\Contracts\DotNetSDKAPI.net6.json"
Write-Output ("Updated contract " + $updatedContractFile)
}
$updatedContractFile = ".\Microsoft.Azure.Cosmos\tests\Microsoft.Azure.Cosmos.Tests\bin\Release\net6.0\Contracts\DotNetSDKTelemetryAPIChanges.net6.json"
if(!(Test-Path -Path $updatedContractFile)){
Write-Error ("The contract file did not get updated with the build. Please fix the test to output the contract file: " + $updatedContractFile)
}else{
Copy-Item -Path $updatedContractFile -Destination ".\Microsoft.Azure.Cosmos\tests\Microsoft.Azure.Cosmos.Tests\Contracts\DotNetSDKTelemetryAPI.net6.json"
Write-Output ("Updated contract " + $updatedContractFile)
}
$updatedContractFolder = ".\Microsoft.Azure.Cosmos\tests\Microsoft.Azure.Cosmos.Tests\bin\Release\net6.0\BaselineTest\TestOutput\*"
if(!(Test-Path -Path $updatedContractFolder)){
Write-Error ("The contract file did not get updated with the build. Please fix the test to output the contract file: " + $updatedContractFile)
}else{
Copy-Item -Path $updatedContractFolder -Destination ".\Microsoft.Azure.Cosmos\tests\Microsoft.Azure.Cosmos.Tests\BaselineTest\TestBaseline" -Recurse
Write-Output ("Updated contract " + $updatedContractFolder)
}
#Run the Cosmos DB SDK Emulator contract tests
dotnet test '.\Microsoft.Azure.Cosmos\tests\Microsoft.Azure.Cosmos.EmulatorTests\Microsoft.Azure.Cosmos.EmulatorTests.csproj' --filter "TestCategory=UpdateContract" --configuration Release -f net6.0
$updatedContractFolder = ".\Microsoft.Azure.Cosmos\tests\Microsoft.Azure.Cosmos.EmulatorTests\bin\Release\net6.0\BaselineTest\TestOutput\*"
if(!(Test-Path -Path $updatedContractFolder)){
Write-Error ("The contract file did not get updated with the build. Please fix the test to output the contract file: " + $updatedContractFile)
}else{
Copy-Item -Path $updatedContractFolder -Destination ".\Microsoft.Azure.Cosmos\tests\Microsoft.Azure.Cosmos.EmulatorTests\BaselineTest\TestBaseline" -Recurse
Write-Output ("Updated contract " + $updatedContractFolder)
}
#Run the Cosmos DB SDK Preview contract tests
dotnet test '.\Microsoft.Azure.Cosmos\tests\Microsoft.Azure.Cosmos.Tests\Microsoft.Azure.Cosmos.Tests.csproj' --filter "TestCategory=UpdateContract" --configuration Release -p:IsPreview=true -f net6.0
$updatedContractFile = ".\Microsoft.Azure.Cosmos\tests\Microsoft.Azure.Cosmos.Tests\bin\Release\net6.0\Contracts\DotNetPreviewSDKAPIChanges.net6.json"
if(!(Test-Path -Path $updatedContractFile)){
Write-Error ("The contract file did not get updated with the preview build. Please fix the test to output the contract file: " + $updatedContractFile)
}else{
Copy-Item -Path $updatedContractFile -Destination ".\Microsoft.Azure.Cosmos\tests\Microsoft.Azure.Cosmos.Tests\Contracts\DotNetPreviewSDKAPI.net6.json"
Write-Output ("Updated contract " + $updatedContractFile)
}
#Run the Encryption SDK contract tests
dotnet test '.\Microsoft.Azure.Cosmos.Encryption\tests\Microsoft.Azure.Cosmos.Encryption.Tests\Microsoft.Azure.Cosmos.Encryption.Tests.csproj' --filter "TestCategory=UpdateContract" --configuration Release -f net6.0
$updatedContractFile = ".\Microsoft.Azure.Cosmos.Encryption\tests\Microsoft.Azure.Cosmos.Encryption.Tests\bin\Release\net6.0\Contracts\DotNetSDKEncryptionAPIChanges.net6.json"
if(!(Test-Path -Path $updatedContractFile)){
Write-Error ("The contract file did not get updated with the build. Please fix the test to output the contract file: " + $updatedContractFile)
}else{
Copy-Item -Path $updatedContractFile -Destination ".\Microsoft.Azure.Cosmos.Encryption\tests\Microsoft.Azure.Cosmos.Encryption.Tests\Contracts\DotNetSDKEncryptionAPI.net6.json"
Write-Output ("Updated contract " + $updatedContractFile)
}
try {
dotnet test '.\Microsoft.Azure.Cosmos.Encryption\tests\Microsoft.Azure.Cosmos.Encryption.Tests\Microsoft.Azure.Cosmos.Encryption.Tests.csproj' --filter "TestCategory=UpdateContract" --configuration Release -f net8.0
$updatedContractFileNet8 = ".\Microsoft.Azure.Cosmos.Encryption\tests\Microsoft.Azure.Cosmos.Encryption.Tests\bin\Release\net8.0\Contracts\DotNetSDKEncryptionAPIChanges.net8.json"
if (Test-Path -Path $updatedContractFileNet8) {
Copy-Item -Path $updatedContractFileNet8 -Destination ".\Microsoft.Azure.Cosmos.Encryption\tests\Microsoft.Azure.Cosmos.Encryption.Tests\Contracts\DotNetSDKEncryptionAPI.net8.json"
Write-Output ("Updated .NET 8 contract " + $updatedContractFileNet8)
# Also copy to Debug output directories so tests work in both configurations
$debugNet8Path = ".\Microsoft.Azure.Cosmos.Encryption\tests\Microsoft.Azure.Cosmos.Encryption.Tests\bin\Debug\net8.0\Contracts\DotNetSDKEncryptionAPI.net8.json"
if (Test-Path -Path (Split-Path $debugNet8Path)) {
Copy-Item -Path $updatedContractFileNet8 -Destination $debugNet8Path -Force
}
}
} catch {
Write-Warning "Unable to run net8.0 Encryption tests to produce .NET 8 baseline. Skipping."
}
#Run the Encryption.Custom SDK contract tests
dotnet test '.\Microsoft.Azure.Cosmos.Encryption.Custom\tests\Microsoft.Azure.Cosmos.Encryption.Custom.Tests\Microsoft.Azure.Cosmos.Encryption.Custom.Tests.csproj' --filter "TestCategory=UpdateContract" --configuration Release -f net6.0
$updatedContractFile = ".\Microsoft.Azure.Cosmos.Encryption.Custom\tests\Microsoft.Azure.Cosmos.Encryption.Custom.Tests\bin\Release\net6.0\Contracts\DotNetSDKEncryptionCustomAPIChanges.net6.json"
if(!(Test-Path -Path $updatedContractFile)){
Write-Error ("The contract file did not get updated with the build. Please fix the test to output the contract file: " + $updatedContractFile)
}else{
Copy-Item -Path $updatedContractFile -Destination ".\Microsoft.Azure.Cosmos.Encryption.Custom\tests\Microsoft.Azure.Cosmos.Encryption.Custom.Tests\Contracts\DotNetSDKEncryptionCustomAPI.net6.json"
Write-Output ("Updated contract " + $updatedContractFile)
}
# Try to generate and copy .NET 8 specific baselines if net8 target exists
try {
dotnet test '.\Microsoft.Azure.Cosmos.Encryption.Custom\tests\Microsoft.Azure.Cosmos.Encryption.Custom.Tests\Microsoft.Azure.Cosmos.Encryption.Custom.Tests.csproj' --filter "TestCategory=UpdateContract" --configuration Release -f net8.0
# .NET 8 test now generates a framework-specific breaking changes file
$updatedContractFileNet8 = ".\Microsoft.Azure.Cosmos.Encryption.Custom\tests\Microsoft.Azure.Cosmos.Encryption.Custom.Tests\bin\Release\net8.0\Contracts\DotNetSDKEncryptionCustomAPIChanges.net8.json"
if (Test-Path -Path $updatedContractFileNet8) {
Copy-Item -Path $updatedContractFileNet8 -Destination ".\Microsoft.Azure.Cosmos.Encryption.Custom\tests\Microsoft.Azure.Cosmos.Encryption.Custom.Tests\Contracts\DotNetSDKEncryptionCustomAPI.net8.json"
Write-Output ("Updated .NET 8 contract " + $updatedContractFileNet8)
# Also copy to Debug output directories so tests work in both configurations
$debugNet8Path = ".\Microsoft.Azure.Cosmos.Encryption.Custom\tests\Microsoft.Azure.Cosmos.Encryption.Custom.Tests\bin\Debug\net8.0\Contracts\DotNetSDKEncryptionCustomAPI.net8.json"
if (Test-Path -Path (Split-Path $debugNet8Path)) {
Copy-Item -Path $updatedContractFileNet8 -Destination $debugNet8Path -Force
}
}
} catch {
Write-Warning "Unable to run net8.0 Encryption.Custom tests to produce .NET 8 baseline. Skipping."
}