Skip to content

Commit c060792

Browse files
Refactor action.yml to enhance clarity in environment variable usage
1 parent 49257cc commit c060792

File tree

1 file changed

+54
-54
lines changed

1 file changed

+54
-54
lines changed

scripts/tests/SourceCode/PSModule/PSModule.Tests.ps1

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -27,85 +27,85 @@ Param(
2727

2828
BeforeAll {
2929
$scriptFiles = Get-ChildItem -Path $Path -Include *.psm1, *.ps1 -Recurse -File
30-
LogGroup " - Script files [$($scriptFiles.Count)]" {
31-
$scriptFiles | ForEach-Object {
32-
Write-Host " - $($_.FullName)"
33-
}
30+
"::group:: - Script files [$($scriptFiles.Count)]"
31+
$scriptFiles | ForEach-Object {
32+
Write-Host " - $($_.FullName)"
3433
}
34+
'::endgroup::'
3535
$functionsPath = Join-Path -Path $Path -ChildPath 'functions'
3636
$functionFiles = (Test-Path -Path $functionsPath) ? (Get-ChildItem -Path $functionsPath -File -Filter '*.ps1' -Recurse) : $null
37-
LogGroup " - Function files [$($functionFiles.Count)]" {
38-
$functionFiles | ForEach-Object {
39-
Write-Host " - $($_.FullName)"
40-
}
37+
"::group:: - Function files [$($functionFiles.Count)]"
38+
$functionFiles | ForEach-Object {
39+
Write-Host " - $($_.FullName)"
4140
}
41+
'::endgroup::'
4242
$privateFunctionsPath = Join-Path -Path $functionsPath -ChildPath 'private'
4343
$privateFunctionFiles = (Test-Path -Path $privateFunctionsPath) ?
4444
(Get-ChildItem -Path $privateFunctionsPath -File -Filter '*.ps1' -Recurse) : $null
45-
LogGroup " - Private [$($privateFunctionFiles.Count)]" {
46-
$privateFunctionFiles | ForEach-Object {
47-
Write-Host " - $($_.FullName)"
48-
}
45+
"::group:: - Private [$($privateFunctionFiles.Count)]"
46+
$privateFunctionFiles | ForEach-Object {
47+
Write-Host " - $($_.FullName)"
4948
}
49+
'::endgroup::'
5050
$publicFunctionsPath = Join-Path -Path $functionsPath -ChildPath 'public'
5151
$publicFunctionFiles = (Test-Path -Path $publicFunctionsPath) ? (Get-ChildItem -Path $publicFunctionsPath -File -Filter '*.ps1' -Recurse) : $null
52-
LogGroup " - Public [$($publicFunctionFiles.Count)]" {
53-
$publicFunctionFiles | ForEach-Object {
54-
Write-Host " - $($_.FullName)"
55-
}
52+
"::group:: - Public [$($publicFunctionFiles.Count)]"
53+
$publicFunctionFiles | ForEach-Object {
54+
Write-Host " - $($_.FullName)"
5655
}
56+
'::endgroup::'
5757
$variablesPath = Join-Path -Path $Path -ChildPath 'variables'
5858
$variableFiles = (Test-Path -Path $variablesPath) ? (Get-ChildItem -Path $variablesPath -File -Filter '*.ps1' -Recurse) : $null
59-
LogGroup " - Variable files [$($variableFiles.Count)]" {
60-
$variableFiles | ForEach-Object {
61-
Write-Host " - $($_.FullName)"
62-
}
59+
"::group:: - Variable files [$($variableFiles.Count)]"
60+
$variableFiles | ForEach-Object {
61+
Write-Host " - $($_.FullName)"
6362
}
63+
'::endgroup::'
6464
$privateVariablesPath = Join-Path -Path $variablesPath -ChildPath 'private'
6565
$privateVariableFiles = (Test-Path -Path $privateVariablesPath) ?
6666
(Get-ChildItem -Path $privateVariablesPath -File -Filter '*.ps1' -Recurse) : $null
67-
LogGroup " - Private [$($privateVariableFiles.Count)]" {
68-
$privateVariableFiles | ForEach-Object {
69-
Write-Host " - $($_.FullName)"
70-
}
67+
"::group:: - Private [$($privateVariableFiles.Count)]"
68+
$privateVariableFiles | ForEach-Object {
69+
Write-Host " - $($_.FullName)"
7170
}
71+
'::endgroup::'
7272
$publicVariablesPath = Join-Path -Path $variablesPath -ChildPath 'public'
7373
$publicVariableFiles = (Test-Path -Path $publicVariablesPath) ?
7474
(Get-ChildItem -Path $publicVariablesPath -File -Filter '*.ps1' -Recurse) : $null
75-
LogGroup " - Public [$($publicVariableFiles.Count)]" {
76-
$publicVariableFiles | ForEach-Object {
77-
Write-Host " - $($_.FullName)"
78-
}
75+
"::group:: - Public [$($publicVariableFiles.Count)]"
76+
$publicVariableFiles | ForEach-Object {
77+
Write-Host " - $($_.FullName)"
7978
}
79+
'::endgroup::'
8080
$classPath = Join-Path -Path $Path -ChildPath 'classes'
8181
$classFiles = (Test-Path -Path $classPath) ? (Get-ChildItem -Path $classPath -File -Filter '*.ps1' -Recurse) : $null
82-
LogGroup " - Class [$($classFiles.Count)]" {
83-
$classFiles | ForEach-Object {
84-
Write-Host " - $($_.FullName)"
85-
}
82+
"::group:: - Class [$($classFiles.Count)]"
83+
$classFiles | ForEach-Object {
84+
Write-Host " - $($_.FullName)"
8685
}
86+
'::endgroup::'
8787
$privateClassPath = Join-Path -Path $classPath -ChildPath 'private'
8888
$privateClassFiles = (Test-Path -Path $privateClassPath) ?
8989
(Get-ChildItem -Path $privateClassPath -File -Filter '*.ps1' -Recurse) : $null
90-
LogGroup " - Private [$($privateClassFiles.Count)]" {
91-
$privateClassFiles | ForEach-Object {
92-
Write-Host " - $($_.FullName)"
93-
}
90+
"::group:: - Private [$($privateClassFiles.Count)]"
91+
$privateClassFiles | ForEach-Object {
92+
Write-Host " - $($_.FullName)"
9493
}
94+
'::endgroup::'
9595
$publicClassPath = Join-Path -Path $classPath -ChildPath 'public'
9696
$publicClassFiles = (Test-Path -Path $publicClassPath) ?
9797
(Get-ChildItem -Path $publicClassPath -File -Filter '*.ps1' -Recurse) : $null
98-
LogGroup " - Public [$($publicClassFiles.Count)]" {
99-
$publicClassFiles | ForEach-Object {
100-
Write-Host " - $($_.FullName)"
101-
}
98+
"::group:: - Public [$($publicClassFiles.Count)]"
99+
$publicClassFiles | ForEach-Object {
100+
Write-Host " - $($_.FullName)"
102101
}
102+
'::endgroup::'
103103
$testFiles = Get-ChildItem -Path $TestsPath -Include *.Tests.ps1 -Recurse -File
104-
LogGroup " - Test files [$($testFiles.Count)]" {
105-
$testFiles | ForEach-Object {
106-
Write-Host " - $($_.FullName)"
107-
}
104+
"::group:: - Test files [$($testFiles.Count)]"
105+
$testFiles | ForEach-Object {
106+
Write-Host " - $($_.FullName)"
108107
}
108+
'::endgroup::'
109109
}
110110

111111
Describe 'PSModule - SourceCode tests' {
@@ -119,7 +119,7 @@ Describe 'PSModule - SourceCode tests' {
119119
$skipTest = Select-String -Path $filePath -Pattern '#SkipTest:NumberOfProcessors:(?<Reason>.+)' -AllMatches
120120
if ($skipTest.Matches.Count -gt 0) {
121121
$skipReason = $skipTest.Matches.Groups | Where-Object { $_.Name -eq 'Reason' } | Select-Object -ExpandProperty Value
122-
Write-GitHubWarning -Message " - $relativePath - $skipReason" -Title 'Skipping NumberOfProcessors test'
122+
"::warning title=Skipping NumberOfProcessors test:: - $relativePath - $skipReason"
123123
} else {
124124
$issues += " - $($_.Path):L$($_.LineNumber)"
125125
}
@@ -136,7 +136,7 @@ Describe 'PSModule - SourceCode tests' {
136136
$skipTest = Select-String -Path $filePath -Pattern '#SkipTest:Verbose:(?<Reason>.+)' -AllMatches
137137
if ($skipTest.Matches.Count -gt 0) {
138138
$skipReason = $skipTest.Matches.Groups | Where-Object { $_.Name -eq 'Reason' } | Select-Object -ExpandProperty Value
139-
Write-GitHubWarning -Message " - $relativePath - $skipReason" -Title 'Skipping Verbose test'
139+
"::warning title=Skipping Verbose test:: - $relativePath - $skipReason"
140140
} else {
141141
Select-String -Path $filePath -Pattern '\s(-Verbose(?::\$true)?)\b(?!:\$false)' -AllMatches | ForEach-Object {
142142
$issues += " - $relativePath`:L$($_.LineNumber) - $($_.Line)"
@@ -154,7 +154,7 @@ Describe 'PSModule - SourceCode tests' {
154154
$skipTest = Select-String -Path $filePath -Pattern '#SkipTest:OutNull:(?<Reason>.+)' -AllMatches
155155
if ($skipTest.Matches.Count -gt 0) {
156156
$skipReason = $skipTest.Matches.Groups | Where-Object { $_.Name -eq 'Reason' } | Select-Object -ExpandProperty Value
157-
Write-GitHubWarning -Message " - $relativePath - $skipReason" -Title 'Skipping OutNull test'
157+
"::warning title=Skipping OutNull test:: - $relativePath - $skipReason"
158158
} else {
159159
Select-String -Path $filePath -Pattern 'Out-Null' -AllMatches | ForEach-Object {
160160
$issues += " - $relativePath`:L$($_.LineNumber) - $($_.Line)"
@@ -172,7 +172,7 @@ Describe 'PSModule - SourceCode tests' {
172172
$skipTest = Select-String -Path $filePath -Pattern '#SkipTest:NoTernary:(?<Reason>.+)' -AllMatches
173173
if ($skipTest.Matches.Count -gt 0) {
174174
$skipReason = $skipTest.Matches.Groups | Where-Object { $_.Name -eq 'Reason' } | Select-Object -ExpandProperty Value
175-
Write-GitHubWarning -Message " - $relativePath - $skipReason" -Title 'Skipping NoTernary test'
175+
"::warning title=Skipping NoTernary test:: - $relativePath - $skipReason"
176176
} else {
177177
Select-String -Path $filePath -Pattern '(?<!\|)\s+\?\s' -AllMatches | ForEach-Object {
178178
$issues += " - $relativePath`:L$($_.LineNumber) - $($_.Line)"
@@ -190,7 +190,7 @@ Describe 'PSModule - SourceCode tests' {
190190
$skipTest = Select-String -Path $filePath -Pattern '#SkipTest:LowercaseKeywords:(?<Reason>.+)' -AllMatches
191191
if ($skipTest.Matches.Count -gt 0) {
192192
$skipReason = $skipTest.Matches.Groups | Where-Object { $_.Name -eq 'Reason' } | Select-Object -ExpandProperty Value
193-
Write-GitHubWarning -Message " - $relativePath - $skipReason" -Title 'Skipping LowercaseKeywords test'
193+
"::warning title=Skipping LowercaseKeywords test:: - $relativePath - $skipReason"
194194
} else {
195195
$errors = $null
196196
$tokens = $null
@@ -246,7 +246,7 @@ Describe 'PSModule - SourceCode tests' {
246246
$skipTest = Select-String -Path $filePath -Pattern '#SkipTest:FunctionCount:(?<Reason>.+)' -AllMatches
247247
if ($skipTest.Matches.Count -gt 0) {
248248
$skipReason = $skipTest.Matches.Groups | Where-Object { $_.Name -eq 'Reason' } | Select-Object -ExpandProperty Value
249-
Write-GitHubWarning -Message " - $relativePath - $skipReason" -Title 'Skipping FunctionCount test'
249+
"::warning title=Skipping FunctionCount test:: - $relativePath - $skipReason"
250250
} else {
251251
$Ast = [System.Management.Automation.Language.Parser]::ParseFile($filePath, [ref]$null, [ref]$null)
252252
$tokens = $Ast.FindAll( { $args[0] -is [System.Management.Automation.Language.FunctionDefinitionAst] } , $true )
@@ -267,7 +267,7 @@ Describe 'PSModule - SourceCode tests' {
267267
$skipTest = Select-String -Path $filePath -Pattern '#SkipTest:FunctionName:(?<Reason>.+)' -AllMatches
268268
if ($skipTest.Matches.Count -gt 0) {
269269
$skipReason = $skipTest.Matches.Groups | Where-Object { $_.Name -eq 'Reason' } | Select-Object -ExpandProperty Value
270-
Write-GitHubWarning -Message " - $relativePath - $skipReason" -Title 'Skipping FunctionName test'
270+
"::warning title=Skipping FunctionName test:: - $relativePath - $skipReason"
271271
} else {
272272
$Ast = [System.Management.Automation.Language.Parser]::ParseFile($filePath, [ref]$null, [ref]$null)
273273
$tokens = $Ast.FindAll( { $args[0] -is [System.Management.Automation.Language.FunctionDefinitionAst] } , $true )
@@ -288,7 +288,7 @@ Describe 'PSModule - SourceCode tests' {
288288
$skipTest = Select-String -Path $filePath -Pattern '#SkipTest:CmdletBinding:(?<Reason>.+)' -AllMatches
289289
if ($skipTest.Matches.Count -gt 0) {
290290
$skipReason = $skipTest.Matches.Groups | Where-Object { $_.Name -eq 'Reason' } | Select-Object -ExpandProperty Value
291-
Write-GitHubWarning -Message " - $relativePath - $skipReason" -Title 'Skipping CmdletBinding test'
291+
"::warning title=Skipping CmdletBinding test:: - $relativePath - $skipReason"
292292
} else {
293293
$scriptAst = [System.Management.Automation.Language.Parser]::ParseFile($filePath, [ref]$null, [ref]$null)
294294
$tokens = $scriptAst.FindAll({ $true }, $true)
@@ -314,7 +314,7 @@ Describe 'PSModule - SourceCode tests' {
314314
$skipTest = Select-String -Path $filePath -Pattern '#SkipTest:ParamBlock:(?<Reason>.+)' -AllMatches
315315
if ($skipTest.Matches.Count -gt 0) {
316316
$skipReason = $skipTest.Matches.Groups | Where-Object { $_.Name -eq 'Reason' } | Select-Object -ExpandProperty Value
317-
Write-GitHubWarning -Message " - $relativePath - $skipReason" -Title 'Skipping ParamBlock test'
317+
"::warning title=Skipping ParamBlock test:: - $relativePath - $skipReason"
318318
} else {
319319
$scriptAst = [System.Management.Automation.Language.Parser]::ParseFile($filePath, [ref]$null, [ref]$null)
320320
$tokens = $scriptAst.FindAll({ $args[0] -is [System.Management.Automation.Language.ParamBlockAst] }, $true)
@@ -366,7 +366,7 @@ Describe 'PSModule - SourceCode tests' {
366366
$skipTest = Select-String -Path $filePath -Pattern '#SkipTest:FunctionTest:(?<Reason>.+)' -AllMatches
367367
if ($skipTest.Matches.Count -gt 0) {
368368
$skipReason = $skipTest.Matches.Groups | Where-Object { $_.Name -eq 'Reason' } | Select-Object -ExpandProperty Value
369-
Write-GitHubWarning -Message " - $relativePath - $skipReason" -Title 'Skipping FunctionTest test'
369+
"::warning title=Skipping FunctionTest test:: - $relativePath - $skipReason"
370370
} else {
371371
$Ast = [System.Management.Automation.Language.Parser]::ParseFile($filePath, [ref]$null, [ref]$null)
372372
$tokens = $Ast.FindAll( { $args[0] -is [System.Management.Automation.Language.FunctionDefinitionAst] } , $true )

0 commit comments

Comments
 (0)