Validate module #27
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: 'Validate module' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| on: | |
| push: | |
| paths: | |
| - 'Evergreen/**' | |
| branches-ignore: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| paths: | |
| - 'Evergreen/**' | |
| workflow_dispatch: | |
| jobs: | |
| psscriptanalyzer: | |
| permissions: | |
| contents: read # for actions/checkout to fetch code | |
| security-events: write # for github/codeql-action/upload-sarif to upload SARIF results | |
| actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status | |
| name: Run PSScriptAnalyzer | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Run PSScriptAnalyzer (main push) | |
| uses: microsoft/psscriptanalyzer-action@6b2948b1944407914a58661c49941824d149734f | |
| with: | |
| path: "./Evergreen" | |
| recurse: true | |
| settings: "./.rules/PSScriptAnalyzerSettings.psd1" | |
| output: results.sarif | |
| # Upload the SARIF file generated in the previous step | |
| - name: Upload SARIF results file | |
| uses: github/codeql-action/upload-sarif@v4 | |
| with: | |
| sarif_file: results.sarif | |
| pestertest5: | |
| name: "Run Pester tests on Windows PowerShell (main push)" | |
| needs: psscriptanalyzer | |
| runs-on: windows-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Pester tests | |
| shell: powershell | |
| working-directory: "${{ github.workspace }}" | |
| run: | | |
| .\tests\Install-Pester.ps1 | |
| Import-Module -Name "Pester" -Force -ErrorAction "Stop" | |
| Import-Module -Name "$env:GITHUB_WORKSPACE\Evergreen" -Force | |
| Update-Evergreen -Force | |
| $Config = [PesterConfiguration]::Default | |
| $Config.Run.Path = "$env:GITHUB_WORKSPACE\tests" | |
| $Config.Run.PassThru = $true | |
| $Config.CodeCoverage.Enabled = $true | |
| $Config.CodeCoverage.Path = "$env:GITHUB_WORKSPACE\Evergreen" | |
| $Config.CodeCoverage.OutputFormat = "JaCoCo" | |
| $Config.CodeCoverage.OutputPath = "$env:GITHUB_WORKSPACE\CodeCoverage.xml" | |
| $Config.Output.Verbosity = "Detailed" | |
| $Config.TestResult.Enabled = $true | |
| $Config.TestResult.OutputFormat = "NUnitXml" | |
| $Config.TestResult.OutputPath = "$env:GITHUB_WORKSPACE\tests\TestResults.xml" | |
| Invoke-Pester -Configuration $Config | |
| # Upload test results | |
| - name: Upload Pester test results | |
| uses: actions/upload-artifact@v5 | |
| if: always() | |
| with: | |
| name: test-results | |
| path: "${{ github.workspace }}\\tests\\TestResults.xml" | |
| - name: Upload code coverage results | |
| uses: actions/upload-artifact@v5 | |
| if: always() | |
| with: | |
| name: codecov-results | |
| path: "${{ github.workspace }}\\CodeCoverage.xml" | |
| publish-test-results: | |
| name: "Publish Tests Results" | |
| needs: [ "pestertest5"] | |
| runs-on: ubuntu-latest | |
| if: always() | |
| permissions: | |
| checks: write | |
| # only needed unless run with comment_mode: off | |
| pull-requests: write | |
| steps: | |
| - name: Download Pester Test Result Artifacts | |
| uses: actions/download-artifact@v6 | |
| with: | |
| name: test-results | |
| path: test-results | |
| - name: Publish Pester Test Results | |
| uses: EnricoMi/publish-unit-test-result-action@v2 | |
| with: | |
| files: "test-results/**/*.xml" |