Skip to content

Commit aa46af5

Browse files
Refactor action.yml to improve environment variable management and enhance readability
1 parent c060792 commit aa46af5

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

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

Lines changed: 32 additions & 32 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-
"::group:: - Script files [$($scriptFiles.Count)]"
30+
Write-Host "::group:: - Script files [$($scriptFiles.Count)]"
3131
$scriptFiles | ForEach-Object {
3232
Write-Host " - $($_.FullName)"
3333
}
34-
'::endgroup::'
34+
Write-Host '::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-
"::group:: - Function files [$($functionFiles.Count)]"
37+
Write-Host "::group:: - Function files [$($functionFiles.Count)]"
3838
$functionFiles | ForEach-Object {
3939
Write-Host " - $($_.FullName)"
4040
}
41-
'::endgroup::'
41+
Write-Host '::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-
"::group:: - Private [$($privateFunctionFiles.Count)]"
45+
Write-Host "::group:: - Private [$($privateFunctionFiles.Count)]"
4646
$privateFunctionFiles | ForEach-Object {
4747
Write-Host " - $($_.FullName)"
4848
}
49-
'::endgroup::'
49+
Write-Host '::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-
"::group:: - Public [$($publicFunctionFiles.Count)]"
52+
Write-Host "::group:: - Public [$($publicFunctionFiles.Count)]"
5353
$publicFunctionFiles | ForEach-Object {
5454
Write-Host " - $($_.FullName)"
5555
}
56-
'::endgroup::'
56+
Write-Host '::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-
"::group:: - Variable files [$($variableFiles.Count)]"
59+
Write-Host "::group:: - Variable files [$($variableFiles.Count)]"
6060
$variableFiles | ForEach-Object {
6161
Write-Host " - $($_.FullName)"
6262
}
63-
'::endgroup::'
63+
Write-Host '::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-
"::group:: - Private [$($privateVariableFiles.Count)]"
67+
Write-Host "::group:: - Private [$($privateVariableFiles.Count)]"
6868
$privateVariableFiles | ForEach-Object {
6969
Write-Host " - $($_.FullName)"
7070
}
71-
'::endgroup::'
71+
Write-Host '::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-
"::group:: - Public [$($publicVariableFiles.Count)]"
75+
Write-Host "::group:: - Public [$($publicVariableFiles.Count)]"
7676
$publicVariableFiles | ForEach-Object {
7777
Write-Host " - $($_.FullName)"
7878
}
79-
'::endgroup::'
79+
Write-Host '::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-
"::group:: - Class [$($classFiles.Count)]"
82+
Write-Host "::group:: - Class [$($classFiles.Count)]"
8383
$classFiles | ForEach-Object {
8484
Write-Host " - $($_.FullName)"
8585
}
86-
'::endgroup::'
86+
Write-Host '::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-
"::group:: - Private [$($privateClassFiles.Count)]"
90+
Write-Host "::group:: - Private [$($privateClassFiles.Count)]"
9191
$privateClassFiles | ForEach-Object {
9292
Write-Host " - $($_.FullName)"
9393
}
94-
'::endgroup::'
94+
Write-Host '::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-
"::group:: - Public [$($publicClassFiles.Count)]"
98+
Write-Host "::group:: - Public [$($publicClassFiles.Count)]"
9999
$publicClassFiles | ForEach-Object {
100100
Write-Host " - $($_.FullName)"
101101
}
102-
'::endgroup::'
102+
Write-Host '::endgroup::'
103103
$testFiles = Get-ChildItem -Path $TestsPath -Include *.Tests.ps1 -Recurse -File
104-
"::group:: - Test files [$($testFiles.Count)]"
104+
Write-Host "::group:: - Test files [$($testFiles.Count)]"
105105
$testFiles | ForEach-Object {
106106
Write-Host " - $($_.FullName)"
107107
}
108-
'::endgroup::'
108+
Write-Host '::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-
"::warning title=Skipping NumberOfProcessors test:: - $relativePath - $skipReason"
122+
Write-Host "::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-
"::warning title=Skipping Verbose test:: - $relativePath - $skipReason"
139+
Write-Host "::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-
"::warning title=Skipping OutNull test:: - $relativePath - $skipReason"
157+
Write-Host "::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-
"::warning title=Skipping NoTernary test:: - $relativePath - $skipReason"
175+
Write-Host "::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-
"::warning title=Skipping LowercaseKeywords test:: - $relativePath - $skipReason"
193+
Write-Host "::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-
"::warning title=Skipping FunctionCount test:: - $relativePath - $skipReason"
249+
Write-Host "::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-
"::warning title=Skipping FunctionName test:: - $relativePath - $skipReason"
270+
Write-Host "::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-
"::warning title=Skipping CmdletBinding test:: - $relativePath - $skipReason"
291+
Write-Host "::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-
"::warning title=Skipping ParamBlock test:: - $relativePath - $skipReason"
317+
Write-Host "::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-
"::warning title=Skipping FunctionTest test:: - $relativePath - $skipReason"
369+
Write-Host "::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)