Files
PSProxmoxVE/.github/workflows/unit-tests.yml
T
Clint Branham 558053dc74 chore(ci): move unit tests and build to Docker containers on self-hosted runner
All CI now runs on the self-hosted runner using Docker containers,
eliminating GitHub-hosted runner minute consumption:

- Unit tests: PS 7.5 container (mcr.microsoft.com/powershell:7.5-ubuntu-24.04)
  with .NET SDK 9.0 installed at build time
- Build/xUnit: .NET SDK 9.0 container (mcr.microsoft.com/dotnet/sdk:9.0)
- Integration tests: unchanged (runs directly on self-hosted runner)

Drops net48/PS 5.1 CI matrix (Windows-only, can't run in Linux
containers). Local Docker testing available via tests/Dockerfile.test.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-19 08:56:12 -05:00

68 lines
2.2 KiB
YAML

name: Unit Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
pester-tests:
runs-on: [self-hosted, proxmox, integration]
timeout-minutes: 15
container:
image: mcr.microsoft.com/powershell:7.5-ubuntu-24.04
options: --user root
steps:
- uses: actions/checkout@v5
- name: Install .NET SDK 9.0
run: |
apt-get update && apt-get install -y wget
wget -q https://dot.net/v1/dotnet-install.sh -O /tmp/dotnet-install.sh
chmod +x /tmp/dotnet-install.sh
/tmp/dotnet-install.sh --channel 9.0 --install-dir /usr/share/dotnet
ln -sf /usr/share/dotnet/dotnet /usr/local/bin/dotnet
- name: Build module
run: dotnet publish src/PSProxmoxVE/PSProxmoxVE.csproj --configuration Release --framework net9.0 --output ./publish/net9.0
- name: Remove deps.json from publish output
run: rm -f ./publish/net9.0/PSProxmoxVE.deps.json
- name: Install Pester and deploy module
shell: pwsh
run: |
Install-Module -Name Pester -MinimumVersion 5.0 -Force -Scope AllUsers
$modulePath = "/usr/local/share/powershell/Modules/PSProxmoxVE"
New-Item -ItemType Directory -Path $modulePath -Force | Out-Null
Copy-Item -Path ./publish/net9.0/* -Destination $modulePath -Recurse -Force
- name: Create TestResults directory
run: mkdir -p TestResults
- name: Run Pester tests
shell: pwsh
env:
DOTNET_ROOT: ''
DOTNET_MULTILEVEL_LOOKUP: ''
run: |
Import-Module Pester -MinimumVersion 5.0
$config = New-PesterConfiguration
$config.Run.Path = "tests/PSProxmoxVE.Tests"
$config.Run.Exit = $true
$config.Filter.ExcludeTag = @("Integration")
$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()
uses: actions/upload-artifact@v4
with:
name: pester-results-linux-ps7
path: TestResults/