Run Tests #1818
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: Run Tests | |
| on: | |
| push: | |
| branches-ignore: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| - develop | |
| schedule: | |
| - cron: '0 * * * *' | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| actions: read | |
| defaults: | |
| run: | |
| shell: pwsh | |
| jobs: | |
| test-and-coverage: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install required CI PowerShell modules | |
| run: ./scripts/build/ci/Install-CiPowerShellModules.ps1 | |
| - name: Run NovaModuleTools CI test | |
| run: ./scripts/build/ci/Invoke-NovaModuleToolsCI.ps1 -OutputDirectory ./artifacts | |
| - name: Validate release history files with Test-KeepAChangelogFile | |
| run: | | |
| foreach ($path in @('./CHANGELOG.md', './RELEASE_NOTE.md')) { | |
| $result = Test-KeepAChangelogFile -Path $path | |
| if (-not $result.IsValid) { | |
| $errors = $result.Errors -join [Environment]::NewLine | |
| throw "Validation failed for $path$([Environment]::NewLine)$errors" | |
| } | |
| } | |
| - name: Upload CI artifacts | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: nova-ci-artifacts | |
| if-no-files-found: warn | |
| path: | | |
| artifacts/ | |
| dist/ | |
| - name: Generate Report | |
| if: always() | |
| run: | | |
| $reportLines = @( | |
| '## CI Output Files', | |
| '', | |
| '### artifacts/', | |
| '' | |
| ) | |
| $artifactFiles = Get-ChildItem -Path ./artifacts -Recurse -File -ErrorAction SilentlyContinue | Sort-Object FullName | |
| if ($artifactFiles) { | |
| $reportLines += '| Name | Directory |' | |
| $reportLines += '| --- | --- |' | |
| $reportLines += $artifactFiles | ForEach-Object { | |
| $name = ('' + $_.Name).Replace('|', '\|') | |
| $directory = ('' + $_.Directory).Replace('|', '\|') | |
| "| $name | $directory |" | |
| } | |
| } | |
| else { | |
| $reportLines += 'No files found in `./artifacts`.' | |
| } | |
| $reportLines += @('', '### dist/', '') | |
| $files = Get-ChildItem -Path ./dist -Recurse -ErrorAction SilentlyContinue | Sort-Object FullName | |
| if ($files) { | |
| $reportLines += '| Name | Directory |' | |
| $reportLines += '| --- | --- |' | |
| $reportLines += $files | ForEach-Object { | |
| $name = ('' + $_.Name).Replace('|', '\|') | |
| $directory = ('' + $_.Directory).Replace('|', '\|') | |
| "| $name | $directory |" | |
| } | |
| } | |
| else { | |
| $reportLines += 'No files found in `./dist`.' | |
| } | |
| $report = $reportLines -join [Environment]::NewLine | |
| Add-Content -LiteralPath $env:GITHUB_STEP_SUMMARY -Value $report | |
| Write-Output $report | |
| codescene-coverage-gates: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - test-and-coverage | |
| if: ${{ needs.test-and-coverage.result == 'success' && github.event_name == 'pull_request' }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Download CI artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: nova-ci-artifacts | |
| path: coverage/ | |
| - name: Check coverage gates in CodeScene | |
| uses: ./.github/actions/check-coverage | |
| with: | |
| access-token: ${{ secrets.CS_ACCESS_TOKEN }} | |
| project-url: ${{ format('{0}/v2/projects/{1}', vars.CS_URL, vars.CS_PROJECT_ID) }} | |
| coverage-files: '**/coverage.xml' | |
| codescene-analysis: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - test-and-coverage | |
| if: ${{ needs.test-and-coverage.result == 'success' && (github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref_name == 'develop')) }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Download CI artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: nova-ci-artifacts | |
| path: . | |
| - name: Install CodeScene coverage CLI | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| curl -fsSL -o install-cs-coverage-tool.sh https://downloads.codescene.io/enterprise/cli/install-cs-coverage-tool.sh | |
| bash install-cs-coverage-tool.sh -y | |
| echo "$HOME/.local/bin" >> "$GITHUB_PATH" | |
| - name: Upload coverage to CodeScene and trigger analysis | |
| env: | |
| CS_URL: ${{ vars.CS_URL }} | |
| CS_PROJECT_ID: ${{ vars.CS_PROJECT_ID }} | |
| CS_ACCESS_TOKEN: ${{ secrets.CS_ACCESS_TOKEN }} | |
| run: ./scripts/build/ci/Invoke-CodeSceneAnalysis.ps1 -UploadCoverage -TriggerAnalysis |