Fix Write-ReportModuleInfo unit tests for CI environment #10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Pester Tests | |
| permissions: | |
| contents: read | |
| on: | |
| push: | |
| branches: [main, dev, master] | |
| pull_request: | |
| branches: [main, dev, master] | |
| workflow_dispatch: | |
| jobs: | |
| test: | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install required modules | |
| shell: pwsh | |
| run: | | |
| Set-PSRepository -Name PSGallery -InstallationPolicy Trusted | |
| Install-Module -Name Pester -MinimumVersion 5.0.0 -Force -SkipPublisherCheck | |
| Install-Module -Name PScribo -MinimumVersion 0.11.1 -Force | |
| - name: Run Pester tests | |
| shell: pwsh | |
| run: | | |
| .\Tests\Invoke-Tests.ps1 -CodeCoverage -OutputFormat NUnitXml | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-results | |
| path: testResults.xml | |
| - name: Upload code coverage | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: code-coverage | |
| path: coverage.xml | |
| - name: Upload coverage reports to Codecov | |
| if: always() | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| slug: AsBuiltReport/AsBuiltReport.Core | |
| files: ./coverage.xml | |
| flags: unittests | |
| fail_ci_if_error: false | |
| analyze: | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install PSScriptAnalyzer | |
| shell: pwsh | |
| run: | | |
| Set-PSRepository -Name PSGallery -InstallationPolicy Trusted | |
| Install-Module -Name PSScriptAnalyzer -Force | |
| - name: Run PSScriptAnalyzer | |
| shell: pwsh | |
| run: | | |
| $SettingsPath = './.github/workflows/PSScriptAnalyzerSettings.psd1' | |
| if (Test-Path $SettingsPath) { | |
| $Results = Invoke-ScriptAnalyzer -Path ./AsBuiltReport.Core -Recurse -Settings $SettingsPath | |
| } else { | |
| $Results = Invoke-ScriptAnalyzer -Path ./AsBuiltReport.Core -Recurse | |
| } | |
| if ($Results) { | |
| $Results | Format-Table -AutoSize | |
| $Errors = $Results | Where-Object Severity -eq 'Error' | |
| if ($Errors.Count -gt 0) { | |
| exit 1 | |
| } | |
| } |