Skip to content

User/jdugar/test self host agent #44

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

Open
wants to merge 139 commits into
base: main
Choose a base branch
from

Conversation

WSEAutomationTests
Copy link
Collaborator

What changed?

Add workflow to run CheckinTest on self hosted agent

Why changed?

How did you test the change?

Related Issues (if any):

@Copilot Copilot AI review requested due to automatic review settings April 8, 2025 07:44
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 1 out of 2 changed files in this pull request and generated 2 comments.

Files not reviewed (1)
  • .github/workflows/TestAndUpload: Language not supported
Comments suppressed due to low confidence (1)

.github/workflows/test.yml:28

  • [nitpick] Consider using consistent casing for the directory name; the comment mentions 'E2e' while the command uses 'E2E'.
cd E2E

.\CheckInTest.ps1 # Adjust to your actual script name

- name: Upload test results (Optional)
if: success()
Copy link
Preview

Copilot AI Apr 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'if: success()' condition should be written as 'if: ${{ success() }}' to conform with GitHub Actions expression syntax.

Suggested change
if: success()
if: ${{ success() }}

Copilot uses AI. Check for mistakes.

Write-Output "Test run completed successfully"

- name: Handle failure (Optional)
if: failure()
Copy link
Preview

Copilot AI Apr 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'if: failure()' condition should be written as 'if: ${{ failure() }}' according to GitHub Actions syntax requirements.

Suggested change
if: failure()
if: ${{ failure() }}

Copilot uses AI. Check for mistakes.

Comment on lines +8 to +33
runs-on: windows-latest
env:
GH_TOKEN: ${{ secrets.PAT_TOKEN }}
steps:
- name: Check runner availability
shell: powershell
run: |
$token = $env:GH_TOKEN
$repo = "microsoft/WSEAutomationTests"
$apiUrl = "https://api.github.com/repos/$repo/actions/runners"
Write-Output "Querying: $apiUrl"

$headers = @{
Authorization = "Bearer $token"
Accept = "application/vnd.github+json"
"X-GitHub-Api-Version" = "2022-11-28"
}

try {
$response = Invoke-RestMethod -Uri $apiUrl -Headers $headers
foreach ($runner in $response.runners) {
Write-Output "Runner: $($runner.name), Status: $($runner.status), Labels: $($runner.labels.name -join ', ')"
}
} catch {
Write-Error "Failed to fetch runner info: $_"
}

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}
Comment on lines +11 to +46
runs-on: windows-latest
outputs:
asus-online: ${{ steps.check-asus.outputs.online }}
steps:
- name: Check ASUS-PROART Runner
id: check-asus
shell: powershell
env:
GH_TOKEN: ${{ secrets.PAT_TOKEN }}
run: |
$label = "Asus-ProArt"
$repo = "${{ github.repository }}"
$apiUrl = "https://api.github.com/repos/$repo/actions/runners"
$headers = @{
Authorization = "Bearer $env:GH_TOKEN"
Accept = "application/vnd.github+json"
"X-GitHub-Api-Version" = "2022-11-28"
}
$runners = Invoke-RestMethod -Uri $apiUrl -Headers $headers
$isOnline = $false
foreach ($runner in $runners.runners) {
$labelNames = $runner.labels | ForEach-Object { $_.name.ToLower() }
$status = $runner.status
$name = $runner.name
$label = $label.ToLower()

Write-Output "Runner found: $name | Status: $status | Labels: $($labelNames -join ', ')"
Write-Output "$label"
if ($labelNames -contains $label.ToLower() -and $runner.status -eq "online") {
$isOnline = $true
break
}
}
"online=$($isOnline.ToString().ToLower())" | Out-File -FilePath $env:GITHUB_OUTPUT -Append

run-asus-tests:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}
Comment on lines +47 to +52
needs: check-runner
if: needs.check-runner.outputs.asus-online == 'true'
uses: ./.github/workflows/reusable-asus.yaml
with:
runner_label: "Asus-ProArt"
secrets: inherit

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}
Comment on lines +12 to +87
name: Run tests on ${{ inputs.runner_label }}
runs-on: ${{ inputs.runner_label }}
steps:
- name: Check out the repository
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pywinauto
shell: powershell

- name: Run PowerShell Tests from E2E folder (device ${{ matrix.name }})
shell: powershell
continue-on-error: true
working-directory: E2E
run: |
try {
.\CheckInTest.ps1
} catch {
Write-Error "Test failed: $_"
exit 1
}

- name: Find the latest log folder
if: always()
id: find-latest-log
shell: powershell
working-directory: E2E\logs
run: |
Write-Output "Changed directory to: $PWD"
$logFolders = Get-ChildItem -Directory
Write-Output "Log folders found: $($logFolders.Name)"
$latestLogFolder = $logFolders | Sort-Object LastWriteTime -Descending | Select-Object -First 1
Write-Output "Latest log folder: $latestLogFolder"
echo "LOG_FOLDER_NAME=$latestLogFolder" >> $env:GITHUB_ENV
echo "LATEST_LOG_FOLDER=$($latestLogFolder.FullName)" >> $env:GITHUB_ENV

- name: Verify latest log folder contents
shell: powershell
run: |
Get-ChildItem -Path "${{ env.LATEST_LOG_FOLDER }}" -Recurse

- name: Set artifact name
id: set-artifact-name
shell: powershell
run: |
$artifactName = "${{ env.LOG_FOLDER_NAME }}-${{ matrix.name }}"
echo "ARTIFACT_NAME=$artifactName" >> $env:GITHUB_ENV

- name: Upload logs from device ${{ matrix.name }}
if: ${{ always() && env.LATEST_LOG_FOLDER != '' }}
uses: actions/upload-artifact@v4.6.2
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.LATEST_LOG_FOLDER }}\**
if-no-files-found: warn
retention-days: 7
compression-level: 6
overwrite: true
include-hidden-files: false

- name: Test Complete on device ${{ matrix.name }}
if: success()
run: Write-Output "Test run completed successfully"

- name: Test Failed on device ${{ matrix.name }}
if: failure()
run: Write-Output "Test run failed"

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
Comment on lines +15 to +102
name: Run tests on ${{ inputs.device_name }}
runs-on: ${{ inputs.runner_label }}
steps:
- name: Check out the repository
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pywinauto
shell: powershell

- name: Run PowerShell Tests
shell: powershell
working-directory: E2E
run: |
try {
# Run the script and capture all output
$testOutput = .\CheckInTest.ps1 *>&1 | Tee-Object -Variable out

# Check for any test failure in output
if ($out -match ":\s*Failed") {
Write-Error "One or more tests failed."
exit 1
}

# Optional: output full logs to console
$out | ForEach-Object { Write-Host $_ }

} catch {
Write-Error "Test script threw an exception: $_"
exit 1
}

- name: Find the latest log folder
if: always()
id: find-latest-log
shell: powershell
working-directory: E2E\logs
run: |
Write-Output "Changed directory to: $PWD"
$logFolders = Get-ChildItem -Directory
Write-Output "Log folders found: $($logFolders.Name)"
$latestLogFolder = $logFolders | Sort-Object LastWriteTime -Descending | Select-Object -First 1
Write-Output "Latest log folder: $latestLogFolder"
echo "LOG_FOLDER_NAME=$latestLogFolder" >> $env:GITHUB_ENV
echo "LATEST_LOG_FOLDER=$($latestLogFolder.FullName)" >> $env:GITHUB_ENV

- name: Verify latest log folder contents
if: always()
shell: powershell
run: |
Get-ChildItem -Path "${{ env.LATEST_LOG_FOLDER }}" -Recurse

- name: Set artifact name
id: set-artifact-name
if: always()
shell: powershell
run: |
$artifactName = "${{ env.LOG_FOLDER_NAME }}-${{ inputs.device_name }}"
echo "ARTIFACT_NAME=$artifactName" >> $env:GITHUB_ENV

- name: Upload logs from device ${{ inputs.device_name }}
if: ${{ always() && env.LATEST_LOG_FOLDER != '' }}
uses: actions/upload-artifact@v4.6.2
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.LATEST_LOG_FOLDER }}\**
if-no-files-found: warn
retention-days: 7
compression-level: 6
overwrite: true
include-hidden-files: false

- name: Test Complete on device ${{ inputs.device_name }}
if: success()
run: Write-Output "Test run completed successfully"

- name: Test Failed on device ${{ inputs.device_name }}
if: failure()
run: Write-Output "Test run failed"

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant