-
Notifications
You must be signed in to change notification settings - Fork 283
Expand file tree
/
Copy pathtest-cs-steps.yml
More file actions
117 lines (103 loc) · 4.35 KB
/
test-cs-steps.yml
File metadata and controls
117 lines (103 loc) · 4.35 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
111
112
113
114
115
116
117
# Lightweight test-only steps for the C# SDK.
# Builds from source and runs tests — no signing or NuGet packing.
parameters:
- name: version
type: string
- name: isWinML
type: boolean
default: false
- name: flcNugetDir
type: string
displayName: 'Path to directory containing the FLC .nupkg'
steps:
- task: PowerShell@2
displayName: 'Set source paths'
inputs:
targetType: inline
script: |
$repoRoot = "$(Build.SourcesDirectory)/Foundry-Local"
$testDataDir = "$(Build.SourcesDirectory)/test-data-shared"
Write-Host "##vso[task.setvariable variable=repoRoot]$repoRoot"
Write-Host "##vso[task.setvariable variable=testDataDir]$testDataDir"
- task: UseDotNet@2
displayName: 'Use .NET 9 SDK'
inputs:
packageType: sdk
version: '9.0.x'
- task: PowerShell@2
displayName: 'List downloaded FLC artifact'
inputs:
targetType: inline
script: |
Write-Host "Contents of ${{ parameters.flcNugetDir }}:"
Get-ChildItem "${{ parameters.flcNugetDir }}" -Recurse | ForEach-Object { Write-Host $_.FullName }
- ${{ if eq(parameters.isWinML, true) }}:
- task: PowerShell@2
displayName: 'Install Windows App SDK Runtime'
inputs:
targetType: 'inline'
script: |
$installerUrl = "https://aka.ms/windowsappsdk/1.8/latest/windowsappruntimeinstall-x64.exe"
$installerPath = "$env:TEMP\windowsappruntimeinstall.exe"
Write-Host "Downloading Windows App SDK Runtime installer from $installerUrl..."
Invoke-WebRequest -Uri $installerUrl -OutFile $installerPath
Write-Host "Installing Windows App SDK Runtime..."
& $installerPath --quiet --force
if ($LASTEXITCODE -ne 0) {
Write-Error "Installation failed with exit code $LASTEXITCODE"
exit 1
}
Write-Host "Windows App SDK Runtime installed successfully."
errorActionPreference: 'stop'
- task: PowerShell@2
displayName: 'Create NuGet.config with local FLC feed'
inputs:
targetType: inline
script: |
$nugetConfig = @"
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="LocalFLC" value="${{ parameters.flcNugetDir }}" />
<add key="ORT-Nightly" value="https://pkgs.dev.azure.com/aiinfra/PublicPackages/_packaging/ORT-Nightly/nuget/v3/index.json" />
</packageSources>
</configuration>
"@
$nupkg = Get-ChildItem "${{ parameters.flcNugetDir }}" -Recurse -Filter "Microsoft.AI.Foundry.Local.Core*.nupkg" -Exclude "*.snupkg" | Select-Object -First 1
if (-not $nupkg) { throw "No FLC .nupkg found in ${{ parameters.flcNugetDir }}" }
$flcVer = $nupkg.BaseName -replace '^Microsoft\.AI\.Foundry\.Local\.Core(\.WinML)?\.', ''
Write-Host "##vso[task.setvariable variable=resolvedFlcVersion]$flcVer"
$flcFeedDir = $nupkg.DirectoryName
$nugetConfig = $nugetConfig -replace [regex]::Escape("${{ parameters.flcNugetDir }}"), $flcFeedDir
$configPath = "$(Build.ArtifactStagingDirectory)/NuGet.config"
Set-Content -Path $configPath -Value $nugetConfig
Write-Host "##vso[task.setvariable variable=customNugetConfig]$configPath"
- task: NuGetAuthenticate@1
displayName: 'Authenticate NuGet feeds'
- task: PowerShell@2
displayName: 'Restore & build tests'
inputs:
targetType: inline
script: |
dotnet restore "$(repoRoot)/sdk/cs/test/FoundryLocal.Tests/Microsoft.AI.Foundry.Local.Tests.csproj" `
--configfile "$(customNugetConfig)" `
/p:UseWinML=${{ parameters.isWinML }} `
/p:FoundryLocalCoreVersion=$(resolvedFlcVersion)
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
dotnet build "$(repoRoot)/sdk/cs/test/FoundryLocal.Tests/Microsoft.AI.Foundry.Local.Tests.csproj" `
--no-restore --configuration Release `
/p:UseWinML=${{ parameters.isWinML }}
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
- task: PowerShell@2
displayName: 'Run SDK tests'
inputs:
targetType: inline
script: |
dotnet test "$(repoRoot)/sdk/cs/test/FoundryLocal.Tests/Microsoft.AI.Foundry.Local.Tests.csproj" `
--no-build --configuration Release `
/p:UseWinML=${{ parameters.isWinML }}
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
env:
TF_BUILD: 'true'