ci(deps): bump actions/github-script from 7 to 8 #60
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 - Automated Testing | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main, develop ] | |
| workflow_dispatch: | |
| # Required permissions for test result publishing | |
| permissions: | |
| contents: read | |
| checks: write | |
| pull-requests: write | |
| env: | |
| PESTER_VERSION: '5.7.0' | |
| PSSCRIPTANALYZER_VERSION: '1.22.0' | |
| jobs: | |
| # Job 1: PowerShell Script Analysis | |
| powershell-analysis: | |
| name: PowerShell Analysis | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Cache PowerShell modules | |
| uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 | |
| with: | |
| path: | | |
| ~\Documents\PowerShell\Modules | |
| C:\Users\runneradmin\Documents\PowerShell\Modules | |
| key: psmodules-${{ runner.os }}-${{ env.PSSCRIPTANALYZER_VERSION }} | |
| restore-keys: | | |
| psmodules-${{ runner.os }}- | |
| - name: Install PSScriptAnalyzer | |
| shell: pwsh | |
| run: | | |
| $ErrorActionPreference = 'Stop' | |
| Set-PSRepository PSGallery -InstallationPolicy Trusted | |
| $installed = Get-Module -ListAvailable -Name PSScriptAnalyzer | | |
| Where-Object Version -ge $env:PSSCRIPTANALYZER_VERSION | |
| if (-not $installed) { | |
| Install-Module -Name PSScriptAnalyzer -MinimumVersion $env:PSSCRIPTANALYZER_VERSION -Force -Scope CurrentUser | |
| Write-Host "[+] PSScriptAnalyzer installed" | |
| } else { | |
| Write-Host "[+] PSScriptAnalyzer already cached" | |
| } | |
| - name: Run PSScriptAnalyzer | |
| shell: pwsh | |
| run: | | |
| Write-Host "[i] Analyzing PowerShell scripts..." | |
| $scriptFiles = Get-ChildItem -Path ./Windows -Include *.ps1,*.psm1 -Recurse | |
| $totalIssues = 0 | |
| $criticalIssues = 0 | |
| foreach ($file in $scriptFiles) { | |
| Write-Host "[*] Analyzing: $($file.Name)" | |
| $results = Invoke-ScriptAnalyzer -Path $file.FullName -Severity Warning,Error | |
| if ($results) { | |
| $totalIssues += $results.Count | |
| $criticalIssues += ($results | Where-Object Severity -eq 'Error').Count | |
| foreach ($result in $results) { | |
| $icon = if ($result.Severity -eq 'Error') { '[-]' } else { '[!]' } | |
| Write-Host "$icon $($result.Severity): $($result.Message) at line $($result.Line)" | |
| } | |
| } | |
| } | |
| Write-Host "" | |
| Write-Host "[i] Total issues: $totalIssues | Critical: $criticalIssues" | |
| if ($criticalIssues -gt 0) { | |
| Write-Host "[-] Build failed due to critical issues" | |
| exit 1 | |
| } | |
| Write-Host "[+] PowerShell analysis passed" | |
| - name: Validate PowerShell syntax | |
| shell: pwsh | |
| run: | | |
| Write-Host "[i] Checking PowerShell syntax..." | |
| $errors = 0 | |
| Get-ChildItem -Path . -Filter *.ps1 -Recurse | ForEach-Object { | |
| $parseErrors = $null | |
| $null = [System.Management.Automation.PSParser]::Tokenize( | |
| (Get-Content $_.FullName -Raw), [ref]$parseErrors | |
| ) | |
| if ($parseErrors) { | |
| Write-Host "[-] Syntax error in: $($_.Name)" | |
| $errors++ | |
| } | |
| } | |
| if ($errors -gt 0) { | |
| Write-Host "[-] $errors script(s) have syntax errors" | |
| exit 1 | |
| } | |
| Write-Host "[+] All PowerShell scripts have valid syntax" | |
| # Job 2: Bash Script Validation | |
| bash-validation: | |
| name: Bash Validation (shellcheck) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Install shellcheck | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y shellcheck | |
| echo "[+] shellcheck installed: $(shellcheck --version | head -2)" | |
| - name: Validate Bash syntax | |
| run: | | |
| echo "[i] Checking Bash syntax..." | |
| errors=0 | |
| while IFS= read -r -d '' script; do | |
| if ! bash -n "$script" 2>/dev/null; then | |
| echo "[-] Syntax error in: $(basename "$script")" | |
| ((errors++)) | |
| fi | |
| done < <(find ./Linux -name "*.sh" -type f -print0) | |
| if [ $errors -gt 0 ]; then | |
| echo "[-] $errors script(s) have syntax errors" | |
| exit 1 | |
| fi | |
| echo "[+] All Bash scripts have valid syntax" | |
| - name: Run shellcheck | |
| run: | | |
| echo "[i] Running shellcheck..." | |
| SCRIPT_FILES=$(find ./Linux -name "*.sh" -type f) | |
| FAILED=0 | |
| for script in $SCRIPT_FILES; do | |
| echo "[*] Checking: $(basename "$script")" | |
| # Exclusions for acceptable patterns | |
| if ! shellcheck -S warning \ | |
| -e SC2034 \ | |
| -e SC2086 \ | |
| -e SC2181 \ | |
| -e SC2155 \ | |
| -e SC2046 \ | |
| -e SC2178 \ | |
| -e SC2128 \ | |
| "$script"; then | |
| FAILED=$((FAILED + 1)) | |
| fi | |
| done | |
| if [ $FAILED -gt 0 ]; then | |
| echo "[-] shellcheck failed for $FAILED file(s)" | |
| exit 1 | |
| fi | |
| echo "[+] All Bash scripts passed shellcheck" | |
| - name: Verify no emojis in scripts | |
| run: | | |
| echo "[i] Checking for emojis in Linux scripts..." | |
| if grep -rP '[\x{1F300}-\x{1F9FF}]' Linux/ --include="*.sh" 2>/dev/null; then | |
| echo "[-] ERROR: Found emojis in scripts!" | |
| exit 1 | |
| fi | |
| echo "[+] No emojis found - CLAUDE.md compliant" | |
| # Job 3: Windows Pester Tests | |
| windows-tests: | |
| name: Windows Pester Tests | |
| runs-on: windows-latest | |
| needs: [powershell-analysis] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Cache Pester module | |
| uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 | |
| with: | |
| path: | | |
| ~\Documents\PowerShell\Modules\Pester | |
| key: pester-${{ runner.os }}-${{ env.PESTER_VERSION }} | |
| - name: Install Pester | |
| shell: pwsh | |
| run: | | |
| Set-PSRepository PSGallery -InstallationPolicy Trusted | |
| $installed = Get-Module -ListAvailable -Name Pester | | |
| Where-Object Version -ge $env:PESTER_VERSION | |
| if (-not $installed) { | |
| Install-Module -Name Pester -MinimumVersion $env:PESTER_VERSION -Force -Scope CurrentUser | |
| Write-Host "[+] Pester installed" | |
| } else { | |
| Write-Host "[+] Pester already cached" | |
| } | |
| Import-Module Pester -PassThru | |
| - name: Enable SSH Agent Service | |
| shell: pwsh | |
| run: | | |
| Write-Host "[i] Enabling SSH agent for tests..." | |
| $sshAgent = Get-Service -Name "ssh-agent" -ErrorAction SilentlyContinue | |
| if (-not $sshAgent) { | |
| Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0 | |
| } | |
| Set-Service -Name "ssh-agent" -StartupType Manual | |
| Start-Service -Name "ssh-agent" | |
| Write-Host "[+] SSH agent: $((Get-Service ssh-agent).Status)" | |
| - name: Run Pester tests | |
| shell: pwsh | |
| run: | | |
| Write-Host "[i] Running Windows Pester tests..." | |
| $config = New-PesterConfiguration | |
| $config.Run.Path = './tests/Windows' | |
| $config.Run.Exit = $true | |
| $config.Output.Verbosity = 'Detailed' | |
| $config.TestResult.Enabled = $true | |
| $config.TestResult.OutputPath = './test-results-windows.xml' | |
| $config.TestResult.OutputFormat = 'NUnitXml' | |
| $config.CodeCoverage.Enabled = $true | |
| $config.CodeCoverage.Path = @('./Windows/lib/*.psm1') | |
| $config.CodeCoverage.OutputPath = './coverage-windows.xml' | |
| $config.CodeCoverage.OutputFormat = 'JaCoCo' | |
| Invoke-Pester -Configuration $config | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | |
| with: | |
| name: windows-test-results | |
| path: | | |
| test-results-windows.xml | |
| coverage-windows.xml | |
| - name: Publish test results | |
| if: always() | |
| uses: EnricoMi/publish-unit-test-result-action/windows@170bf24d20d201b842d7a52c0f46f5bb5800e9ce # v2.18.0 | |
| with: | |
| files: test-results-windows.xml | |
| check_name: Windows Test Results | |
| # Job 4: Linux Tests (Pester + BATS) | |
| linux-tests: | |
| name: Linux Tests | |
| runs-on: ubuntu-latest | |
| needs: [bash-validation] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Setup BATS with libraries | |
| uses: bats-core/bats-action@3.0.0 | |
| with: | |
| support-install: true | |
| assert-install: true | |
| file-install: true | |
| - name: Install PowerShell | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y wget apt-transport-https software-properties-common | |
| wget -q "https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb" | |
| sudo dpkg -i packages-microsoft-prod.deb | |
| rm packages-microsoft-prod.deb | |
| sudo apt-get update | |
| sudo apt-get install -y powershell | |
| echo "[+] PowerShell installed: $(pwsh --version)" | |
| - name: Install Pester | |
| shell: pwsh | |
| run: | | |
| Set-PSRepository PSGallery -InstallationPolicy Trusted | |
| Install-Module -Name Pester -MinimumVersion $env:PESTER_VERSION -Force -Scope CurrentUser | |
| Import-Module Pester -PassThru | |
| Write-Host "[+] Pester installed" | |
| - name: Run Linux Pester tests | |
| shell: pwsh | |
| continue-on-error: true | |
| run: | | |
| Write-Host "[i] Running Linux Pester tests..." | |
| $testFiles = Get-ChildItem './tests/Linux/*.Tests.ps1' -ErrorAction SilentlyContinue | |
| if ($testFiles) { | |
| $config = New-PesterConfiguration | |
| $config.Run.Path = './tests/Linux/*.Tests.ps1' | |
| $config.Run.Exit = $false | |
| $config.Output.Verbosity = 'Detailed' | |
| $config.TestResult.Enabled = $true | |
| $config.TestResult.OutputPath = './test-results-linux-pester.xml' | |
| $config.TestResult.OutputFormat = 'NUnitXml' | |
| $result = Invoke-Pester -Configuration $config | |
| Write-Host "[i] Pester: $($result.PassedCount) passed, $($result.FailedCount) failed" | |
| } else { | |
| Write-Host "[i] No Linux Pester tests found" | |
| } | |
| - name: Run BATS tests | |
| run: | | |
| echo "[i] Running BATS tests..." | |
| if [ -d "./tests/Linux" ]; then | |
| BATS_FILES=$(find ./tests/Linux -name "*.bats" -type f 2>/dev/null || true) | |
| if [ -n "$BATS_FILES" ]; then | |
| for bats_file in $BATS_FILES; do | |
| echo "[*] Running: $(basename "$bats_file")" | |
| bats --tap "$bats_file" || echo "[!] Failed: $bats_file" | |
| done | |
| else | |
| echo "[i] No BATS test files found" | |
| fi | |
| fi | |
| echo "[+] BATS tests completed" | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | |
| with: | |
| name: linux-test-results | |
| path: | | |
| test-results-linux-pester.xml | |
| if-no-files-found: ignore | |
| - name: Publish test results | |
| if: always() | |
| continue-on-error: true | |
| uses: EnricoMi/publish-unit-test-result-action@170bf24d20d201b842d7a52c0f46f5bb5800e9ce # v2.18.0 | |
| with: | |
| files: test-results-linux-pester.xml | |
| check_name: Linux Test Results | |
| # Job 5: Test Summary | |
| test-summary: | |
| name: Test Summary | |
| runs-on: ubuntu-latest | |
| needs: [windows-tests, linux-tests] | |
| if: always() | |
| steps: | |
| - name: Download Windows results | |
| uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 | |
| continue-on-error: true | |
| with: | |
| name: windows-test-results | |
| path: ./results | |
| - name: Download Linux results | |
| uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 | |
| continue-on-error: true | |
| with: | |
| name: linux-test-results | |
| path: ./results | |
| - name: Generate summary | |
| run: | | |
| echo "# CI Test Results" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "| Platform | Status |" >> $GITHUB_STEP_SUMMARY | |
| echo "|----------|--------|" >> $GITHUB_STEP_SUMMARY | |
| echo "| Windows Pester | ${{ needs.windows-tests.result }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| Linux BATS | ${{ needs.linux-tests.result }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| if [ -f ./results/coverage-windows.xml ]; then | |
| echo "[+] Windows coverage report available" >> $GITHUB_STEP_SUMMARY | |
| fi |