-
Notifications
You must be signed in to change notification settings - Fork 10
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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
.github/workflows/test.yml
Outdated
.\CheckInTest.ps1 # Adjust to your actual script name | ||
|
||
- name: Upload test results (Optional) | ||
if: success() |
There was a problem hiding this comment.
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.
if: success() | |
if: ${{ success() }} |
Copilot uses AI. Check for mistakes.
.github/workflows/test.yml
Outdated
Write-Output "Test run completed successfully" | ||
|
||
- name: Handle failure (Optional) | ||
if: failure() |
There was a problem hiding this comment.
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.
if: failure() | |
if: ${{ failure() }} |
Copilot uses AI. Check for mistakes.
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
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
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
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
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
What changed?
Add workflow to run CheckinTest on self hosted agent
Why changed?
How did you test the change?
Related Issues (if any):