Skip to content
Merged
Changes from 2 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
64 changes: 64 additions & 0 deletions .github/workflows/pr-test-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Windows Tests

on:
push:
paths:
- "providers/os/**"
- ".github/workflows/pr-test-windows.yml"
pull_request:
paths:
- "providers/os/**"
- ".github/workflows/pr-test-windows.yml"

permissions:
contents: read

jobs:
windows-test:
runs-on: windows-latest
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Import environment variables from file
shell: bash
run: cat ".github/env" >> $GITHUB_ENV

- name: Install Go
uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
with:
go-version: ">=${{ env.golang-version }}"
cache: false

- name: Find packages with Windows-specific tests
id: find-packages
shell: pwsh
run: |
# Find all _windows_test.go files and extract unique package directories
$packages = Get-ChildItem -Path providers/os -Recurse -Filter "*_windows_test.go" |
ForEach-Object { "./$($_.DirectoryName -replace '\\','/')/..." } |
Sort-Object -Unique
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 suggestion — Appending /... makes each entry match the package and all sub-packages. If _windows_test.go files exist in both providers/os/a/ and providers/os/a/b/, Sort-Object -Unique won't deduplicate them (different strings), so tests in b will be run twice — once via ./providers/os/a/... and once via ./providers/os/a/b/.... go test tolerates this (no incorrect results), but you could avoid the redundant work by dropping the /... suffix (i.e. use ./$rel) since you're already enumerating every directory that contains test files.

if ($packages.Count -eq 0) {
Write-Output "No Windows-specific test packages found"
echo "has_tests=false" >> $env:GITHUB_OUTPUT
} else {
$pkgList = $packages -join " "
Write-Output "Found Windows test packages: $pkgList"
echo "has_tests=true" >> $env:GITHUB_OUTPUT
echo "packages=$pkgList" >> $env:GITHUB_OUTPUT
}

- name: Run Windows-specific tests
if: steps.find-packages.outputs.has_tests == 'true'
shell: pwsh
run: |
$packages = "${{ steps.find-packages.outputs.packages }}" -split " "
go test -v @packages 2>&1 | Tee-Object -FilePath windows-test-output.txt

- name: Upload test output
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: steps.find-packages.outputs.has_tests == 'true' && (success() || failure())
with:
name: windows-test-output
path: windows-test-output.txt
Loading