diff --git a/CHANGELOG.md b/CHANGELOG.md index b1e412451..bdb933cfa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ - **unix:** Fix tests in Linux and macOS ([#5179](https://github.com/ScoopInstaller/Scoop/issues/5179)) - **pester:** Update to Pester 5 ([#5222](https://github.com/ScoopInstaller/Scoop/issues/5222)) +- **bucket:** Use BuildHelpers' EnvVars ([#5226](https://github.com/ScoopInstaller/Scoop/issues/5226)) ### Documentation diff --git a/test/Import-Bucket-Tests.ps1 b/test/Import-Bucket-Tests.ps1 index 93cc9e404..789a4b24f 100644 --- a/test/Import-Bucket-Tests.ps1 +++ b/test/Import-Bucket-Tests.ps1 @@ -1,4 +1,5 @@ #Requires -Version 5.1 +#Requires -Modules @{ ModuleName = 'BuildHelpers'; ModuleVersion = '2.0.1' } #Requires -Modules @{ ModuleName = 'Pester'; ModuleVersion = '5.2.0' } param( [String] $BucketPath = $MyInvocation.PSScriptRoot @@ -14,18 +15,8 @@ Describe 'Manifest validates against the schema' { $BucketPath } if ($env:CI -eq $true) { - $commit = if ($env:GITHUB_SHA) { - # GitHub Actions - $env:GITHUB_SHA - } elseif ($env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT) { - # AppVeyor - $env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT - } else { - $env:APPVEYOR_REPO_COMMIT - } - if ($commit) { - $changedManifests = @(Get-GitChangedFile -Path $bucketDir -Include '*.json' -Commit $commit) - } + Set-BuildEnvironment -Force + $changedManifests = @(Get-GitChangedFile -Path $bucketDir -Include '*.json' -Commit $env:BHCommitHash) } $manifestFiles = (Get-ChildItem $bucketDir -Filter '*.json' -Recurse).FullName if ($changedManifests) { diff --git a/test/bin/test.ps1 b/test/bin/test.ps1 index ac07fb9a4..ffb35351a 100644 --- a/test/bin/test.ps1 +++ b/test/bin/test.ps1 @@ -26,17 +26,14 @@ if ($env:CI -eq $true) { Write-Host "Load 'BuildHelpers' environment variables ..." Set-BuildEnvironment -Force - $commit = $env:BHCommitHash - $commitMessage = $env:BHCommitMessage - # Check if tests are called from the Core itself, if so, adding excludes if ($TestPath -eq (Convert-Path "$PSScriptRoot\..")) { - if ($commitMessage -match '!linter') { + if ($env:BHCommitMessage -match '!linter') { Write-Warning "Skipping code linting per commit flag '!linter'" $excludes += 'Linter' } - $changedScripts = (Get-GitChangedFile -Include '*.ps1', '*.psd1', '*.psm1' -Commit $commit) + $changedScripts = (Get-GitChangedFile -Include '*.ps1', '*.psd1', '*.psm1' -Commit $env:BHCommitHash) if (!$changedScripts) { Write-Warning "Skipping tests and code linting for PowerShell scripts because they didn't change" $excludes += 'Linter'