fix(ci): fix xunit test, net48 build isolation, mock server check, Pester config

- Update BaseUrl test to expect trailing slash (matches code change)
- Revert upload-artifact to v4 (v5 doesn't exist yet)
- Build net48 job restores only src/test projects (excludes MockServer)
- MockServer.Tests.ps1: fix net10.0 -> net9.0 DLL paths, fix build check
- Unit tests: use New-PesterConfiguration instead of -CI flag (fixes
  AmbiguousParameterSet on PS 5.1), exclude MockIntegration tag

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Clint Branham
2026-03-18 17:20:39 -05:00
parent b64c34c8cd
commit ec05e52e58
5 changed files with 33 additions and 10 deletions
+6 -2
View File
@@ -16,9 +16,13 @@ jobs:
with:
dotnet-version: '9.0.x'
- name: Restore dependencies
run: dotnet restore
run: |
dotnet restore src/PSProxmoxVE/PSProxmoxVE.csproj
dotnet restore tests/PSProxmoxVE.Core.Tests/PSProxmoxVE.Core.Tests.csproj
- name: Build net48
run: dotnet build --configuration Release --framework net48 --no-restore
run: |
dotnet build src/PSProxmoxVE/PSProxmoxVE.csproj --configuration Release --framework net48 --no-restore
dotnet build tests/PSProxmoxVE.Core.Tests/PSProxmoxVE.Core.Tests.csproj --configuration Release --framework net48 --no-restore
- name: Test net48
run: dotnet test tests/PSProxmoxVE.Core.Tests/PSProxmoxVE.Core.Tests.csproj --configuration Release --framework net48 --no-build --verbosity normal --collect:"XPlat Code Coverage" --results-directory ./coverage
- name: Upload coverage
+1 -1
View File
@@ -217,7 +217,7 @@ jobs:
- name: Upload test results
if: always()
uses: actions/upload-artifact@v5
uses: actions/upload-artifact@v4
with:
name: integration-test-results
path: TestResults/
+18 -2
View File
@@ -93,14 +93,30 @@ jobs:
shell: powershell
run: |
Import-Module Pester -MinimumVersion 5.0
Invoke-Pester tests/PSProxmoxVE.Tests -ExcludeTag Integration -CI -OutputFormat NUnitXml -OutputFile TestResults/pester-results.xml
$config = New-PesterConfiguration
$config.Run.Path = "tests/PSProxmoxVE.Tests"
$config.Run.Exit = $true
$config.Filter.ExcludeTag = @("Integration", "MockIntegration")
$config.Output.Verbosity = "Detailed"
$config.TestResult.Enabled = $true
$config.TestResult.OutputFormat = "NUnitXml"
$config.TestResult.OutputPath = "TestResults/pester-results.xml"
Invoke-Pester -Configuration $config
- name: Run Pester tests (PS 7.x)
if: matrix.ps_version != '5.1'
shell: pwsh
run: |
Import-Module Pester -MinimumVersion 5.0
Invoke-Pester tests/PSProxmoxVE.Tests -ExcludeTag Integration -CI -OutputFormat NUnitXml -OutputFile TestResults/pester-results.xml
$config = New-PesterConfiguration
$config.Run.Path = "tests/PSProxmoxVE.Tests"
$config.Run.Exit = $true
$config.Filter.ExcludeTag = @("Integration", "MockIntegration")
$config.Output.Verbosity = "Detailed"
$config.TestResult.Enabled = $true
$config.TestResult.OutputFormat = "NUnitXml"
$config.TestResult.OutputPath = "TestResults/pester-results.xml"
Invoke-Pester -Configuration $config
- name: Upload test results
if: always()
@@ -42,7 +42,7 @@ namespace PSProxmoxVE.Core.Tests.Authentication
{
var session = new PveSession(TestHostname, TestPort, false, "root@pam!mytoken=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee");
Assert.Equal($"https://{TestHostname}:{TestPort}/api2/json", session.BaseUrl);
Assert.Equal($"https://{TestHostname}:{TestPort}/api2/json/", session.BaseUrl);
}
[Fact]
@@ -20,17 +20,20 @@ BeforeAll {
# Find the built module DLL
$dllSearchPaths = @(
(Join-Path $PSScriptRoot '../../PSProxmoxVE.MockServer/bin/Release/net10.0/PSProxmoxVE.MockServer.dll'),
(Join-Path $PSScriptRoot '../../PSProxmoxVE.MockServer/bin/Debug/net10.0/PSProxmoxVE.MockServer.dll')
(Join-Path $PSScriptRoot '../../PSProxmoxVE.MockServer/bin/Release/net9.0/PSProxmoxVE.MockServer.dll'),
(Join-Path $PSScriptRoot '../../PSProxmoxVE.MockServer/bin/Debug/net9.0/PSProxmoxVE.MockServer.dll')
)
$mockServerDll = $dllSearchPaths | Where-Object { Test-Path $_ } | Select-Object -First 1
if (-not $mockServerDll) {
# Build it
$buildOutput = dotnet build $mockServerProject --configuration Release 2>&1
$buildOutput = dotnet build $mockServerProject --configuration Release 2>&1 | Out-String
if ($LASTEXITCODE -ne 0) {
throw "Failed to build mock server (exit code $LASTEXITCODE): $buildOutput"
}
$mockServerDll = $dllSearchPaths | Where-Object { Test-Path $_ } | Select-Object -First 1
if (-not $mockServerDll) {
throw "Failed to build mock server: $buildOutput"
throw "Mock server build succeeded but DLL not found at expected paths: $($dllSearchPaths -join ', ')"
}
}