diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index ebc8f80aa..000000000 --- a/.appveyor.yml +++ /dev/null @@ -1,27 +0,0 @@ -environment: - matrix: - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 - PSEdition: Core - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - PSEdition: Desktop - - APPVEYOR_BUILD_WORKER_IMAGE: WMF 4 - PSEdition: Desktop - -skip_branch_with_pr: true -build: off - -test_script: - - ps: | - if ( $env:PSEdition -eq 'Desktop' ) { - Set-StrictMode -Version Latest - $global:PesterDebugPreference_ShowFullErrors = $true - Import-Module ./Pester.psd1 - Invoke-Pester -ExcludeTag VersionChecks, StyleRules, Help -EnableExit -OutputFile TestResults.xml -OutputFormat NUnitXml - (New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/${env:APPVEYOR_JOB_ID}", (Join-Path $PWD 'TestResults.xml')) } - - pwsh: | - if ( $env:PSEdition -eq 'Core' ) { - Set-StrictMode -Version Latest - $global:PesterDebugPreference_ShowFullErrors = $true - Import-Module ./Pester.psd1 - Invoke-Pester -ExcludeTag VersionChecks, StyleRules, Help -EnableExit -OutputFile TestResults.xml -OutputFormat NUnitXml - (New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/${env:APPVEYOR_JOB_ID}", (Join-Path $PWD 'TestResults.xml')) } diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..00de00a6d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,55 @@ +# CI for the Pester v4 maintenance branch. Replaces the dead AppVeyor setup. +# +# v4 is in security-fix-only maintenance. We test only Windows PowerShell 5.1 +# and PowerShell 7 — nothing else is guaranteed. The goal is to keep the branch +# releasable: green CI here means a security fix can be validated and shipped +# through the manual release process (release.ps1). +name: CI + +on: + push: + branches: ['rel/4.x.x'] + pull_request: + branches: ['rel/4.x.x'] + workflow_dispatch: + +permissions: + contents: read + +jobs: + test: + name: ${{ matrix.name }} + runs-on: ${{ matrix.os }} + timeout-minutes: 30 + strategy: + fail-fast: false + matrix: + include: + - { name: 'PS5.1 - Windows', id: ps51-windows, os: windows-latest, psexe: powershell } + - { name: 'PS7 - Windows', id: ps7-windows, os: windows-latest, psexe: pwsh } + - { name: 'PS7 - Ubuntu', id: ps7-ubuntu, os: ubuntu-latest, psexe: pwsh } + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 1 + + # Same test invocation AppVeyor used: import the module from the repo + # root and run the suite, excluding the tags that need extra tooling. + # `shell:` cannot take a matrix expression, so run from a fixed pwsh and + # launch the leg's interpreter: pwsh for PS7, powershell (Windows + # PowerShell 5.1) for the 5.1 leg. exit $LASTEXITCODE so a failure in + # the launched process still fails the job. + - name: Test Pester + shell: pwsh + run: | + & ${{ matrix.psexe }} -NoProfile -Command '$PSVersionTable; Set-StrictMode -Version Latest; $global:PesterDebugPreference_ShowFullErrors = $true; Import-Module ./Pester.psd1; Invoke-Pester -ExcludeTag VersionChecks, StyleRules, Help -EnableExit -OutputFile TestResults.xml -OutputFormat NUnitXml' + exit $LASTEXITCODE + + - name: Upload test results + if: always() + uses: actions/upload-artifact@v4 + with: + name: results-${{ matrix.id }} + retention-days: 7 + if-no-files-found: ignore + path: TestResults.xml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index da81af5de..000000000 --- a/.travis.yml +++ /dev/null @@ -1,24 +0,0 @@ -language: generic - -matrix: - include: - - os: osx - osx_image: xcode9.1 - before_install: - # - brew update - # - brew tap caskroom/cask - - brew cask install powershell - - os: linux - dist: trusty - # VM-based builds turned out to be faster - sudo: required - addons: - apt: - sources: - - sourceline: deb [arch=amd64] https://packages.microsoft.com/ubuntu/14.04/prod trusty main - key_url: https://packages.microsoft.com/keys/microsoft.asc - packages: - - powershell - -script: - - pwsh -c 'Set-StrictMode -Version Latest; $global:PesterDebugPreference_ShowFullErrors = $true ;Import-Module ./Pester.psd1; Invoke-Pester -ExcludeTag VersionChecks, StyleRules, Help -EnableExit' diff --git a/Functions/TestDrive.Tests.ps1 b/Functions/TestDrive.Tests.ps1 index 28b6edac7..a505fc8a0 100644 --- a/Functions/TestDrive.Tests.ps1 +++ b/Functions/TestDrive.Tests.ps1 @@ -1,7 +1,11 @@ Set-StrictMode -Version Latest if ($PSVersionTable.PSVersion.Major -lt 6 -or $IsWindows) { - $tempPath = $env:TEMP + # don't use $env:TEMP directly, GitHub Actions runners set it to the 8.3 + # short form (C:\Users\RUNNER~1\...) but TestDrive is created via + # GetTempPath which returns the long form, so the -like comparisons below + # would never match + $tempPath = [System.IO.Path]::GetTempPath() } elseif ($IsMacOS) { $tempPath = '/private/tmp' diff --git a/Functions/TestResults.Tests.ps1 b/Functions/TestResults.Tests.ps1 index fc17c2f1d..60ebe00fd 100644 --- a/Functions/TestResults.Tests.ps1 +++ b/Functions/TestResults.Tests.ps1 @@ -198,7 +198,7 @@ InModuleScope Pester { #create state $TestResults = New-PesterState -Path TestDrive:\ $testResults.EnterTestGroup('Describe #1', 'Describe') - $TestResults.AddTestResult("Successful testcase", 'Passed', (New-TimeSpan -mi 1)) + $TestResults.AddTestResult("Successful testcase", 'Passed', (New-TimeSpan -Minutes 1)) $testResults.LeaveTestGroup('Describe #1', 'Describe') $testResults.EnterTestGroup('Describe #2', 'Describe') $TestResults.AddTestResult("Failed testcase", 'Failed', (New-TimeSpan -Seconds 2)) @@ -352,7 +352,7 @@ InModuleScope Pester { #create state $TestResults = New-PesterState -Path TestDrive:\ $testResults.EnterTestGroup('Describe #1', 'Describe') - $TestResults.AddTestResult("Successful testcase", 'Passed', (New-TimeSpan -mi 1)) + $TestResults.AddTestResult("Successful testcase", 'Passed', (New-TimeSpan -Minutes 1)) $testResults.LeaveTestGroup('Describe #1', 'Describe') $testResults.EnterTestGroup('Describe #2', 'Describe') $TestResults.AddTestResult("Failed testcase", 'Failed', (New-TimeSpan -Seconds 2)) diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index ea9d5531d..000000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,46 +0,0 @@ -trigger: - - rel/4.x.x -pr: - - rel/4.x.x - -resources: - - repo: self - clean: true - fetchDepth: 1 - -jobs: - - job: ps2 - displayName: PowerShell 2 - continueOnError: false - pool: - name: Default - demands: - - ps2 - workspace: - clean: all - timeoutInMinutes: 5 - steps: - - script: | - rem build in 32-bit version of PowerShell 2 because the 64-bit version - rem was butchered and replaced with PowerShell 6 to be able to run the - rem Azure Pipelines agent on Server 2008 R2 with only PowerShell 2 - C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -c "$errorActionPreference = 'stop'; $global:PesterDebugPreference_ShowFullErrors = $true ; try {$PSVersionTable; Set-StrictMode -Version Latest; Import-Module .\Pester.psd1; Invoke-Pester -ExcludeTag VersionChecks, StyleRules, Help -EnableExit} catch { Write-Error $_; exit 9999 }" - exit %errorlevel% - - - job: ps3 - displayName: PowerShell 3 - continueOnError: false - pool: - name: Default - demands: - - ps3 - workspace: - clean: all - timeoutInMinutes: 5 - steps: - - powershell: | - $global:PesterDebugPreference_ShowFullErrors = $true - $errorActionPreference = 'stop' - Set-StrictMode -Version Latest - Import-Module .\Pester.psd1 - Invoke-Pester -ExcludeTag VersionChecks, StyleRules, Help -EnableExit