Skip to content

Commit ea6c738

Browse files
authored
tests(bucket): Use BuildHelpers EnvVars (#5226)
1 parent e4f9734 commit ea6c738

3 files changed

Lines changed: 6 additions & 17 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
- **unix:** Fix tests in Linux and macOS ([#5179](https://github.com/ScoopInstaller/Scoop/issues/5179))
3434
- **pester:** Update to Pester 5 ([#5222](https://github.com/ScoopInstaller/Scoop/issues/5222))
35+
- **bucket:** Use BuildHelpers' EnvVars ([#5226](https://github.com/ScoopInstaller/Scoop/issues/5226))
3536

3637
### Documentation
3738

test/Import-Bucket-Tests.ps1

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#Requires -Version 5.1
2+
#Requires -Modules @{ ModuleName = 'BuildHelpers'; ModuleVersion = '2.0.1' }
23
#Requires -Modules @{ ModuleName = 'Pester'; ModuleVersion = '5.2.0' }
34
param(
45
[String] $BucketPath = $MyInvocation.PSScriptRoot
@@ -14,18 +15,8 @@ Describe 'Manifest validates against the schema' {
1415
$BucketPath
1516
}
1617
if ($env:CI -eq $true) {
17-
$commit = if ($env:GITHUB_SHA) {
18-
# GitHub Actions
19-
$env:GITHUB_SHA
20-
} elseif ($env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT) {
21-
# AppVeyor
22-
$env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT
23-
} else {
24-
$env:APPVEYOR_REPO_COMMIT
25-
}
26-
if ($commit) {
27-
$changedManifests = @(Get-GitChangedFile -Path $bucketDir -Include '*.json' -Commit $commit)
28-
}
18+
Set-BuildEnvironment -Force
19+
$changedManifests = @(Get-GitChangedFile -Path $bucketDir -Include '*.json' -Commit $env:BHCommitHash)
2920
}
3021
$manifestFiles = (Get-ChildItem $bucketDir -Filter '*.json' -Recurse).FullName
3122
if ($changedManifests) {

test/bin/test.ps1

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,14 @@ if ($env:CI -eq $true) {
2626
Write-Host "Load 'BuildHelpers' environment variables ..."
2727
Set-BuildEnvironment -Force
2828

29-
$commit = $env:BHCommitHash
30-
$commitMessage = $env:BHCommitMessage
31-
3229
# Check if tests are called from the Core itself, if so, adding excludes
3330
if ($TestPath -eq (Convert-Path "$PSScriptRoot\..")) {
34-
if ($commitMessage -match '!linter') {
31+
if ($env:BHCommitMessage -match '!linter') {
3532
Write-Warning "Skipping code linting per commit flag '!linter'"
3633
$excludes += 'Linter'
3734
}
3835

39-
$changedScripts = (Get-GitChangedFile -Include '*.ps1', '*.psd1', '*.psm1' -Commit $commit)
36+
$changedScripts = (Get-GitChangedFile -Include '*.ps1', '*.psd1', '*.psm1' -Commit $env:BHCommitHash)
4037
if (!$changedScripts) {
4138
Write-Warning "Skipping tests and code linting for PowerShell scripts because they didn't change"
4239
$excludes += 'Linter'

0 commit comments

Comments
 (0)