From 96568676a3d5359b37894c7047713e5d4163e0a7 Mon Sep 17 00:00:00 2001 From: Michael LoPresti Date: Sat, 14 Oct 2023 22:18:14 -0700 Subject: [PATCH 1/3] better actions output --- .gitignore | 5 ++++- ValidateJson.build.ps1 | 10 ++++++++-- tools/dev-init.ps1 | 7 +++++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 56e2d15..59d9897 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,7 @@ src/ValidateJson.nuspec src/ValidateJson.psd1 dist -coverage.xml \ No newline at end of file +coverage.xml +test\**\** +test\result\Pester-Test-Result.XML +testResults.xml diff --git a/ValidateJson.build.ps1 b/ValidateJson.build.ps1 index b2807b5..889a828 100644 --- a/ValidateJson.build.ps1 +++ b/ValidateJson.build.ps1 @@ -116,8 +116,14 @@ task analyze { task test { if($ci){ New-Item -Path "$BuildRoot\test\" -Name "result" -ItemType "directory" -Force | out-null - Invoke-Pester -OutputFile "$BuildRoot\test\result\Pester-Test-Result.XML" ` - -OutputFormat "JUnitXML" + $pesterConfig = New-PesterConfiguration -Hashtable @{ + TestResult=@{ + Enabled=$true + OutputPath="\test\result\Pester-Test-Result.XML" + OutputFormat="JUnitXml" + } + } + Invoke-Pester -Configuration $pesterConfig # Invoke-Pester -CodeCoverage "$BuildRoot\src\$module_name.psm1" ` # -CodeCoverageOutputFile "$BuildRoot\test\result\Pester-Coverage.xml" ` # -CodeCoverageOutputFileFormat JaCoCo diff --git a/tools/dev-init.ps1 b/tools/dev-init.ps1 index 145fd8c..6634a0b 100644 --- a/tools/dev-init.ps1 +++ b/tools/dev-init.ps1 @@ -1,5 +1,8 @@ -Install-Module InvokeBuild,PSScriptAnalyzer,platyPS -Scope CurrentUser -Force -Install-Module Pester -Scope CurrentUser -MinimumVersion "5.0.0" +Install-Module "InvokeBuild","PSScriptAnalyzer","platyPS" -Scope CurrentUser -Force +Install-Module "Pester" -Scope CurrentUser -MinimumVersion "5.0.0" -Force + +Write-host "Module Versions are" +Get-Module -ListAvailable "InvokeBuild","PSScriptAnalyzer","platyPS","Pester" | Select-Object Name,Version if($(winget list --id Microsoft.NuGet --disable-interactivity --accept-source-agreements|out-string) -like '*No installed package found*') { winget install -e --id Microsoft.NuGet --disable-interactivity --accept-source-agreements From ad37e0cd163a9feac824ebc6984e4fc10ddc931e Mon Sep 17 00:00:00 2001 From: Michael LoPresti Date: Sat, 14 Oct 2023 22:24:41 -0700 Subject: [PATCH 2/3] Adding better path to output of tests --- .github/workflows/ci.github-action.yml | 1 + ValidateJson.build.ps1 | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.github-action.yml b/.github/workflows/ci.github-action.yml index a86fe99..3907b0b 100644 --- a/.github/workflows/ci.github-action.yml +++ b/.github/workflows/ci.github-action.yml @@ -36,6 +36,7 @@ jobs: - name: Validate run: Invoke-Build validate -ci $true + continue-on-error: true - name: Report Test Results uses: dorny/test-reporter@v1 diff --git a/ValidateJson.build.ps1 b/ValidateJson.build.ps1 index 889a828..d0ba95f 100644 --- a/ValidateJson.build.ps1 +++ b/ValidateJson.build.ps1 @@ -119,7 +119,7 @@ task test { $pesterConfig = New-PesterConfiguration -Hashtable @{ TestResult=@{ Enabled=$true - OutputPath="\test\result\Pester-Test-Result.XML" + OutputPath="$BuildRoot\test\result\Pester-Test-Result.XML" OutputFormat="JUnitXml" } } From 9df489de589b5394e4a8fb42226eb5bdf7cff54d Mon Sep 17 00:00:00 2001 From: Michael LoPresti Date: Sat, 14 Oct 2023 22:33:37 -0700 Subject: [PATCH 3/3] Swapping error suppression method --- ValidateJson.build.ps1 | 3 --- tests/Test-Json.Unit.Tests.ps1 | 24 ++++++++++++------------ 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/ValidateJson.build.ps1 b/ValidateJson.build.ps1 index d0ba95f..6b22ef7 100644 --- a/ValidateJson.build.ps1 +++ b/ValidateJson.build.ps1 @@ -124,9 +124,6 @@ task test { } } Invoke-Pester -Configuration $pesterConfig - # Invoke-Pester -CodeCoverage "$BuildRoot\src\$module_name.psm1" ` - # -CodeCoverageOutputFile "$BuildRoot\test\result\Pester-Coverage.xml" ` - # -CodeCoverageOutputFileFormat JaCoCo } else { Invoke-Pester } diff --git a/tests/Test-Json.Unit.Tests.ps1 b/tests/Test-Json.Unit.Tests.ps1 index dcd6c9d..7f02633 100644 --- a/tests/Test-Json.Unit.Tests.ps1 +++ b/tests/Test-Json.Unit.Tests.ps1 @@ -10,15 +10,15 @@ Describe "Json ParameterSet" { It "Handle pipeline input" { $validJson | Test-Json | Should -BeTrue - $invalidJson | Test-Json 2> $null | Should -Not -BeTrue + $invalidJson | Test-Json -ErrorAction SilentlyContinue | Should -Not -BeTrue } It "Handle positional argument" { Test-Json $validJson | Should -BeTrue - Test-Json $invalidJson 2> $null | Should -Not -BeTrue + Test-Json $invalidJson -ErrorAction SilentlyContinue | Should -Not -BeTrue } It "Handle explicit argument" { Test-Json -Json $validJson | Should -BeTrue - Test-Json -Json $invalidJson 2> $null | Should -Not -BeTrue + Test-Json -Json $invalidJson -ErrorAction SilentlyContinue | Should -Not -BeTrue } } @@ -33,21 +33,21 @@ Describe "Schema ParameterSet" { It "Handle pipeline input" { $validJson | Test-Json -Schema $schema | Should -BeTrue - $invalidJsonObject | Test-Json -Schema $schema -ErrorVariable errorvar 2> $null | Should -Not -BeTrue + $invalidJsonObject | Test-Json -Schema $schema -ErrorVariable errorvar -ErrorAction SilentlyContinue | Should -Not -BeTrue $errorvar.FullyQualifiedErrorId | Should -Be "System.Exception,Test-Json" - $invalidJson | Test-Json -Schema $schema 2> $null | Should -Not -BeTrue + $invalidJson | Test-Json -Schema $schema -ErrorAction SilentlyContinue | Should -Not -BeTrue } It "Handle positional argument" { Test-Json $validJson -Schema $schema | Should -BeTrue - Test-Json $invalidJsonObject -Schema $schema -ErrorVariable errorvar 2> $null | Should -Not -BeTrue + Test-Json $invalidJsonObject -Schema $schema -ErrorVariable errorvar -ErrorAction SilentlyContinue | Should -Not -BeTrue $errorvar.FullyQualifiedErrorId | Should -Be "System.Exception,Test-Json" - Test-Json $invalidJson -Schema $schema 2> $null | Should -Not -BeTrue + Test-Json $invalidJson -Schema $schema -ErrorAction SilentlyContinue | Should -Not -BeTrue } It "Handle explicit argument" { Test-Json -Json $validJson -Schema $schema | Should -BeTrue - Test-Json -Json $invalidJsonObject -Schema $schema -ErrorVariable errorvar 2> $null | Should -Not -BeTrue + Test-Json -Json $invalidJsonObject -Schema $schema -ErrorVariable errorvar -ErrorAction SilentlyContinue | Should -Not -BeTrue $errorvar.FullyQualifiedErrorId | Should -Be "System.Exception,Test-Json" - Test-Json -Json $invalidJson -Schema $schema 2> $null | Should -Not -BeTrue + Test-Json -Json $invalidJson -Schema $schema -ErrorAction SilentlyContinue | Should -Not -BeTrue } } @@ -63,14 +63,14 @@ Describe "File ParameterSet" { It "Handle pipeline input" { $validJson | Test-Json -SchemaFile $schemaPath | Should -BeTrue - $invalidJson | Test-Json -SchemaFile $schemaPath 2> $null | Should -Not -BeTrue + $invalidJson | Test-Json -SchemaFile $schemaPath -ErrorAction SilentlyContinue | Should -Not -BeTrue } It "Handle positional argument" { Test-Json $validJson -SchemaFile $schemaPath | Should -BeTrue - Test-Json $invalidJson -SchemaFile $schemaPath 2> $null | Should -Not -BeTrue + Test-Json $invalidJson -SchemaFile $schemaPath -ErrorAction SilentlyContinue | Should -Not -BeTrue } It "Handle explicit argument" { Test-Json -Json $validJson -SchemaFile $schemaPath | Should -BeTrue - Test-Json -Json $invalidJson -SchemaFile $schemaPath 2> $null | Should -Not -BeTrue + Test-Json -Json $invalidJson -SchemaFile $schemaPath -ErrorAction SilentlyContinue | Should -Not -BeTrue } } \ No newline at end of file