|
| 1 | +name: Windows PowerShell Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main, develop ] |
| 6 | + paths: |
| 7 | + - '**.ps1' |
| 8 | + - 'app.py' |
| 9 | + - 'requirements.txt' |
| 10 | + - '.github/workflows/windows-test.yml' |
| 11 | + pull_request: |
| 12 | + branches: [ main ] |
| 13 | + paths: |
| 14 | + - '**.ps1' |
| 15 | + - 'app.py' |
| 16 | + - 'requirements.txt' |
| 17 | + - '.github/workflows/windows-test.yml' |
| 18 | + workflow_dispatch: # Allow manual trigger |
| 19 | + |
| 20 | +jobs: |
| 21 | + powershell-tests: |
| 22 | + name: PowerShell Quick-Start Tests |
| 23 | + runs-on: windows-latest |
| 24 | + |
| 25 | + strategy: |
| 26 | + matrix: |
| 27 | + python-version: ['3.9', '3.11', '3.12'] |
| 28 | + fail-fast: false |
| 29 | + |
| 30 | + steps: |
| 31 | + - name: Checkout code |
| 32 | + uses: actions/checkout@v4 |
| 33 | + |
| 34 | + - name: Set up Python ${{ matrix.python-version }} |
| 35 | + uses: actions/setup-python@v5 |
| 36 | + with: |
| 37 | + python-version: ${{ matrix.python-version }} |
| 38 | + |
| 39 | + - name: Cache pip dependencies |
| 40 | + uses: actions/cache@v4 |
| 41 | + with: |
| 42 | + path: ~\AppData\Local\pip\Cache |
| 43 | + key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }} |
| 44 | + restore-keys: | |
| 45 | + ${{ runner.os }}-pip- |
| 46 | +
|
| 47 | + - name: Display Python version |
| 48 | + run: python --version |
| 49 | + |
| 50 | + - name: Install Python dependencies |
| 51 | + run: | |
| 52 | + python -m pip install --upgrade pip |
| 53 | + pip install -r requirements.txt |
| 54 | +
|
| 55 | + - name: Verify PowerShell version |
| 56 | + shell: powershell |
| 57 | + run: | |
| 58 | + Write-Host "PowerShell Version:" -ForegroundColor Cyan |
| 59 | + $PSVersionTable.PSVersion |
| 60 | +
|
| 61 | + - name: Run PowerShell Quick-Start Tests |
| 62 | + shell: powershell |
| 63 | + run: | |
| 64 | + Write-Host "========================================" -ForegroundColor Magenta |
| 65 | + Write-Host "Running PowerShell Quick-Start Tests" -ForegroundColor Magenta |
| 66 | + Write-Host "Python Version: ${{ matrix.python-version }}" -ForegroundColor Magenta |
| 67 | + Write-Host "========================================" -ForegroundColor Magenta |
| 68 | +
|
| 69 | + # Run the test script |
| 70 | + .\tests\scripts\test-quick-start.ps1 -TestPort 8001 |
| 71 | +
|
| 72 | + if ($LASTEXITCODE -ne 0) { |
| 73 | + Write-Host "Tests failed with exit code: $LASTEXITCODE" -ForegroundColor Red |
| 74 | + exit $LASTEXITCODE |
| 75 | + } |
| 76 | + env: |
| 77 | + PYTHONPATH: ${{ github.workspace }}\src;${{ github.workspace }} |
| 78 | + |
| 79 | + - name: Display logs on failure |
| 80 | + if: failure() |
| 81 | + shell: powershell |
| 82 | + run: | |
| 83 | + $logFile = Join-Path $env:USERPROFILE ".config\helpful-tools\helpful-tools-v2.log" |
| 84 | + if (Test-Path $logFile) { |
| 85 | + Write-Host "========================================" -ForegroundColor Yellow |
| 86 | + Write-Host "Application Logs" -ForegroundColor Yellow |
| 87 | + Write-Host "========================================" -ForegroundColor Yellow |
| 88 | + Get-Content $logFile -Tail 50 |
| 89 | + } else { |
| 90 | + Write-Host "No log file found at: $logFile" -ForegroundColor Yellow |
| 91 | + } |
| 92 | +
|
| 93 | + - name: Upload test logs and artifacts |
| 94 | + if: failure() |
| 95 | + uses: actions/upload-artifact@v4 |
| 96 | + with: |
| 97 | + name: test-logs-python-${{ matrix.python-version }} |
| 98 | + path: | |
| 99 | + ${{ env.USERPROFILE }}\.config\helpful-tools\*.log |
| 100 | + ${{ env.USERPROFILE }}\.config\helpful-tools\*.pid |
| 101 | + ${{ env.USERPROFILE }}\.config\helpful-tools\.port |
| 102 | + if-no-files-found: ignore |
| 103 | + retention-days: 7 |
| 104 | + |
| 105 | + bash-script-test: |
| 106 | + name: Test Bash Script on Windows (WSL/Git Bash) |
| 107 | + runs-on: windows-latest |
| 108 | + |
| 109 | + steps: |
| 110 | + - name: Checkout code |
| 111 | + uses: actions/checkout@v4 |
| 112 | + |
| 113 | + - name: Set up Python |
| 114 | + uses: actions/setup-python@v5 |
| 115 | + with: |
| 116 | + python-version: '3.11' |
| 117 | + |
| 118 | + - name: Install dependencies |
| 119 | + run: | |
| 120 | + python -m pip install --upgrade pip |
| 121 | + pip install -r requirements.txt |
| 122 | +
|
| 123 | + - name: Test quick-start.sh with Git Bash |
| 124 | + shell: bash |
| 125 | + run: | |
| 126 | + echo "Testing quick-start.sh help command..." |
| 127 | + chmod +x quick-start.sh |
| 128 | + ./quick-start.sh help || echo "Note: Full bash script may not work on Windows without WSL" |
| 129 | +
|
| 130 | + summary: |
| 131 | + name: Test Summary |
| 132 | + runs-on: windows-latest |
| 133 | + needs: [powershell-tests, bash-script-test] |
| 134 | + if: always() |
| 135 | + |
| 136 | + steps: |
| 137 | + - name: Check test results |
| 138 | + shell: powershell |
| 139 | + run: | |
| 140 | + Write-Host "========================================" -ForegroundColor Cyan |
| 141 | + Write-Host "Windows Test Summary" -ForegroundColor Cyan |
| 142 | + Write-Host "========================================" -ForegroundColor Cyan |
| 143 | +
|
| 144 | + $psResult = "${{ needs.powershell-tests.result }}" |
| 145 | + $bashResult = "${{ needs.bash-script-test.result }}" |
| 146 | +
|
| 147 | + Write-Host "PowerShell Tests: $psResult" -ForegroundColor $(if ($psResult -eq 'success') { 'Green' } else { 'Red' }) |
| 148 | + Write-Host "Bash Script Test: $bashResult" -ForegroundColor $(if ($bashResult -eq 'success') { 'Green' } else { 'Yellow' }) |
| 149 | +
|
| 150 | + if ($psResult -ne 'success') { |
| 151 | + Write-Host "`nPowerShell tests failed!" -ForegroundColor Red |
| 152 | + exit 1 |
| 153 | + } |
| 154 | +
|
| 155 | + Write-Host "`nAll critical tests passed!" -ForegroundColor Green |
0 commit comments