Prepare 5.0 release #88
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: CI | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| jobs: | |
| Testing: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - name: Install PSScriptAnalyzer module | |
| shell: pwsh | |
| run: | | |
| Set-PSRepository PSGallery -InstallationPolicy Trusted | |
| Install-Module PSScriptAnalyzer -ErrorAction Stop | |
| - name: Lint with PSScriptAnalyzer | |
| shell: pwsh | |
| run: | | |
| Invoke-ScriptAnalyzer -Path . -Recurse -Outvariable issues | |
| $issues | ConvertTo-Json -Depth 2 | Set-Content -Path '${{ github.workspace }}/pssa.json' | |
| $errors = $issues.Where({$_.Severity -eq 'Error'}) | |
| $warnings = $issues.Where({$_.Severity -eq 'Warning'}) | |
| if ($errors) { | |
| Write-Error "There were $($errors.Count) errors and $($warnings.Count) warnings total." -ErrorAction Stop | |
| } else { | |
| Write-Output "There were $($errors.Count) errors and $($warnings.Count) warnings total." | |
| } | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: pssa-results | |
| path: ${{ github.workspace }}/pssa.json | |
| - name: Install Pester module | |
| shell: pwsh | |
| run: | | |
| Set-PSRepository PSGallery -InstallationPolicy Trusted | |
| Install-Module Pester -MinimumVersion 5.0 -SkipPublisherCheck -Force -ErrorAction Stop | |
| - name: Test with Pester | |
| shell: pwsh | |
| run: | | |
| # legacy tests require a live ServiceNow instance and mandatory credentials - | |
| # they aren't runnable non-interactively in CI, so exclude them here | |
| $excluded = @( | |
| 'AddServiceNowAttachment.Tests.ps1', | |
| 'GetServiceNowAttachment.Tests.ps1', | |
| 'GetServiceNowAttachmentDetail.Tests.ps1', | |
| 'RemoveServiceNowAttachment.Tests.ps1', | |
| 'ServiceNow.Tests.ps1' | |
| ) | |
| $testFiles = Get-ChildItem -Path './Tests' -Filter '*.Tests.ps1' | | |
| Where-Object { $_.Name -notin $excluded } | | |
| Select-Object -ExpandProperty FullName | |
| $config = New-PesterConfiguration | |
| $config.Run.Path = $testFiles | |
| $config.Run.PassThru = $true | |
| $config.Run.Exit = $false | |
| $config.TestResult.Enabled = $true | |
| $config.TestResult.OutputPath = '${{ github.workspace }}/pester-results.xml' | |
| $config.Output.Verbosity = 'Detailed' | |
| $result = Invoke-Pester -Configuration $config | |
| if ($result.FailedCount -gt 0) { | |
| Write-Error "$($result.FailedCount) Pester test(s) failed." -ErrorAction Stop | |
| } | |
| - name: Upload Pester results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: pester-results | |
| path: ${{ github.workspace }}/pester-results.xml |