ModernUO/tools
Kamron Batman 737d3ec4ce
ci(tools): cross-platform check for the blocklist generator; require pwsh 7
TEMPORARY workflow -- delete .github/workflows/tools-ps1-check.yml before merge.

Writing the check immediately found that the script did not parse at all under
Windows PowerShell 5.1, despite claiming to support it. The file is UTF-8
without a BOM, which Windows PowerShell reads as ANSI, and a UTF-8 em dash
decodes to a trailing U+201D -- a smart quote PowerShell accepts as a string
delimiter. Every em dash inside a string ended it early, so the script died in
a wall of parse errors.

Rather than add a BOM (which any editor can silently strip, breaking it again),
the script now targets PowerShell 7 only and the source is ASCII-only. Both
matter together: #requires is only honored once the file parses, so ASCII is
what lets Windows PowerShell print "requires PowerShell 7.0" instead of parse
noise. CI asserts both, and asserts the refusal is clean.

Dropping 5.1 support removes the scaffolding it needed: the File.Move-vs-
File.Replace probe collapses to a single File.Move(src, dst, overwrite) -- one
atomic rename on every platform, and it no longer needs to branch on whether the
destination exists -- the multi-segment Join-Path replaces a manual loop, and the
ServicePointManager TLS pin is gone, since only .NET Framework needed it.

The check runs on Linux, macOS and Windows. It is mostly offline, because the
feed-name filter throws after the Add-Type compile and the cooldown gate but
before any download, which makes "did it reach the filter?" a deterministic
signal. That gives discriminating assertions for the two portability bugs fixed
earlier: a wrong path join makes the script miss a list it should have found and
run instead of skipping, and a culture-sensitive duration parse makes a 3h-old
list look newer than -MinInterval 2.5h. One step does hit the network, using the
smallest feed, since the write and atomic swap need content.

Every step was run locally under pwsh 7 and Windows PowerShell 5.1 before
committing; two bugs in the checks themselves surfaced that way (Write-Host goes
to the information stream, so 2>&1 captured nothing, and the expected throw
aborted the step before its assertion ran).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-25 01:48:54 -07:00
..
Export-IpBlocklist.ps1 ci(tools): cross-platform check for the blocklist generator; require pwsh 7 2026-07-25 01:48:54 -07:00