|
| 1 | +name: Run QA Test # Runs automated tests on a self-hosted QA machine |
| 2 | +permissions: |
| 3 | + contents: read |
| 4 | + #pull-requests: write # maybe need to re-add this later |
| 5 | + |
| 6 | +on: |
| 7 | + workflow_run: |
| 8 | + workflows: ["Build"] |
| 9 | + types: |
| 10 | + - completed |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: qa-test-run |
| 14 | + cancel-in-progress: true # Cancels any queued job when a new one starts |
| 15 | + |
| 16 | +jobs: |
| 17 | + debug-workflow: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - name: Debug Workflow Variables |
| 21 | + env: |
| 22 | + HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }} |
| 23 | + HEAD_COMMIT_MSG: ${{ github.event.workflow_run.head_commit.message }} |
| 24 | + run: | |
| 25 | + echo "Workflow Conclusion: ${{ github.event.workflow_run.conclusion }}" |
| 26 | + echo "Workflow Head Branch: $HEAD_BRANCH" |
| 27 | + echo "Workflow Run ID: ${{ github.event.workflow_run.id }}" |
| 28 | + echo "Head Commit Message: $HEAD_COMMIT_MSG" |
| 29 | + echo "GitHub Ref: ${{ github.ref }}" |
| 30 | + echo "GitHub Ref Name: ${{ github.ref_name }}" |
| 31 | + echo "GitHub Event Name: ${{ github.event_name }}" |
| 32 | + echo "GitHub Workflow Name: ${{ github.workflow }}" |
| 33 | +
|
| 34 | + install-viewer-and-run-tests: |
| 35 | + runs-on: [self-hosted, qa-machine] |
| 36 | + # Run test only on successful builds of Second_Life_X branches |
| 37 | + if: > |
| 38 | + github.event.workflow_run.conclusion == 'success' && |
| 39 | + ( |
| 40 | + startsWith(github.event.workflow_run.head_branch, 'Second_Life') |
| 41 | + ) |
| 42 | +
|
| 43 | + steps: |
| 44 | + - name: Temporarily Allow PowerShell Scripts (Process Scope) |
| 45 | + run: | |
| 46 | + Set-ExecutionPolicy RemoteSigned -Scope Process -Force |
| 47 | +
|
| 48 | + - name: Verify viewer-sikulix-main Exists |
| 49 | + run: | |
| 50 | + if (-Not (Test-Path -Path 'C:\viewer-sikulix-main')) { |
| 51 | + Write-Host '❌ Error: viewer-sikulix not found on runner!' |
| 52 | + exit 1 |
| 53 | + } |
| 54 | + Write-Host '✅ viewer-sikulix is already available.' |
| 55 | +
|
| 56 | + - name: Fetch & Download Windows Installer Artifact |
| 57 | + shell: pwsh |
| 58 | + run: | |
| 59 | + $BUILD_ID = "${{ github.event.workflow_run.id }}" |
| 60 | + $ARTIFACTS_URL = "https://api.github.com/repos/secondlife/viewer/actions/runs/$BUILD_ID/artifacts" |
| 61 | +
|
| 62 | + # Fetch the correct artifact URL |
| 63 | + $response = Invoke-RestMethod -Headers @{Authorization="token ${{ secrets.GITHUB_TOKEN }}" } -Uri $ARTIFACTS_URL |
| 64 | + $ARTIFACT_NAME = ($response.artifacts | Where-Object { $_.name -eq "Windows-installer" }).archive_download_url |
| 65 | +
|
| 66 | + if (-Not $ARTIFACT_NAME) { |
| 67 | + Write-Host "❌ Error: Windows-installer artifact not found!" |
| 68 | + exit 1 |
| 69 | + } |
| 70 | +
|
| 71 | + Write-Host "✅ Artifact found: $ARTIFACT_NAME" |
| 72 | +
|
| 73 | + # Secure download path |
| 74 | + $DownloadPath = "$env:TEMP\secondlife-build-$BUILD_ID" |
| 75 | + New-Item -ItemType Directory -Path $DownloadPath -Force | Out-Null |
| 76 | + $InstallerPath = "$DownloadPath\installer.zip" |
| 77 | +
|
| 78 | + # Download the ZIP |
| 79 | + Invoke-WebRequest -Uri $ARTIFACT_NAME -Headers @{Authorization="token ${{ secrets.GITHUB_TOKEN }}"} -OutFile $InstallerPath |
| 80 | +
|
| 81 | + # Ensure download succeeded |
| 82 | + if (-Not (Test-Path $InstallerPath)) { |
| 83 | + Write-Host "❌ Error: Failed to download Windows-installer.zip" |
| 84 | + exit 1 |
| 85 | + } |
| 86 | +
|
| 87 | + - name: Extract Installer & Locate Executable |
| 88 | + shell: pwsh |
| 89 | + run: | |
| 90 | + # Explicitly set BUILD_ID again (since it does not appear to persist across steps) |
| 91 | + $BUILD_ID = "${{ github.event.workflow_run.id }}" |
| 92 | + $ExtractPath = "$env:TEMP\secondlife-build-$BUILD_ID" |
| 93 | + $InstallerZip = "$ExtractPath\installer.zip" |
| 94 | +
|
| 95 | + # Print paths for debugging |
| 96 | + Write-Host "Extract Path: $ExtractPath" |
| 97 | + Write-Host "Installer ZIP Path: $InstallerZip" |
| 98 | +
|
| 99 | + # Verify ZIP exists before extracting |
| 100 | + if (-Not (Test-Path $InstallerZip)) { |
| 101 | + Write-Host "❌ Error: ZIP file not found at $InstallerZip!" |
| 102 | + exit 1 |
| 103 | + } |
| 104 | +
|
| 105 | + Write-Host "✅ ZIP file exists and is valid. Extracting..." |
| 106 | +
|
| 107 | + Expand-Archive -Path $InstallerZip -DestinationPath $ExtractPath -Force |
| 108 | +
|
| 109 | + # Find installer executable |
| 110 | + $INSTALLER_PATH = (Get-ChildItem -Path $ExtractPath -Filter '*.exe' -Recurse | Select-Object -First 1).FullName |
| 111 | +
|
| 112 | + if (-Not $INSTALLER_PATH -or $INSTALLER_PATH -eq "") { |
| 113 | + Write-Host "❌ Error: No installer executable found in the extracted files!" |
| 114 | + Write-Host "📂 Extracted Files:" |
| 115 | + Get-ChildItem -Path $ExtractPath -Recurse | Format-Table -AutoSize |
| 116 | + exit 1 |
| 117 | + } |
| 118 | +
|
| 119 | + Write-Host "✅ Installer found: $INSTALLER_PATH" |
| 120 | + echo "INSTALLER_PATH=$INSTALLER_PATH" | Out-File -FilePath $env:GITHUB_ENV -Append |
| 121 | +
|
| 122 | + - name: Install Second Life Using Task Scheduler (Bypass UAC) |
| 123 | + shell: pwsh |
| 124 | + run: | |
| 125 | + $action = New-ScheduledTaskAction -Execute "${{ env.INSTALLER_PATH }}" -Argument "/S" |
| 126 | + $principal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -LogonType ServiceAccount -RunLevel Highest |
| 127 | + $task = New-ScheduledTask -Action $action -Principal $principal |
| 128 | + Register-ScheduledTask -TaskName "SilentSLInstaller" -InputObject $task -Force |
| 129 | + Start-ScheduledTask -TaskName "SilentSLInstaller" |
| 130 | +
|
| 131 | + - name: Wait for Installation to Complete |
| 132 | + shell: pwsh |
| 133 | + run: | |
| 134 | + Write-Host "Waiting for the Second Life installer to finish..." |
| 135 | + do { |
| 136 | + Start-Sleep -Seconds 5 |
| 137 | + $installerProcess = Get-Process | Where-Object { $_.Path -eq "${{ env.INSTALLER_PATH }}" } |
| 138 | + } while ($installerProcess) |
| 139 | +
|
| 140 | + Write-Host "✅ Installation completed!" |
| 141 | +
|
| 142 | + - name: Cleanup Task Scheduler Entry |
| 143 | + shell: pwsh |
| 144 | + run: | |
| 145 | + Unregister-ScheduledTask -TaskName "SilentSLInstaller" -Confirm:$false |
| 146 | + Write-Host "✅ Task Scheduler entry removed." |
| 147 | +
|
| 148 | + - name: Delete Installer ZIP |
| 149 | + shell: pwsh |
| 150 | + run: | |
| 151 | + # Explicitly set BUILD_ID again |
| 152 | + $BUILD_ID = "${{ github.event.workflow_run.id }}" |
| 153 | + $DeletePath = "$env:TEMP\secondlife-build-$BUILD_ID\installer.zip" |
| 154 | +
|
| 155 | + Write-Host "Checking if installer ZIP exists: $DeletePath" |
| 156 | +
|
| 157 | + # Ensure the ZIP file exists before trying to delete it |
| 158 | + if (Test-Path $DeletePath) { |
| 159 | + Remove-Item -Path $DeletePath -Force |
| 160 | + Write-Host "✅ Successfully deleted: $DeletePath" |
| 161 | + } else { |
| 162 | + Write-Host "⚠️ Warning: ZIP file does not exist, skipping deletion." |
| 163 | + } |
| 164 | +
|
| 165 | + - name: Run QA Test Script |
| 166 | + run: | |
| 167 | + Write-Host "Running QA Test script..." |
| 168 | + python C:\viewer-sikulix-main\runTests.py |
| 169 | +
|
| 170 | + # - name: Upload Test Results |
| 171 | + # uses: actions/upload-artifact@v3 |
| 172 | + # with: |
| 173 | + # name: test-results |
| 174 | + # path: C:\viewer-sikulix-main\regressionTest\test_results.html |
0 commit comments