From 133a2c6b96ed9847a78ba2e93c353c911319a0b7 Mon Sep 17 00:00:00 2001 From: Mikhail Koliada Date: Fri, 21 Jan 2022 12:43:03 +0300 Subject: [PATCH 1/3] Migrate build pipeline to Pester v5 --- .github/workflows/python-builder.yml | 9 +++---- tests/python-tests.ps1 | 40 +++++++++++++++------------- 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/.github/workflows/python-builder.yml b/.github/workflows/python-builder.yml index 5d7b2a7..a111f4a 100644 --- a/.github/workflows/python-builder.yml +++ b/.github/workflows/python-builder.yml @@ -146,16 +146,13 @@ jobs: - name: Run tests run: | - Install-Module Pester -Force -Scope CurrentUser -RequiredVersion 4.10.1 + Install-Module Pester -Force -Scope CurrentUser -RequiredVersion 5.3.1 Import-Module Pester - $pesterParams = @{ - Path="./python-tests.ps1"; - Parameters=@{ + $pesterContainer = New-PesterContainer -Path './python-tests.ps1' -Data @{ Version="${{ env.VERSION }}"; Platform="${{ matrix.platform }}"; - } } - $Result = Invoke-Pester -PassThru -Script $pesterParams + Invoke-Pester -Container $pesterContainer -PassThru if ($Result.FailedCount -gt 0) { $host.SetShouldExit($Result.FailedCount) exit $Result.FailedCount diff --git a/tests/python-tests.ps1 b/tests/python-tests.ps1 index d18c7be..2ec4016 100644 --- a/tests/python-tests.ps1 +++ b/tests/python-tests.ps1 @@ -9,29 +9,31 @@ Import-Module (Join-Path $PSScriptRoot "../helpers/pester-extensions.psm1") Import-Module (Join-Path $PSScriptRoot "../helpers/common-helpers.psm1") Import-Module (Join-Path $PSScriptRoot "../builders/python-version.psm1") -function Analyze-MissingModules([string] $buildOutputLocation) { - $searchStringStart = "Failed to build these modules:" - $searchStringEnd = "running build_scripts" - $pattern = "$searchStringStart(.*?)$searchStringEnd" +BeforeAll { + function Analyze-MissingModules([string] $buildOutputLocation) { + $searchStringStart = "Failed to build these modules:" + $searchStringEnd = "running build_scripts" + $pattern = "$searchStringStart(.*?)$searchStringEnd" - $buildContent = Get-Content -Path $buildOutputLocation - $splitBuiltOutput = $buildContent -split "\n"; + $buildContent = Get-Content -Path $buildOutputLocation + $splitBuiltOutput = $buildContent -split "\n"; - ### Search for missing modules that are displayed between the search strings - $regexMatch = [regex]::match($SplitBuiltOutput, $Pattern) - if ($regexMatch.Success) - { - $module = $regexMatch.Groups[1].Value.Trim() - Write-Host "Failed missing modules:" - Write-Host $module - if ( ($module -eq "_tkinter") -and ( [semver]"$($Version.Major).$($Version.Minor)" -ge [semver]"3.10" -and $Version.PreReleaseLabel ) ) { - Write-Host "$module $Version ignored" - } else { - return 1 + ### Search for missing modules that are displayed between the search strings + $regexMatch = [regex]::match($SplitBuiltOutput, $Pattern) + if ($regexMatch.Success) + { + $module = $regexMatch.Groups[1].Value.Trim() + Write-Host "Failed missing modules:" + Write-Host $module + if ( ($module -eq "_tkinter") -and ( [semver]"$($Version.Major).$($Version.Minor)" -ge [semver]"3.10" -and $Version.PreReleaseLabel ) ) { + Write-Host "$module $Version ignored" + } else { + return 1 + } } - } - return 0 + return 0 + } } Describe "Tests" { From 811f1bc41aec6d0d727b2d93846b357f83fc43f8 Mon Sep 17 00:00:00 2001 From: Mikhail Koliada Date: Fri, 21 Jan 2022 13:26:46 +0300 Subject: [PATCH 2/3] install latest pester --- .github/workflows/python-builder.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-builder.yml b/.github/workflows/python-builder.yml index a111f4a..fbd004b 100644 --- a/.github/workflows/python-builder.yml +++ b/.github/workflows/python-builder.yml @@ -146,7 +146,7 @@ jobs: - name: Run tests run: | - Install-Module Pester -Force -Scope CurrentUser -RequiredVersion 5.3.1 + Install-Module Pester -Force -Scope CurrentUser Import-Module Pester $pesterContainer = New-PesterContainer -Path './python-tests.ps1' -Data @{ Version="${{ env.VERSION }}"; From 135879dbe31863f80bfc862d224a386efc25f863 Mon Sep 17 00:00:00 2001 From: Mikhail Koliada <88318005+mikhailkoliada@users.noreply.github.com> Date: Mon, 24 Jan 2022 19:38:52 +0300 Subject: [PATCH 3/3] assign results to a var --- .github/workflows/python-builder.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-builder.yml b/.github/workflows/python-builder.yml index fbd004b..028324b 100644 --- a/.github/workflows/python-builder.yml +++ b/.github/workflows/python-builder.yml @@ -152,7 +152,7 @@ jobs: Version="${{ env.VERSION }}"; Platform="${{ matrix.platform }}"; } - Invoke-Pester -Container $pesterContainer -PassThru + $Result = Invoke-Pester -Container $pesterContainer -PassThru if ($Result.FailedCount -gt 0) { $host.SetShouldExit($Result.FailedCount) exit $Result.FailedCount