gha: start DNS Client service and probe Windows localhost resolution

Addrinfo.getaddrinfo on the Windows CI runners fails for "localhost"
regardless of address family (diagnostic commit a69d12aa54 showed
127.0.0.1 literal resolves fine while "localhost" never does under
AF_INET, AF_INET6, AF_UNSPEC, or nil). That rules out the earlier
KB4057932/AF_INET hypothesis and points at the Dnscache service
being stopped on the runner image.

Start Dnscache if not already running (and set it to Automatic),
then Resolve-DnsName localhost to print the OS-level resolver view
to the log. Existing hosts file and diagnostic assert stay in place
so the single CI round exposes both the service state and its
effect on getaddrinfo.

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Yukihiro "Matz" Matsumoto
2026-04-24 01:39:08 +09:00
parent a69d12aa54
commit 7ae25febbb
+20
View File
@@ -42,8 +42,18 @@ jobs:
if: runner.os == 'Windows'
shell: pwsh
run: |
Write-Host "=== Dnscache service state (before) ==="
Get-Service Dnscache | Format-List Name, Status, StartType
if ((Get-Service Dnscache).Status -ne 'Running') {
Set-Service -Name Dnscache -StartupType Automatic
Start-Service -Name Dnscache
}
Write-Host "=== Dnscache service state (after) ==="
Get-Service Dnscache | Format-List Name, Status, StartType
Add-Content -Path $env:WINDIR\System32\drivers\etc\hosts -Value "127.0.0.1 localhost"
Add-Content -Path $env:WINDIR\System32\drivers\etc\hosts -Value "::1 localhost"
Write-Host "=== Resolve-DnsName localhost ==="
Resolve-DnsName localhost -ErrorAction Continue | Format-List
- name: Build and test
run: rake -m test:run:serial
@@ -88,8 +98,18 @@ jobs:
- name: Ensure localhost resolves
shell: pwsh
run: |
Write-Host "=== Dnscache service state (before) ==="
Get-Service Dnscache | Format-List Name, Status, StartType
if ((Get-Service Dnscache).Status -ne 'Running') {
Set-Service -Name Dnscache -StartupType Automatic
Start-Service -Name Dnscache
}
Write-Host "=== Dnscache service state (after) ==="
Get-Service Dnscache | Format-List Name, Status, StartType
Add-Content -Path $env:WINDIR\System32\drivers\etc\hosts -Value "127.0.0.1 localhost"
Add-Content -Path $env:WINDIR\System32\drivers\etc\hosts -Value "::1 localhost"
Write-Host "=== Resolve-DnsName localhost ==="
Resolve-DnsName localhost -ErrorAction Continue | Format-List
- name: Build and test
shell: cmd
run: |