File tree Expand file tree Collapse file tree 6 files changed +38
-13
lines changed
Expand file tree Collapse file tree 6 files changed +38
-13
lines changed Original file line number Diff line number Diff line change @@ -5,13 +5,22 @@ run-name: "Action-Test - [${{ github.event.pull_request.title }} #${{ github.eve
55on : [pull_request]
66
77jobs :
8- ActionTestSrc :
8+ ActionTest :
99 strategy :
1010 fail-fast : false
1111 matrix :
12+ shell : [pwsh]
13+ os : [ubuntu-latest, macos-latest, windows-latest]
1214 path : [tests/src, tests/outputs/modules]
13- name : Action-Test - [${{ matrix.path }}]
14- runs-on : ubuntu-latest
15+ include :
16+ - shell : powershell
17+ os : windows-latest
18+ path : tests/src
19+ - shell : powershell
20+ os : windows-latest
21+ path : tests/outputs/modules
22+ name : Action-Test - [${{ matrix.os }}@${{ matrix.shell }}] - [${{ matrix.path }}]
23+ runs-on : ${{ matrix.os }}
1524 steps :
1625 - name : Checkout repo
1726 uses : actions/checkout@v4
2433
2534 - name : Initialize environment
2635 uses : PSModule/Initialize-PSModule@main
36+ with :
37+ Shell : ${{ matrix.shell }}
2738
2839 - name : Action-Test
2940 uses : ./
3243 with :
3344 Name : PSModule
3445 Path : ${{ matrix.path }}
46+ Shell : ${{ matrix.shell }}
Original file line number Diff line number Diff line change 9090| ` Name ` | The name of the module to test. The name of the repository is used if not specified. | ` false ` | |
9191| ` Path ` | The path to the module to test. | ` true ` | |
9292| ` RunModuleTests ` | Run the module tests. | ` false ` | ` true ` |
93+ | ` Shell ` | The shell to use for running the tests. | ` false ` | ` pwsh ` |
9394
9495## PSModule tests
9596
Original file line number Diff line number Diff line change @@ -16,12 +16,16 @@ inputs:
1616 description : Run the module tests.
1717 required : false
1818 default : ' true'
19+ Shell :
20+ description : The shell to use for running the tests.
21+ required : false
22+ default : pwsh
1923
2024runs :
2125 using : composite
2226 steps :
2327 - name : Run Test-PSModule
24- shell : pwsh
28+ shell : ${{ inputs.Shell }}
2529 env :
2630 GITHUB_ACTION_INPUT_Name : ${{ inputs.Name }}
2731 GITHUB_ACTION_INPUT_Path : ${{ inputs.Path }}
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ function Test-PSModule {
3434 # region Add test - Common - PSScriptAnalyzer
3535 Start-LogGroup ' Add test - Common - PSScriptAnalyzer'
3636 $containers = @ ()
37- $PSSATestsPath = Join-Path - Path $env: GITHUB_ACTION_PATH - ChildPath ' scripts' ' tests' ' PSScriptAnalyzer'
37+ $PSSATestsPath = Join-Path - Path $env: GITHUB_ACTION_PATH - ChildPath ' scripts\ tests\ PSScriptAnalyzer'
3838 $containerParams = @ {
3939 Path = Join-Path $PSSATestsPath ' PSScriptAnalyzer.Tests.ps1'
4040 Data = @ {
@@ -50,7 +50,7 @@ function Test-PSModule {
5050
5151 # region Add test - Common - PSModule
5252 Start-LogGroup ' Add test - Common - PSModule'
53- $PSModuleTestsPath = Join-Path - Path $env: GITHUB_ACTION_PATH - ChildPath ' scripts' ' tests' ' PSModule'
53+ $PSModuleTestsPath = Join-Path - Path $env: GITHUB_ACTION_PATH - ChildPath ' scripts\ tests\ PSModule'
5454 $containerParams = @ {
5555 Path = $PSModuleTestsPath
5656 Data = @ {
@@ -90,8 +90,8 @@ function Test-PSModule {
9090 if ((Test-Path - Path $moduleTestsPath ) -and $RunModuleTests ) {
9191 Start-LogGroup " Importing module: $moduleName "
9292 Add-PSModulePath - Path (Split-Path $Path - Parent)
93- Remove -Module - Name $moduleName - ErrorAction SilentlyContinue - Force
94- Import-Module $Path - Force
93+ Get -Module - Name $moduleName - ListAvailable | Remove-Module - Force - Verbose: $false
94+ Import-Module - Name $moduleName - Force
9595 Stop-LogGroup
9696 }
9797 # endregion
Original file line number Diff line number Diff line change 44param ()
55
66Start-LogGroup ' Loading helper scripts'
7- Get-ChildItem - Path (Join-Path - Path $env: GITHUB_ACTION_PATH - ChildPath ' scripts' ' helpers' ) - Filter ' *.ps1' - Recurse |
7+ Get-ChildItem - Path (Join-Path - Path $env: GITHUB_ACTION_PATH - ChildPath ' scripts\ helpers' ) - Filter ' *.ps1' - Recurse |
88 ForEach-Object { Write-Verbose " [$ ( $_.FullName ) ]" ; . $_.FullName }
99Stop-LogGroup
1010
1111Start-LogGroup ' Loading inputs'
12- $moduleName = ($env: GITHUB_ACTION_INPUT_Name | IsNullOrEmpty) ? $env: GITHUB_REPOSITORY_NAME : $env: GITHUB_ACTION_INPUT_Name
12+ $moduleName = if ($env: GITHUB_ACTION_INPUT_Name | IsNullOrEmpty) { $env: GITHUB_REPOSITORY_NAME } else { $env: GITHUB_ACTION_INPUT_Name }
1313Write-Verbose " Module name: [$moduleName ]"
1414
15- $codeToTest = Join-Path - Path $env: GITHUB_WORKSPACE - ChildPath $env: GITHUB_ACTION_INPUT_Path $moduleName
15+ $codeToTest = Join-Path - Path $env: GITHUB_WORKSPACE - ChildPath " $env: GITHUB_ACTION_INPUT_Path \ $moduleName "
1616Write-Verbose " Code to test: [$codeToTest ]"
1717if (-not (Test-Path - Path $codeToTest )) {
1818 throw " Path [$codeToTest ] does not exist."
@@ -23,7 +23,7 @@ Write-Verbose "Run module tests: [$runModuleTests]"
2323Stop-LogGroup
2424
2525$params = @ {
26- Path = $codeToTest
26+ Path = $codeToTest
2727 RunModuleTests = $runModuleTests
2828}
2929$results = Test-PSModule @params
Original file line number Diff line number Diff line change @@ -20,7 +20,15 @@ Param(
2020)
2121
2222BeforeDiscovery {
23- $rules = Get-ScriptAnalyzerRule | Sort-Object - Property Severity | ConvertTo-Json | ConvertFrom-Json - AsHashtable
23+ $rules = @ ()
24+ $ruleObjects = Get-ScriptAnalyzerRule | Sort-Object - Property Severity
25+ foreach ($ruleObject in $ruleObjects ) {
26+ $hashTable = @ {}
27+ foreach ($property in $ruleObject.PSObject.Properties ) {
28+ $hashTable [$property.Name ] = $property.Value
29+ }
30+ $rules += $hashTable
31+ }
2432 Write-Warning " Discovered [$ ( $rules.Count ) ] rules"
2533 $relativeSettingsFilePath = $SettingsFilePath.Replace ($PSScriptRoot , ' ' ).Trim(' \' ).Trim(' /' )
2634}
You can’t perform that action at this time.
0 commit comments