Skip to content

Commit b3c95e6

Browse files
Match workflow targets case-sensitively
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 26372a1 commit b3c95e6

2 files changed

Lines changed: 16 additions & 9 deletions

File tree

.github/scripts/Get-ProcessPSModuleWorkflowInventory.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ function Get-WorkflowInventoryItem {
504504
Uses = "$uses"
505505
Reference = "$uses".Substring("$ExpectedReference@".Length)
506506
MatchesTarget = if ($ExpectedTargetReference) {
507-
"$uses".Substring("$ExpectedReference@".Length) -eq $ExpectedTargetReference
507+
"$uses".Substring("$ExpectedReference@".Length) -ceq $ExpectedTargetReference
508508
} else {
509509
$null
510510
}

.github/scripts/tests/Get-ProcessPSModuleWorkflowInventory.Tests.ps1

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ permissions:
3939
jobs:
4040
Process-PSModule:
4141
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
42-
uses: PSModule/Process-PSModule/.github/workflows/workflow.yml@0123456789012345678901234567890123456789 # v8.0.0
42+
uses: PSModule/Process-PSModule/.github/workflows/workflow.yml@v8
4343
with:
4444
Debug: true
4545
secrets:
@@ -66,8 +66,8 @@ jobs:
6666
& git -C $repositoryRoot switch --quiet -c feature
6767
$featureContent = Get-Content -LiteralPath (Join-Path $workflowRoot 'Process-PSModule.yml') -Raw
6868
$featureContent.Replace(
69-
'0123456789012345678901234567890123456789',
70-
'ffffffffffffffffffffffffffffffffffffffff'
69+
'workflow.yml@v8',
70+
'workflow.yml@v9'
7171
) |
7272
Set-Content -LiteralPath (Join-Path $workflowRoot 'Process-PSModule.yml')
7373
}
@@ -85,7 +85,7 @@ Describe 'Get-ProcessPSModuleWorkflowInventory' {
8585
$result = @(
8686
& $scriptPath `
8787
-Path $testRoot `
88-
-TargetReference '0123456789012345678901234567890123456789'
88+
-TargetReference 'v8'
8989
)
9090

9191
$result.Count | Should -Be 1
@@ -96,7 +96,7 @@ Describe 'Get-ProcessPSModuleWorkflowInventory' {
9696
$result[0].PullRequestTypes | Should -Be @('opened', 'synchronize')
9797
$result[0].ConcurrencyGroup | Should -Be '${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}'
9898
$result[0].CancelInProgress | Should -BeFalse
99-
$result[0].ProcessJobs[0].Reference | Should -Be '0123456789012345678901234567890123456789'
99+
$result[0].ProcessJobs[0].Reference | Should -Be 'v8'
100100
$result[0].ProcessJobs[0].MatchesTarget | Should -BeTrue
101101
$result[0].MatchesTarget | Should -BeTrue
102102
$result[0].ProcessJobs[0].Condition | Should -Match 'head.repo.full_name'
@@ -108,11 +108,18 @@ Describe 'Get-ProcessPSModuleWorkflowInventory' {
108108
)
109109
}
110110

111+
It 'compares target references case-sensitively' {
112+
$result = @(& $scriptPath -Path $repositoryRoot -TargetReference 'V8')
113+
114+
$result[0].ProcessJobs[0].MatchesTarget | Should -BeFalse
115+
$result[0].MatchesTarget | Should -BeFalse
116+
}
117+
111118
It 'reads the remote default branch instead of feature-worktree changes' {
112119
$result = @(& $scriptPath -Path $repositoryRoot)
113120

114121
$result[0].DefaultBranch | Should -Be 'main'
115-
$result[0].ProcessJobs[0].Reference | Should -Be '0123456789012345678901234567890123456789'
122+
$result[0].ProcessJobs[0].Reference | Should -Be 'v8'
116123
}
117124

118125
It 'writes JSON and Markdown refresh artifacts' {
@@ -121,7 +128,7 @@ Describe 'Get-ProcessPSModuleWorkflowInventory' {
121128

122129
& $scriptPath `
123130
-Path $repositoryRoot `
124-
-TargetReference '0123456789012345678901234567890123456789' `
131+
-TargetReference 'v8' `
125132
-JsonPath $jsonPath `
126133
-MarkdownPath $markdownPath |
127134
Out-Null
@@ -130,7 +137,7 @@ Describe 'Get-ProcessPSModuleWorkflowInventory' {
130137
Test-Path -LiteralPath $markdownPath | Should -BeTrue
131138
(Get-Content -LiteralPath $jsonPath -Raw).TrimStart() | Should -Match '^\['
132139
Get-Content -LiteralPath $markdownPath -Raw | Should -Match 'Example'
133-
Get-Content -LiteralPath $markdownPath -Raw | Should -Match '0123456789012345678901234567890123456789'
140+
Get-Content -LiteralPath $markdownPath -Raw | Should -Match 'v8'
134141
Get-Content -LiteralPath $markdownPath -Raw | Should -Match 'Matching target: 1/1'
135142
}
136143

0 commit comments

Comments
 (0)