mirror of
https://github.com/GoodOlClint/PSProxmoxVE.git
synced 2026-08-12 07:16:51 +00:00
b64c34c8cd
- Change test projects from net10.0 to net9.0 to match source projects - Update build workflow from net8.0 to net9.0 - Upgrade checkout to v5, setup-dotnet to v5 across all workflows - Remove outdated PS 7.2 test matrix entries - Restructure integration tests: create test keeps VM alive so start/stop, snapshot, and cloud-init tests can use it instead of skipping. AfterAll handles cleanup. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
111 lines
3.8 KiB
YAML
111 lines
3.8 KiB
YAML
name: Unit Tests
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
pull_request:
|
|
branches: [ main ]
|
|
|
|
jobs:
|
|
pester-tests:
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- os: windows-latest
|
|
ps_version: '5.1'
|
|
framework: net48
|
|
shell: powershell
|
|
- os: windows-latest
|
|
ps_version: '7.5'
|
|
framework: net9.0
|
|
shell: pwsh
|
|
- os: ubuntu-latest
|
|
ps_version: '7.5'
|
|
framework: net9.0
|
|
shell: pwsh
|
|
- os: macos-latest
|
|
ps_version: '7.5'
|
|
framework: net9.0
|
|
shell: pwsh
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
|
|
- name: Setup .NET
|
|
uses: actions/setup-dotnet@v5
|
|
with:
|
|
dotnet-version: '9.0.x'
|
|
|
|
- name: Build module
|
|
run: dotnet publish src/PSProxmoxVE/PSProxmoxVE.csproj --configuration Release --framework ${{ matrix.framework }} --output ./publish/${{ matrix.framework }}
|
|
|
|
- name: Install Pester 5 (PS 5.1)
|
|
if: matrix.ps_version == '5.1'
|
|
shell: powershell
|
|
run: |
|
|
Install-Module -Name Pester -MinimumVersion 5.0 -Force -Scope CurrentUser -SkipPublisherCheck
|
|
|
|
- name: Install Pester 5 (PS 7.x)
|
|
if: matrix.ps_version != '5.1'
|
|
shell: pwsh
|
|
run: |
|
|
Install-Module -Name Pester -MinimumVersion 5.0 -Force -Scope CurrentUser
|
|
|
|
- name: Copy module to module path (PS 5.1)
|
|
if: matrix.ps_version == '5.1'
|
|
shell: powershell
|
|
run: |
|
|
$modulePath = "$env:USERPROFILE\Documents\WindowsPowerShell\Modules\PSProxmoxVE"
|
|
New-Item -ItemType Directory -Path $modulePath -Force | Out-Null
|
|
Copy-Item -Path .\publish\${{ matrix.framework }}\* -Destination $modulePath -Recurse -Force
|
|
|
|
- name: Copy module to module path (PS 7.x, Windows)
|
|
if: matrix.ps_version != '5.1' && matrix.os == 'windows-latest'
|
|
shell: pwsh
|
|
run: |
|
|
$modulePath = "$env:USERPROFILE\Documents\PowerShell\Modules\PSProxmoxVE"
|
|
New-Item -ItemType Directory -Path $modulePath -Force | Out-Null
|
|
Copy-Item -Path .\publish\${{ matrix.framework }}\* -Destination $modulePath -Recurse -Force
|
|
|
|
- name: Copy module to module path (PS 7.x, non-Windows)
|
|
if: matrix.ps_version != '5.1' && matrix.os != 'windows-latest'
|
|
shell: pwsh
|
|
run: |
|
|
$modulePath = "$HOME/.local/share/powershell/Modules/PSProxmoxVE"
|
|
New-Item -ItemType Directory -Path $modulePath -Force | Out-Null
|
|
Copy-Item -Path ./publish/${{ matrix.framework }}/* -Destination $modulePath -Recurse -Force
|
|
|
|
- name: Create TestResults directory (PS 5.1)
|
|
if: matrix.ps_version == '5.1'
|
|
shell: powershell
|
|
run: New-Item -ItemType Directory -Path TestResults -Force | Out-Null
|
|
|
|
- name: Create TestResults directory (PS 7.x)
|
|
if: matrix.ps_version != '5.1'
|
|
shell: pwsh
|
|
run: New-Item -ItemType Directory -Path TestResults -Force | Out-Null
|
|
|
|
- name: Run Pester tests (PS 5.1)
|
|
if: matrix.ps_version == '5.1'
|
|
shell: powershell
|
|
run: |
|
|
Import-Module Pester -MinimumVersion 5.0
|
|
Invoke-Pester tests/PSProxmoxVE.Tests -ExcludeTag Integration -CI -OutputFormat NUnitXml -OutputFile TestResults/pester-results.xml
|
|
|
|
- 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
|
|
|
|
- name: Upload test results
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: pester-results-${{ matrix.os }}-ps${{ matrix.ps_version }}
|
|
path: TestResults/
|