Skip to content

Commit 7834a12

Browse files
czunkerclaude
andauthored
✨ Add Windows test workflow for PR CI (#6687)
* ✨ Add Windows test workflow for PR CI Extract the Windows test workflow from #6474 to enable running Windows-specific tests (e.g. registry-based detection) in CI. See: #6474 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * 🐛 Fix Windows test workflow to only run Windows-specific tests The previous version ran all tests in the services package on Windows, which included Linux/macOS tests that fail due to path separators and symlinks. Now dynamically discovers packages containing _windows_test.go files and only runs those. See: #6474 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * 🐛 Fix review comments on Windows test workflow - Use relative paths for package discovery (DirectoryName returns absolute) - Filter empty strings from package split to avoid ghost arguments - Propagate go test exit code through Tee-Object - Add -count=1 to disable test caching in CI Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * 🐛 Fix script injection risk and remove push trigger in Windows workflow Pass test packages via environment variable instead of direct interpolation to prevent potential script injection. Remove push trigger to match the PR-only intent of the workflow filename. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8fa9ad4 commit 7834a12

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Windows Tests
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "providers/os/**"
7+
- ".github/workflows/pr-test-windows.yml"
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
windows-test:
14+
runs-on: windows-latest
15+
timeout-minutes: 30
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
19+
20+
- name: Import environment variables from file
21+
shell: bash
22+
run: cat ".github/env" >> $GITHUB_ENV
23+
24+
- name: Install Go
25+
uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
26+
with:
27+
go-version: ">=${{ env.golang-version }}"
28+
cache: false
29+
30+
- name: Find packages with Windows-specific tests
31+
id: find-packages
32+
shell: pwsh
33+
run: |
34+
# Find all _windows_test.go files and extract unique package directories
35+
$repoRoot = (Get-Location).Path -replace '\\','/'
36+
$packages = Get-ChildItem -Path providers/os -Recurse -Filter "*_windows_test.go" |
37+
ForEach-Object {
38+
$rel = ($_.DirectoryName -replace '\\','/').Replace($repoRoot + '/', '')
39+
"./$rel/..."
40+
} |
41+
Sort-Object -Unique
42+
if ($packages.Count -eq 0) {
43+
Write-Output "No Windows-specific test packages found"
44+
echo "has_tests=false" >> $env:GITHUB_OUTPUT
45+
} else {
46+
$pkgList = $packages -join " "
47+
Write-Output "Found Windows test packages: $pkgList"
48+
echo "has_tests=true" >> $env:GITHUB_OUTPUT
49+
echo "packages=$pkgList" >> $env:GITHUB_OUTPUT
50+
}
51+
52+
- name: Run Windows-specific tests
53+
if: steps.find-packages.outputs.has_tests == 'true'
54+
shell: pwsh
55+
env:
56+
WIN_TEST_PACKAGES: ${{ steps.find-packages.outputs.packages }}
57+
run: |
58+
$packages = ($env:WIN_TEST_PACKAGES -split " ") | Where-Object { $_ -ne '' }
59+
go test -count=1 -v @packages 2>&1 | Tee-Object -FilePath windows-test-output.txt
60+
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
61+
62+
- name: Upload test output
63+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
64+
if: steps.find-packages.outputs.has_tests == 'true' && (success() || failure())
65+
with:
66+
name: windows-test-output
67+
path: windows-test-output.txt

0 commit comments

Comments
 (0)