diff --git a/.github/workflows/build-go-packages.yml b/.github/workflows/build-go-packages.yml index 5108db7..d6b9592 100644 --- a/.github/workflows/build-go-packages.yml +++ b/.github/workflows/build-go-packages.yml @@ -14,6 +14,10 @@ on: env: VERSION: ${{ github.event.inputs.VERSION }} +defaults: + run: + shell: pwsh + jobs: build_go: name: Build Go ${{ github.event.inputs.VERSION }} [${{ matrix.platform }}] @@ -45,9 +49,6 @@ jobs: name: Test Go ${{ github.event.inputs.VERSION }} [${{ matrix.platform }}] needs: build_go runs-on: ${{ matrix.os }} - defaults: - run: - shell: pwsh env: ARTIFACT_NAME: go-${{ github.event.inputs.VERSION }}-${{ matrix.platform }}-x64 strategy: @@ -105,7 +106,7 @@ jobs: - name: Run tests run: | - Install-Module Pester -Force -Scope CurrentUser -RequiredVersion 4.10.1 + Install-Module Pester -Force -Scope CurrentUser Import-Module Pester $pesterParams = @{ Path="./Go.Tests.ps1"; @@ -113,7 +114,7 @@ jobs: Version="$env:VERSION"; } } - Invoke-Pester -Script $pesterParams -EnableExit + Invoke-Pester -Script ./Go.Tests.ps1 -EnableExit working-directory: ./tests publish_release: diff --git a/tests/Go.Tests.ps1 b/tests/Go.Tests.ps1 index d52d522..95fec25 100644 --- a/tests/Go.Tests.ps1 +++ b/tests/Go.Tests.ps1 @@ -1,21 +1,18 @@ -param ( - [version] [Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] - $Version -) - Import-Module (Join-Path $PSScriptRoot "../helpers/pester-extensions.psm1") Import-Module (Join-Path $PSScriptRoot "../helpers/common-helpers.psm1") -function Get-UseGoLogs { - # GitHub Windows images don't have `HOME` variable - $homeDir = $env:HOME ?? $env:HOMEDRIVE - $logsFolderPath = Join-Path -Path $homeDir -ChildPath "runners/*/_diag/pages" -Resolve +BeforeAll { + function Get-UseNodeLogs { + # GitHub Windows images don't have `HOME` variable + $homeDir = $env:HOME ?? $env:HOMEDRIVE + $logsFolderPath = Join-Path -Path $homeDir -ChildPath "runners/*/_diag/pages" -Resolve - $useGoLogFile = Get-ChildItem -Path $logsFolderPath | Where-Object { - $logContent = Get-Content $_.Fullname -Raw - return $logContent -match "setup-go@v" - } | Select-Object -First 1 - return $useGoLogFile.Fullname + $useGoLogFile = Get-ChildItem -Path $logsFolderPath | Where-Object { + $logContent = Get-Content $_.Fullname -Raw + return $logContent -match "setup-go@v" + } | Select-Object -First 1 + return $useGoLogFile.Fullname + } } Describe "Go" { @@ -25,9 +22,9 @@ Describe "Go" { It "version is correct" { $versionOutput = Invoke-Expression -Command "go version" - $finalVersion = $Version.ToString(3) + $finalVersion = $env:VERSION.ToString(3) If ($Version.Build -eq "0"){ - $finalVersion = $Version.ToString(2) + $finalVersion = $env:VERSION.ToString(2) } $versionOutput | Should -Match $finalVersion }