Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP]Testing windows CI #44

Merged
merged 3 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .github/workflows/provision-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,14 @@ on:
github-token:
description: 'Personal Access Token For GH'
required: true
nonadmin-password:
description: 'Password for the non-admin user'
required: true
outputs:
instance_label:
instance_label:
description: "The label of the VM that was created."
value: ${{ jobs.provision-ec2.outputs.label }}
ec2-instance-id:
ec2-instance-id:
description: "Instance id of the VM that was created."
value: ${{ jobs.provision-ec2.outputs.instance_id }}

Expand Down Expand Up @@ -70,12 +73,12 @@ jobs:
mode: start
github-token: ${{ secrets.github-token }}
ec2-os: ${{ inputs.ec2-os-type }}
ec2-instance-type: ${{ inputs.ec2-instance-type }}
ec2-instance-type: ${{ inputs.ec2-instance-type }}
ec2-image-id: ${{ inputs.ec2-image-id }}
subnet-id: ${{ inputs.subnet-id }}
security-group-id: ${{ inputs.security-group-id }}

- name: Output EC2 Instance ID
run: |
echo "EC2 Instance ID: ${{ steps.ec2.outputs.ec2-instance-id }}"
echo "Label : ${{ steps.ec2.outputs.label }}"
echo "Label : ${{ steps.ec2.outputs.label }}"
101 changes: 101 additions & 0 deletions .github/workflows/windows-nightly-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Windows Nightly Run

on: [pull_request]

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: Write Test Script
# shell: powershell
# run: |
# # Ensure the directory exists
# $runnerDir = "C:\Users\nonadmin\Documents\actions-runner\work"
# if (-not (Test-Path -Path $runnerDir)) {
# New-Item -Path $runnerDir -ItemType Directory -Force
# }
#
# # Create the test script
# $scriptContent = @"
# # Redirect output directly in the script
# code --version >> "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-output.log" 2>> "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-error.log"
# node --version >> "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-output.log" 2>> "C:\Users\nonadmin\Documents\actions-runner\work\run-tests-error.log"
# "@
#
# $scriptPath = "$runnerDir\run-tests.ps1"
# $scriptContent | Out-File -FilePath $scriptPath -Encoding utf8 -Force

- name: Run Test Script with PsExec
shell: powershell
run: |
# Define paths
$psExecUrl = "https://download.sysinternals.com/files/PSTools.zip"
$toolsDir = "C:\tools"
$psExecPath = "$toolsDir\PsExec64.exe"
$logDir = "C:\Users\nonadmin\Documents\actions-runner\work"
$logPathOut = "$logDir\run-tests-output.log"
$logPathErr = "$logDir\run-tests-error.log"

# Step 1: Install PsExec
Write-Output "Downloading and installing PsExec..."
if (Test-Path -Path $toolsDir) { Remove-Item -Recurse -Force $toolsDir }
New-Item -Path $toolsDir -ItemType Directory -Force
Invoke-WebRequest -Uri $psExecUrl -OutFile "$toolsDir\PSTools.zip"
Expand-Archive -Path "$toolsDir\PSTools.zip" -DestinationPath $toolsDir -Force
Write-Output "PsExec installed successfully."

# Step 2: Ensure the log directory exists
Write-Output "Ensuring log directory exists: $logDir"
if (-Not (Test-Path -Path $logDir)) {
New-Item -Path $logDir -ItemType Directory -Force
}

# Step 3: Execute the command using PsExec
Write-Output "Executing PsExec as nonadmin to run 'code --version'..."
& $psExecPath -accepteula -nobanner -u nonadmin -p "pass123!" powershell.exe `
-Command "hostname > '$logPathOut' 2> '$logPathErr'"

# Step 4: Check if output log file exists
if (-Not (Test-Path -Path $logPathOut)) {
Write-Output "Log file does not exist: $logPathOut"
Write-Output "Check $logPathErr for any errors."
exit 1
}

# Step 5: Output log files to GitHub Actions
Write-Output "--- Run Output ---"
Get-Content -Path $logPathOut
Write-Output "--- Run Error ---"
Get-Content -Path $logPathErr



# 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 }}


Loading