more debugging #128
This file contains 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: Windows Nightly Run | |
on: [push] | |
jobs: | |
start-ec2-instance: | |
uses: ./.github/workflows/provision-runner.yml | |
with: | |
ec2-image-id: ami-01fa2492704e48175 | |
ec2-instance-type: t2.micro | |
security-group-id: sg-0a3e6b53e86d0e69d | |
subnet-id: subnet-06113672589e7e836 | |
ec2-os-type: windows | |
secrets: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
github-token: ${{ secrets.GH_RUNNER_API_TOKEN }} | |
nonadmin-password: ${{ secrets.NONADMIN_PASSWORD }} | |
run-tests: | |
needs: start-ec2-instance | |
runs-on: ${{ needs.start-ec2-instance.outputs.instance_label }} | |
steps: | |
- name: Install nodeJS | |
shell: powershell | |
run: | | |
if (-not (Get-Command choco -ErrorAction SilentlyContinue)) { | |
Set-ExecutionPolicy Bypass -Scope Process -Force | |
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12 | |
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) | |
} | |
choco install nodejs -y | |
- name: Write Test Script | |
shell: powershell | |
run: | | |
# Ensure the directory exists | |
if (-not (Test-Path -Path "C:\actions-runner\work")) { | |
New-Item -Path "C:\actions-runner\work" -ItemType Directory -Force | |
} | |
$scriptContent = @" | |
# Redirect all output streams | |
Start-Transcript -Path 'C:\actions-runner\work\run-tests-transcript.log' -Append | |
code --version *> C:\actions-runner\work\run-tests-output.log 2> C:\actions-runner\work\run-tests-error.log | |
node --version *> C:\actions-runner\work\run-tests-output.log 2>> C:\actions-runner\work\run-tests-error.log | |
Stop-Transcript | |
"@ | |
$scriptPath = "C:\actions-runner\work\run-tests.ps1" | |
$scriptContent | Out-File -FilePath $scriptPath -Encoding utf8 -Force | |
- name: Run Test Script as Non-Admin | |
shell: powershell | |
run: | | |
$password = ConvertTo-SecureString -String "${{ secrets.NONADMIN_PASSWORD }}" -AsPlainText -Force | |
$credential = New-Object System.Management.Automation.PSCredential("nonadmin", $password) | |
# Paths for script and logs | |
$scriptPath = "C:\actions-runner\work\run-tests.ps1" | |
$logPathOut = "C:\actions-runner\work\run-tests-output.log" | |
$logPathErr = "C:\actions-runner\work\run-tests-error.log" | |
# Log debug info before running the script | |
Write-Output "Checking script path: $scriptPath" | |
if (-not (Test-Path $scriptPath)) { | |
Write-Error "Script not found at path: $scriptPath" | |
exit 1 | |
} | |
Write-Output "Checking output log path: $logPathOut" | |
if (-not (Test-Path $logPathOut)) { | |
New-Item -Path $logPathOut -ItemType File -Force | Out-Null | |
} | |
Write-Output "Checking error log path: $logPathErr" | |
if (-not (Test-Path $logPathErr)) { | |
New-Item -Path $logPathErr -ItemType File -Force | Out-Null | |
} | |
# Run script using Start-Process for non-admin execution | |
Start-Process -FilePath "powershell.exe" ` | |
-ArgumentList "-File $scriptPath" ` | |
-Credential $credential ` | |
-NoNewWindow ` | |
-RedirectStandardOutput $logPathOut ` | |
-RedirectStandardError $logPathErr ` | |
-Wait | |
# Output log files to GitHub Actions | |
if ((Test-Path $logPathOut) -and (Get-Content $logPathOut | Measure-Object -Line).Lines -gt 0) { | |
Write-Output "--- Standard Output ---" | |
Get-Content -Path $logPathOut | |
} else { | |
Write-Output "No output was written to the standard output log." | |
} | |
if ((Test-Path $logPathErr) -and (Get-Content $logPathErr | Measure-Object -Line).Lines -gt 0) { | |
Write-Output "--- Standard Error ---" | |
Get-Content -Path $logPathErr | |
} else { | |
Write-Output "No output was written to the standard error log." | |
} | |
# stop-ec2-instance: | |
# needs: [ start-ec2-instance, run-tests ] | |
# if: always() | |
# uses: ./.github/workflows/remove-runner.yml | |
# with: | |
# ec2-instance-id: ${{ needs.start-ec2-instance.outputs.ec2-instance-id }} | |
# ec2-runner-label: ${{ needs.start-ec2-instance.outputs.instance_label }} | |
# secrets: | |
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
# github-token: ${{ secrets.GH_RUNNER_API_TOKEN }} |