Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
test
  • Loading branch information
MariusStorhaug committed Aug 19, 2024
commit 7d2b62df8f3ebff29bba7599e23be4d6fa498e3b
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ runs:
$passed = . "${{ github.action_path }}\scripts\main.ps1" -Verbose
"passed=$passed" | Out-File -FilePath $env:GITHUB_OUTPUT -Append

Write-Host "Passed: [$passed]"

if (-not $passed) {
exit 1
}
Expand Down
45 changes: 22 additions & 23 deletions scripts/main.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,40 @@ LogGroup "Loading helper scripts from [$path]" {
}
}

Start-LogGroup 'Loading inputs'
$moduleName = if ($env:GITHUB_ACTION_INPUT_Name | IsNullOrEmpty) { $env:GITHUB_REPOSITORY_NAME } else { $env:GITHUB_ACTION_INPUT_Name }
Write-Verbose "Module name: [$moduleName]"
LogGroup 'Loading inputs' {
$moduleName = if ($env:GITHUB_ACTION_INPUT_Name | IsNullOrEmpty) { $env:GITHUB_REPOSITORY_NAME } else { $env:GITHUB_ACTION_INPUT_Name }
Write-Verbose "Module name: [$moduleName]"

$codeToTest = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath "$env:GITHUB_ACTION_INPUT_Path\$moduleName"
if (Test-Path -Path $codeToTest) {
Write-Verbose "Code to test: [$codeToTest]"
} else {
$codeToTest = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath $env:GITHUB_ACTION_INPUT_Path
}

$codeToTest = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath "$env:GITHUB_ACTION_INPUT_Path\$moduleName"
if (Test-Path -Path $codeToTest) {
Write-Verbose "Code to test: [$codeToTest]"
} else {
$codeToTest = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath $env:GITHUB_ACTION_INPUT_Path
}

Write-Verbose "Code to test: [$codeToTest]"
if (-not (Test-Path -Path $codeToTest)) {
throw "Path [$codeToTest] does not exist."
}
Write-Verbose "Test type to run: [$env:GITHUB_ACTION_INPUT_TestType]"
if (-not (Test-Path -Path $codeToTest)) {
throw "Path [$codeToTest] does not exist."
}
Write-Verbose "Test type to run: [$env:GITHUB_ACTION_INPUT_TestType]"

$testsPath = $env:GITHUB_ACTION_INPUT_TestsPath
Write-Verbose "Path to tests: [$testsPath]"
if (-not (Test-Path -Path $testsPath)) {
throw "Path [$testsPath] does not exist."
$testsPath = $env:GITHUB_ACTION_INPUT_TestsPath
Write-Verbose "Path to tests: [$testsPath]"
if (-not (Test-Path -Path $testsPath)) {
throw "Path [$testsPath] does not exist."
}
}

Stop-LogGroup

$params = @{
Path = $codeToTest
TestType = $env:GITHUB_ACTION_INPUT_TestType
TestsPath = $testsPath
}
$results = Test-PSModule @params

Start-LogGroup 'Test results'
Write-Verbose ($results | Out-String)
Stop-LogGroup
LogGroup 'Test results' {
Write-Verbose ($results | Out-String)
}

$failedTests = $results.FailedCount

Expand Down