Files
PSProxmoxVE/tests/Dockerfile.test
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

37 lines
1.6 KiB
Docker

# Replicates the GitHub Actions CI environment for PS 7.x unit tests
FROM mcr.microsoft.com/powershell:7.5-ubuntu-24.04
# Install .NET SDK 9.0, build module, install Pester, copy to module path
RUN apt-get update && apt-get install -y wget \
&& wget 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 \
&& rm /tmp/dotnet-install.sh \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /repo
COPY . .
RUN dotnet publish src/PSProxmoxVE/PSProxmoxVE.csproj \
--configuration Release --framework net9.0 --output ./publish/net9.0 \
&& rm -f ./publish/net9.0/PSProxmoxVE.deps.json \
&& pwsh -NoProfile -Command ' \
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'
# Unset DOTNET_ROOT so PS uses its own bundled runtime
ENV DOTNET_ROOT=""
ENV DOTNET_MULTILEVEL_LOOKUP=""
CMD ["pwsh", "-NoProfile", "-Command", " \
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'; \
Invoke-Pester -Configuration $config"]