Repository navigation
feat(cache): opt-in env var to prefer BSD tar on Windows - #2379
Open
zeitlinger wants to merge 2 commits into
Open
zeitlinger wants to merge 2 commits into
zeitlinger wants to merge 2 commits into
Conversation
Set ACTIONS_CACHE_PREFER_BSD_TAR_ON_WINDOWS=true to route cache archive/extract through C:\Windows\System32\tar.exe (libarchive bsdtar) instead of Git-for-Windows' MSYS GNU tar. On hosted windows-latest runners, bsdtar extracts many-small-files payloads ~4x faster than MSYS tar because it makes native Win32 syscalls and has zstd built in (no fork-per-file to zstd.exe). Default behavior is unchanged — this only takes effect when the env var is explicitly set. The existing BSD_TAR_ZSTD two-command path handles the BSD tar case end-to-end. Refs: actions/cache#752 Signed-off-by: Gregor Zeitlinger <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an opt-in Windows behavior switch to prefer the built-in libarchive tar.exe (bsdtar) for cache archive/extract selection, aiming to speed up extraction of caches with many small files while keeping the existing default unchanged.
Changes:
- Introduces
ACTIONS_CACHE_PREFER_BSD_TAR_ON_WINDOWS=trueto selectSystemTarPathOnWindowsahead of GNU tar onwin32when available. - Adds a Windows unit test ensuring the opt-in env var prefers BSD tar even when GNU tar is present.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/cache/src/internal/tar.ts | Adds Windows tar-selection opt-in env var to prefer system bsdtar when present. |
| packages/cache/tests/tar.test.ts | Adds a Windows test covering the new opt-in tar-selection behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Gregor Zeitlinger <[email protected]>
aitorciki
added a commit
to aitorciki/ladxhd-patcher
that referenced
this pull request
May 18, 2026
aitorciki
added a commit
to aitorciki/ladxhd-patcher
that referenced
this pull request
May 18, 2026
Author
|
@robherley can you take a look? |
jorrite
pushed a commit
to jorrite/atmos
that referenced
this pull request
Sep 7, 2026
…action (cloudposse#3049) * ci: guard Windows DNS against harden-runner's post-step race; allowlist OS endpoints Windows jobs have been finishing every step, including "Post Harden Runner" and "Complete job", and then never reporting a conclusion until GitHub cancels them 30-40 minutes later (0/day before harden-runner landed on the Windows legs on Aug 31; 5, 9, 23/day on Sept 1-3). Root cause: harden-runner's Windows post step waits at most 10 s for its agent, then kills it, and in the losing case the agent is still restoring the runner's DNS settings, leaving the adapter pointed at a DNS proxy that no longer exists. - Add .github/actions/windows-dns-guard: a scheduled-task watchdog that resets DNS only once harden-runner's post step has begun, the agent is gone, and 127.0.0.1 is still configured. Wired into every Windows leg. - Allowlist the Windows/macOS operating-system endpoints StepSecurity showed blocked on every job (NCSI probes, WNS, update/settings/telemetry, time sync, Sectigo OCSP/CRL, Apple update/CDN hosts); harden-runner stays in block mode everywhere. - Drop the GOPROXY "|direct" fallback in block-mode workflows: it only fans out to blocked vanity-import hosts. - Cancel superseded pull_request runs via a concurrency group. - Skip SARIF uploads on merge_group runs, whose synthetic ref cannot be scanned and was evicting PRs from the merge queue. Fix log: docs/fixes/2026-09-03-harden-runner-windows-dns-restore-race.md Co-Authored-By: Claude Fable 5.1 <[email protected]> * ci: allow the whole NTP pool (*.pool.ntp.org), not just 0.pool.ntp.org The pool advertises four rotating names (0-3.pool.ntp.org); a single one was only what happened to be sampled. Push deferred until the first CI run of the guard finishes so its Windows data isn't cancelled by the new concurrency group. Co-Authored-By: Claude Fable 5.1 <[email protected]> * ci: address review on the Windows DNS guard - Skip Harden Runner on draft-PR Windows jobs: every other Windows step (including checkout) is already skipped there, so its post step would race the agent's DNS restore with no guard available. - Run the guard's scheduled task as the runner's own Administrator account (S4U) instead of SYSTEM; it grants nothing the job does not already have. - Wrap the plain go mod download steps in pre-commit.yml and codeql.yml with go-mod-download-retry now that GOPROXY has no direct fallback. - Measurement query: filter to Windows jobs and tolerate fractional-second timestamps. Co-Authored-By: Claude Fable 5.1 <[email protected]> * ci: Windows Defender exclusions and restore-only toolchain cache on shards Phase 2 (part 1) of the CI-stability plan, stacked on the Phase 1 branch. Windows Defender: on the Windows shards "Set up Go" averages 5.2 min (max 10.5) restoring a 1.9 GB go-build+mod cache; the download is ~20 s, the rest is tar/zstd extraction with Defender's real-time scanner inspecting every extracted file, and the same scanner holding handles on fresh test files surfaces as testing.TempDir cleanup failures ("unlinkat ... being used by another process"). Add a continue-on-error pwsh step to every Windows leg of test.yml (build, terraform-registry-cache, test, mock) and to setup-go-cache-warmup.yml that excludes D:\a, C:\hostedtoolcache\windows, the Go caches, and the temp dirs, plus go.exe as a process. These are ephemeral VMs and the step does not touch harden-runner's egress policy. Restore-only toolchain cache: the repo's Actions cache is 18.9 GB across 17 refs/pull/N/merge-scoped entries against a 10 GB LRU quota, so the static atmos-toolchain-<os>-<arch>-v2 key never hits ("Cache not found for input keys" on every shard), then all 10 shards race to save it ("Unable to reserve cache with key ...") and "Post Cache Atmos toolchain" costs 43 s avg / 3 min max per shard for nothing. Add an opt-in restore-only input (default 'false') to actions/cache/action.yml that switches to actions/cache/restore at the same pinned SHA, keep cache-hit and key outputs working, document it in the README, and set it on the test job's "Cache Atmos toolchain" step for all three OSes. terraform-registry-cache stays the single writer per OS and is unchanged. Fix log: docs/fixes/2026-09-03-windows-defender-exclusions-and-restore-only-toolchain-cache.md Co-Authored-By: Claude Fable 5.1 <[email protected]> * fix(ci): drop the go.exe Defender process exclusion; it's spoofable Add-MpPreference -ExclusionProcess 'go.exe' matches on image name only, not path, so it would exempt any binary named go.exe from real-time scanning regardless of where it actually lives - including one planted by a compromised dependency during go build/go generate. The path exclusions already in this step cover the actual scanning cost (file I/O in the Go caches and workspace), so removing the process exclusion gives up nothing measured. (Skipped a second CodeRabbit finding on this PR: it asked test/ terraform-registry-cache to needs: a "cache-writer" job that doesn't exist in this file - terraform-registry-cache itself is the writer, and test is deliberately parallel to it so 30 shards don't wait on or race the single writer job. Making test depend on it would serialize two long-running job groups that currently run concurrently.) Co-Authored-By: Claude Sonnet 5 <[email protected]> * temp: diagnostic - dump live Windows Defender state (to be reverted) * Revert "temp: diagnostic - dump live Windows Defender state (to be reverted)" This reverts commit 145a8c4. * ci: drop Windows Defender exclusions, they're a no-op GitHub's own actions/runner-images build script already disables real-time monitoring and excludes C:\ and D:\ entirely on windows-latest images, before any workflow step runs. Confirmed live via a temporary diagnostic step (Get-MpComputerStatus/Get-MpPreference) on an actual windows-latest runner: RealTimeProtectionEnabled was already False and ExclusionPath already {C:\, D:\} before our own Add-MpPreference calls, which only added redundant subpaths already covered by the existing C:\ exclusion. Since Defender was never doing real-time scanning to begin with, it wasn't the cause of the measured Windows slowdown this step was meant to fix - that root cause is still open. Splits the fix-log doc accordingly: the restore-only-toolchain-cache half (unrelated, unaffected) moves to its own file; a new doc records the Defender investigation and reversal so it isn't re-attempted blind later. * ci: add a dispatch-only Windows cache-restore perf lab Restoring our ~1.9 GB go-build+mod cache on windows-2025 hosted runners is ~6.5 minutes of pure tar extraction (download is ~16 s) - 40-60% of every Windows acceptance shard's wall time. Iterating on that through the full Tests suite costs a whole run per experiment. This workflow restores the SAME production setup-go archive under one tar configuration per matrix leg (gnu-tar = exactly what test.yml does today; bsdtar = the proposed fix via a PROGRAMFILES override + System32-first PATH, using only released @actions/cache code), asserts a real cache hit so a miss can never masquerade as a fast restore, prints which tar was actually selected, and writes each leg's "Set up Go" duration to the step summary. A second job reports C:/D: disk topology and a small-file write benchmark on each, to settle whether the D:\ that windows-2025-vs2026 still exposes is a distinct (fast) disk or a path onto the same volume. Evidence for the two measured causes: actions/runner-images#12416/#12647 (D: removed on Windows Server 2025; C: ~540 IOPS, won't-fix) and actions/cache#752 / actions/toolkit#2379 (MSYS GNU tar ~4x slower than native bsdtar on many-small-files archives; PR unmerged). Windows Defender is not a factor: real-time monitoring is disabled at the image level. * ci: run the cache-perf lab on push, no merge to main needed workflow_dispatch only resolves workflows that already exist on the default branch, which would have meant merging the lab before running a single experiment. A push trigger runs the pushed branch's own copy of the file, so every push to a *ci-cache-perf* branch now runs it directly - edit, push, read the step summary, repeat. A per-ref concurrency group lets a newer push supersede a stale in-flight run. workflow_dispatch is kept for once the file is on main. * ci(cache-perf): seed the archive per layout; add a D:-relocated leg The first run missed on both legs: main's setup-go archive is evicted by the 10 GB LRU churn, and the only surviving entries are PR-scoped, which other branches cannot read. A seed job per cache layout now populates a real go-build+mod archive (go mod download + go build ./...) that setup-go's post step saves under this branch, so the timed legs always restore something real. The topology job measured D: as a separate disk with ~8.8x the small-file write rate of C: (4,545 vs 515 files/s), so a third leg relocates GOCACHE and GOMODCACHE to D:\a\ before setup-go (actions/setup-go#515). It needs its own seed: the cache version hashes the restore paths and the archive holds absolute paths, so seed and restore must agree on layout. Co-Authored-By: Claude Fable 5.1 <[email protected]> * ci(cache-perf): pair each restore with its own seed; move steps to a composite The second run lost the D: seed's archive before its restore leg ran: this repo's cache sits at the 10 GB quota (9.9 GB across 5 entries, ~1.8 GB per Windows setup-go archive), so every save evicts the least recently used entries, and the restore legs waited on both seeds - nine minutes during which the D: archive was the oldest unread entry. Now each layout is its own seed -> restore pair, so a restore starts (and touches its archive) seconds after its seed saved it. Each layout also gets its own cache key via a marker file hashed through cache-dependency-path. The shared step sequence moves into .github/actions/cache-perf-lab, which times the restore with its own clock since the jobs API does not list nested composite steps. Measured so far (both seeds through bsdtar): the cache save dropped from 590 s on C: to 175 s on D:, and go build ./... from 599 s to 455 s. On C:, gnu-tar restored in 276 s and bsdtar in 295 s. Co-Authored-By: Claude Fable 5.1 <[email protected]> * ci(cache-perf): select bsdtar by renaming Git's tar aside; record D: numbers Run 2's "bsdtar" legs silently used GNU tar: a step-level PROGRAMFILES override does not take effect on Windows runners (the process keeps its own ProgramFiles value), so @actions/cache's hardcoded %PROGRAMFILES%\Git\usr\bin\tar.exe existence check kept passing. The composite now takes tar: gnu|bsd and, for bsd, renames Git's tar.exe aside for the job and puts C:\Windows\System32 first on PATH, so the toolkit's PATH lookup lands on bsdtar. Nothing else in the job needs Git's tar. Measured so far with GNU tar on both sides: restore 276 s on C: vs 94 s on D: (same 1.7 GB archive); save 590 s vs 175 s; go build 599 s vs 455 s. Co-Authored-By: Claude Fable 5.1 <[email protected]> * ci: put Windows Go caches on the fast work disk via a setup-go-cache action New .github/actions/setup-go-cache: pinned actions/setup-go with caching, plus one Windows-specific step before it - relocate GOCACHE and GOMODCACHE onto the runner's work disk (derived from RUNNER_TEMP) when that is a different drive from LOCALAPPDATA, where Go's defaults live. On windows-latest that is D:, a separate disk with ~8.8x the small-file write rate of C:. No-op on Linux/macOS or on an image without the split. Measured with the cache-perf lab on our ~1.7 GB go-build+mod archive: restore 276 s -> 94 s, save 590 s -> 175 s, go build ./... 599 s -> 455 s. All eight setup-go call sites in test.yml that run on v5.6.0 (or on Windows) and the cache-warmup workflow now use the action, so the pattern lives in one place; the Linux-only coverage job stays on setup-go v6. terraform-registry-cache moves from setup-go v6 to the action's v5.6.0. The lab's D: layout now runs this exact action, so cache-perf.yml keeps measuring what production runs. Co-Authored-By: Claude Fable 5.1 <[email protected]> * docs(fixes): Windows Go caches on the fast disk; measured tar numbers at the GNU tar steps Run 4 of the lab settles the tar question: with real bsdtar (Git's tar renamed aside) the restore takes 353 s on C: and 117 s on D: against GNU tar's 264 s and 94 s, because @actions/cache's bsdtar path decompresses the whole archive to a .tar on disk before extracting. The GNU tar steps stay, now with the measured justification instead of the unmeasured 2024 belief; the lab keeps the bsdtar leg for re-checks. Co-Authored-By: Claude Fable 5.1 <[email protected]> * ci(cache-perf): record the bsdtar result in the lab header Co-Authored-By: Claude Fable 5.1 <[email protected]> * ci: drop the cache-perf lab; the numbers and method live in the fix-log The lab did its job (four runs, every number in docs/fixes/2026-09-04-windows-go-caches-on-fast-disk.md) and is not worth maintaining on main. It remains in this branch's history at 8fe6ed6 if it is ever needed again. Co-Authored-By: Claude Fable 5.1 <[email protected]> * ci: codify the GNU tar choice as a windows-gnu-tar action The four hand-copied "Add GNU tar to PATH" steps become one idempotent local action. setup-go-cache calls it first, since both of setup-go's cache archives go through @actions/cache; the three jobs whose toolchain cache step runs before Set up Go (terraform-registry-cache, test, mock) call it directly at that point. No-op off Windows. Co-Authored-By: Claude Fable 5.1 <[email protected]> * ci: give the published actions/cache action its own GNU tar step on Windows The Atmos Cache action is consumed from other repositories, so it cannot reference the local windows-gnu-tar action; it carries the same idempotent step inline instead, which also gives every consumer the faster restores on Windows runners. With both cache-using actions provisioning their own tar, the explicit calls before the toolchain cache steps in test.yml go away. Co-Authored-By: Claude Fable 5.1 <[email protected]> * docs(fixes): toolchain cache measured; stays on C: Co-Authored-By: Claude Fable 5.1 <[email protected]> * feat(actions/cache): cache-home input to put the Atmos cache root on a chosen disk The published action's archive is whatever the consumer's ci.cache covers, which can be exactly the small-file kind the fast work disk helps. Since the paths derive from Atmos's cache root, the action cannot move the archive alone; cache-home exports ATMOS_XDG_CACHE_HOME for the rest of the job so toolchain installs, the cache save and the cached paths agree. Opt-in: moving a consumer's cache root silently would be a behavior change, and jobs whose tests assert the default locations (our own acceptance shards) must not use it. README documents both Windows levers and the one-time cold start. Co-Authored-By: Claude Fable 5.1 <[email protected]> * docs(fixes): first production numbers for the Windows Go cache on D: Co-Authored-By: Claude Fable 5.1 <[email protected]> * ci(setup-go-cache): put Go's temp dirs on the work disk too GOTMPDIR (Go's build scratch) and TEMP/TMP (what t.TempDir() and os.TempDir() resolve from) default to %LOCALAPPDATA%\Temp on the slow C: disk, so every fixture copy and scratch file the acceptance tests make paid the same small-file IOPS penalty as the caches did. Spotted from a test log path (C:\Users\RUNNER~1\AppData\Local\Temp\TestParse...). Co-Authored-By: Claude Fable 5.1 <[email protected]> * ci(setup-go-cache): temp dir beside RUNNER_TEMP, not under it RUNNER_TEMP is D:\a\_temp, and atmos's output layer mangles the "\_" in such paths into "_" (a Markdown-escape bug, tracked separately), so with TEMP under it the toolchain clean tests failed on the printed path (D:\a_temp\... vs D:\a\_temp\...). D:\a\tmp has no such sequence; the Go cache paths keep theirs since they never appear in atmos output. Co-Authored-By: Claude Fable 5.1 <[email protected]> * docs(fixes): temp dirs on the work disk: shard timings and the \_ output bug Co-Authored-By: Claude Fable 5.1 <[email protected]> * ci(actions/cache): reject CR/LF in cache-home and pin the README example Address CodeRabbit findings: a newline in cache-home would let it inject extra variables into GITHUB_ENV, and the Windows example referenced @main instead of the pinned-release convention documented just below it. Co-Authored-By: Claude Fable 5.1 <[email protected]> * ci(actions/cache): a mode input instead of a restore-only boolean restore-and-save (default) or restore-only. A value lets a caller pass its own mode straight through in one step; the boolean made every caller branch on which step to run. Co-Authored-By: Claude Fable 5.1 <[email protected]> * fix(actions/cache): make the post-step save work when nested in a composite action Post steps of an action nested inside another composite action do not see steps.*.outputs (actions/runner#2800): called from a repo-local toolchain action, actions/cache's save ran with an empty path ("Input required and not supplied: path") and stored nothing. The key, paths and restore-keys now also go through the job env, which post steps do see. Co-Authored-By: Claude Fable 5.1 <[email protected]> * docs(fixes): nested post-step save and the mode input Co-Authored-By: Claude Fable 5.1 <[email protected]> * docs: fix CodeRabbit-flagged doc issues on the cache/Defender fix notes - Correct cache entry total to 22, matching the listed 14 setup-go-* + 8 atmos-toolchain-* breakdown. - Fix the python3 YAML-validation snippet: f was never bound, so copying it raised NameError. Wrap it in a shell loop instead. - Add a text fence language to the unfenced diagnostic output block (markdownlint MD040). Co-Authored-By: Claude Sonnet 5 <[email protected]> * test(testhelpers): keep one record per fake-runtime invocation with multi-line args The fake container runtime wrote each invocation as one tab-joined line; a forwarded -e KEY=VALUE for a multi-line environment variable (ATMOS_CACHE_PATH, exported by the cache action for its nested post step) split the record and the container-override tests lost the interpreter fields on Windows shard 1. Newlines and tabs inside an argument are now escaped in the record. Co-Authored-By: Claude Fable 5.1 <[email protected]> * fix(actions/cache): CR/LF guard, collision-safe delimiter, strict mode validation - Reject CR/LF in the resolved cache key before writing it as a single-line KEY=VALUE record to GITHUB_ENV (mirrors the existing cache-home guard in the same file); an embedded newline could otherwise inject arbitrary extra environment variables. - Use a random per-run delimiter for the multiline PATH/RESTORE_KEYS exports instead of a fixed one, since a cache path or restore key containing the literal delimiter line could end the heredoc early and inject assignments. - Add an explicit mode input validation step: an unrecognized value (e.g. a restore_only typo) previously fell through to the restore-and-save default silently, defeating the whole point of restore-only on fan-out shards. - tests/testhelpers/fake_container_runtime.go: escape backslash before newline/tab in recordArgs so the encoding is unambiguous -- a literal "\n" in an argument and an actual embedded newline previously produced identical encoded output. - docs/fixes: markdownlint MD018 fix (hard-wrapped issue reference). * fix(test): revert backslash-escaping in fake_container_runtime recordArgs A same-PR fix for a CodeRabbit finding (encoding ambiguity: a literal "\n" in an argument vs. an actual embedded newline) escaped backslash before newline/tab. That broke every Windows path argument recorded through this helper: every consumer (pkg/runner/step, cmd/custom_command_*_test.go, pkg/container, pkg/workflow) reads the log with a plain strings.Split on tabs and compares fields directly against real filesystem paths -- none of them decode escapes back out. Confirmed via TestCustomCommandContainerBuildPassesWithBlockToDocker failing deterministically (not flaky -- reproduced on rerun) on the Windows acceptance shard with every path separator doubled. The encoding ambiguity CodeRabbit flagged is real but was never exploitable: no caller has ever decoded this format. Revert rather than add a decoder nobody needs, restoring the behavior every existing consumer already depends on. * feat(ci/cache): atmos ci cache paths writes GITHUB_ENV directly; collapse action.yml bash actions/cache/action.yml's meta/validate/export steps (~35 lines of hand-rolled bash) existed only because a nested composite's post step can't see the outer step's steps.*.outputs (actions/runner#2800), so the action re-derived and re-wrote the same key/path/restore-keys to $GITHUB_ENV by hand -- duplicating, less safely, what pkg/github/actions already does correctly for $GITHUB_OUTPUT (collision-safe delimiter generation, tested). - cmd/ci/cache/paths.go: emitGitHubCachePaths now also writes ATMOS_CACHE_KEY/ATMOS_CACHE_PATH/ATMOS_CACHE_RESTORE_KEYS to $GITHUB_ENV (via the same env.Output/ghactions.FormatValue used for $GITHUB_OUTPUT) whenever $GITHUB_ENV is set, with explicit empty-key/empty-paths validation replacing the old bash checks. - errors/errors.go: new ErrCachePathsRequired sentinel, alongside the existing ErrCacheKeyRequired. - actions/cache/action.yml: meta+validate+export collapse into the one `atmos ci cache paths --format=github` line the action already mostly was. The CR/LF and delimiter-collision finding classes from the previous commit can't recur now that this is one tested Go code path instead of every consumer's own bash. * fix(ci/cache): isolate tests from ambient GITHUB_ENV, wrap write error; update stale regression test - cmd/ci/cache: this package's test binary runs inside real GitHub Actions CI, so every github-format test would otherwise inherit an ambient GITHUB_ENV left over from the job -- emitGitHubCachePaths writes to it whenever set, so an unrelated test could leak fixture cache metadata into the real job's environment file. initTestIO (called by every test in the package) now clears it by default; tests that specifically exercise the write path override it explicitly. Added a regression test proving initTestIO clears an ambient value. Also wrapped the GITHUB_ENV write's error so it's distinguishable from the preceding GITHUB_OUTPUT write's error. - cmd/docker_and_action_regression_test.go: TestAtmosCacheActionValidatesMetadataBeforeActionsCache asserted the exact bash validation strings the previous commit removed from action.yml (validation now lives in Go -- see TestEmitGitHubCachePaths_EmptyKey/_EmptyPaths). Failing across every acceptance shard and the race suite. Updated to check the real invariant -- metadata is still derived via `atmos ci cache paths --format=github` before either terminal cache step runs -- instead of bash string literals that no longer exist. --------- Co-authored-by: Claude Fable 5.1 <[email protected]>
jorrite
pushed a commit
to jorrite/atmos
that referenced
this pull request
Sep 7, 2026
…#3038) * ci: guard Windows DNS against harden-runner's post-step race; allowlist OS endpoints Windows jobs have been finishing every step, including "Post Harden Runner" and "Complete job", and then never reporting a conclusion until GitHub cancels them 30-40 minutes later (0/day before harden-runner landed on the Windows legs on Aug 31; 5, 9, 23/day on Sept 1-3). Root cause: harden-runner's Windows post step waits at most 10 s for its agent, then kills it, and in the losing case the agent is still restoring the runner's DNS settings, leaving the adapter pointed at a DNS proxy that no longer exists. - Add .github/actions/windows-dns-guard: a scheduled-task watchdog that resets DNS only once harden-runner's post step has begun, the agent is gone, and 127.0.0.1 is still configured. Wired into every Windows leg. - Allowlist the Windows/macOS operating-system endpoints StepSecurity showed blocked on every job (NCSI probes, WNS, update/settings/telemetry, time sync, Sectigo OCSP/CRL, Apple update/CDN hosts); harden-runner stays in block mode everywhere. - Drop the GOPROXY "|direct" fallback in block-mode workflows: it only fans out to blocked vanity-import hosts. - Cancel superseded pull_request runs via a concurrency group. - Skip SARIF uploads on merge_group runs, whose synthetic ref cannot be scanned and was evicting PRs from the merge queue. Fix log: docs/fixes/2026-09-03-harden-runner-windows-dns-restore-race.md Co-Authored-By: Claude Fable 5.1 <[email protected]> * ci: allow the whole NTP pool (*.pool.ntp.org), not just 0.pool.ntp.org The pool advertises four rotating names (0-3.pool.ntp.org); a single one was only what happened to be sampled. Push deferred until the first CI run of the guard finishes so its Windows data isn't cancelled by the new concurrency group. Co-Authored-By: Claude Fable 5.1 <[email protected]> * ci: address review on the Windows DNS guard - Skip Harden Runner on draft-PR Windows jobs: every other Windows step (including checkout) is already skipped there, so its post step would race the agent's DNS restore with no guard available. - Run the guard's scheduled task as the runner's own Administrator account (S4U) instead of SYSTEM; it grants nothing the job does not already have. - Wrap the plain go mod download steps in pre-commit.yml and codeql.yml with go-mod-download-retry now that GOPROXY has no direct fallback. - Measurement query: filter to Windows jobs and tolerate fractional-second timestamps. Co-Authored-By: Claude Fable 5.1 <[email protected]> * ci: Windows Defender exclusions and restore-only toolchain cache on shards Phase 2 (part 1) of the CI-stability plan, stacked on the Phase 1 branch. Windows Defender: on the Windows shards "Set up Go" averages 5.2 min (max 10.5) restoring a 1.9 GB go-build+mod cache; the download is ~20 s, the rest is tar/zstd extraction with Defender's real-time scanner inspecting every extracted file, and the same scanner holding handles on fresh test files surfaces as testing.TempDir cleanup failures ("unlinkat ... being used by another process"). Add a continue-on-error pwsh step to every Windows leg of test.yml (build, terraform-registry-cache, test, mock) and to setup-go-cache-warmup.yml that excludes D:\a, C:\hostedtoolcache\windows, the Go caches, and the temp dirs, plus go.exe as a process. These are ephemeral VMs and the step does not touch harden-runner's egress policy. Restore-only toolchain cache: the repo's Actions cache is 18.9 GB across 17 refs/pull/N/merge-scoped entries against a 10 GB LRU quota, so the static atmos-toolchain-<os>-<arch>-v2 key never hits ("Cache not found for input keys" on every shard), then all 10 shards race to save it ("Unable to reserve cache with key ...") and "Post Cache Atmos toolchain" costs 43 s avg / 3 min max per shard for nothing. Add an opt-in restore-only input (default 'false') to actions/cache/action.yml that switches to actions/cache/restore at the same pinned SHA, keep cache-hit and key outputs working, document it in the README, and set it on the test job's "Cache Atmos toolchain" step for all three OSes. terraform-registry-cache stays the single writer per OS and is unchanged. Fix log: docs/fixes/2026-09-03-windows-defender-exclusions-and-restore-only-toolchain-cache.md Co-Authored-By: Claude Fable 5.1 <[email protected]> * fix(ci): drop the go.exe Defender process exclusion; it's spoofable Add-MpPreference -ExclusionProcess 'go.exe' matches on image name only, not path, so it would exempt any binary named go.exe from real-time scanning regardless of where it actually lives - including one planted by a compromised dependency during go build/go generate. The path exclusions already in this step cover the actual scanning cost (file I/O in the Go caches and workspace), so removing the process exclusion gives up nothing measured. (Skipped a second CodeRabbit finding on this PR: it asked test/ terraform-registry-cache to needs: a "cache-writer" job that doesn't exist in this file - terraform-registry-cache itself is the writer, and test is deliberately parallel to it so 30 shards don't wait on or race the single writer job. Making test depend on it would serialize two long-running job groups that currently run concurrently.) Co-Authored-By: Claude Sonnet 5 <[email protected]> * temp: diagnostic - dump live Windows Defender state (to be reverted) * Revert "temp: diagnostic - dump live Windows Defender state (to be reverted)" This reverts commit 145a8c4. * ci: drop Windows Defender exclusions, they're a no-op GitHub's own actions/runner-images build script already disables real-time monitoring and excludes C:\ and D:\ entirely on windows-latest images, before any workflow step runs. Confirmed live via a temporary diagnostic step (Get-MpComputerStatus/Get-MpPreference) on an actual windows-latest runner: RealTimeProtectionEnabled was already False and ExclusionPath already {C:\, D:\} before our own Add-MpPreference calls, which only added redundant subpaths already covered by the existing C:\ exclusion. Since Defender was never doing real-time scanning to begin with, it wasn't the cause of the measured Windows slowdown this step was meant to fix - that root cause is still open. Splits the fix-log doc accordingly: the restore-only-toolchain-cache half (unrelated, unaffected) moves to its own file; a new doc records the Defender investigation and reversal so it isn't re-attempted blind later. * ci: add a dispatch-only Windows cache-restore perf lab Restoring our ~1.9 GB go-build+mod cache on windows-2025 hosted runners is ~6.5 minutes of pure tar extraction (download is ~16 s) - 40-60% of every Windows acceptance shard's wall time. Iterating on that through the full Tests suite costs a whole run per experiment. This workflow restores the SAME production setup-go archive under one tar configuration per matrix leg (gnu-tar = exactly what test.yml does today; bsdtar = the proposed fix via a PROGRAMFILES override + System32-first PATH, using only released @actions/cache code), asserts a real cache hit so a miss can never masquerade as a fast restore, prints which tar was actually selected, and writes each leg's "Set up Go" duration to the step summary. A second job reports C:/D: disk topology and a small-file write benchmark on each, to settle whether the D:\ that windows-2025-vs2026 still exposes is a distinct (fast) disk or a path onto the same volume. Evidence for the two measured causes: actions/runner-images#12416/#12647 (D: removed on Windows Server 2025; C: ~540 IOPS, won't-fix) and actions/cache#752 / actions/toolkit#2379 (MSYS GNU tar ~4x slower than native bsdtar on many-small-files archives; PR unmerged). Windows Defender is not a factor: real-time monitoring is disabled at the image level. * ci: run the cache-perf lab on push, no merge to main needed workflow_dispatch only resolves workflows that already exist on the default branch, which would have meant merging the lab before running a single experiment. A push trigger runs the pushed branch's own copy of the file, so every push to a *ci-cache-perf* branch now runs it directly - edit, push, read the step summary, repeat. A per-ref concurrency group lets a newer push supersede a stale in-flight run. workflow_dispatch is kept for once the file is on main. * ci(cache-perf): seed the archive per layout; add a D:-relocated leg The first run missed on both legs: main's setup-go archive is evicted by the 10 GB LRU churn, and the only surviving entries are PR-scoped, which other branches cannot read. A seed job per cache layout now populates a real go-build+mod archive (go mod download + go build ./...) that setup-go's post step saves under this branch, so the timed legs always restore something real. The topology job measured D: as a separate disk with ~8.8x the small-file write rate of C: (4,545 vs 515 files/s), so a third leg relocates GOCACHE and GOMODCACHE to D:\a\ before setup-go (actions/setup-go#515). It needs its own seed: the cache version hashes the restore paths and the archive holds absolute paths, so seed and restore must agree on layout. Co-Authored-By: Claude Fable 5.1 <[email protected]> * ci(cache-perf): pair each restore with its own seed; move steps to a composite The second run lost the D: seed's archive before its restore leg ran: this repo's cache sits at the 10 GB quota (9.9 GB across 5 entries, ~1.8 GB per Windows setup-go archive), so every save evicts the least recently used entries, and the restore legs waited on both seeds - nine minutes during which the D: archive was the oldest unread entry. Now each layout is its own seed -> restore pair, so a restore starts (and touches its archive) seconds after its seed saved it. Each layout also gets its own cache key via a marker file hashed through cache-dependency-path. The shared step sequence moves into .github/actions/cache-perf-lab, which times the restore with its own clock since the jobs API does not list nested composite steps. Measured so far (both seeds through bsdtar): the cache save dropped from 590 s on C: to 175 s on D:, and go build ./... from 599 s to 455 s. On C:, gnu-tar restored in 276 s and bsdtar in 295 s. Co-Authored-By: Claude Fable 5.1 <[email protected]> * ci(cache-perf): select bsdtar by renaming Git's tar aside; record D: numbers Run 2's "bsdtar" legs silently used GNU tar: a step-level PROGRAMFILES override does not take effect on Windows runners (the process keeps its own ProgramFiles value), so @actions/cache's hardcoded %PROGRAMFILES%\Git\usr\bin\tar.exe existence check kept passing. The composite now takes tar: gnu|bsd and, for bsd, renames Git's tar.exe aside for the job and puts C:\Windows\System32 first on PATH, so the toolkit's PATH lookup lands on bsdtar. Nothing else in the job needs Git's tar. Measured so far with GNU tar on both sides: restore 276 s on C: vs 94 s on D: (same 1.7 GB archive); save 590 s vs 175 s; go build 599 s vs 455 s. Co-Authored-By: Claude Fable 5.1 <[email protected]> * ci: put Windows Go caches on the fast work disk via a setup-go-cache action New .github/actions/setup-go-cache: pinned actions/setup-go with caching, plus one Windows-specific step before it - relocate GOCACHE and GOMODCACHE onto the runner's work disk (derived from RUNNER_TEMP) when that is a different drive from LOCALAPPDATA, where Go's defaults live. On windows-latest that is D:, a separate disk with ~8.8x the small-file write rate of C:. No-op on Linux/macOS or on an image without the split. Measured with the cache-perf lab on our ~1.7 GB go-build+mod archive: restore 276 s -> 94 s, save 590 s -> 175 s, go build ./... 599 s -> 455 s. All eight setup-go call sites in test.yml that run on v5.6.0 (or on Windows) and the cache-warmup workflow now use the action, so the pattern lives in one place; the Linux-only coverage job stays on setup-go v6. terraform-registry-cache moves from setup-go v6 to the action's v5.6.0. The lab's D: layout now runs this exact action, so cache-perf.yml keeps measuring what production runs. Co-Authored-By: Claude Fable 5.1 <[email protected]> * docs(fixes): Windows Go caches on the fast disk; measured tar numbers at the GNU tar steps Run 4 of the lab settles the tar question: with real bsdtar (Git's tar renamed aside) the restore takes 353 s on C: and 117 s on D: against GNU tar's 264 s and 94 s, because @actions/cache's bsdtar path decompresses the whole archive to a .tar on disk before extracting. The GNU tar steps stay, now with the measured justification instead of the unmeasured 2024 belief; the lab keeps the bsdtar leg for re-checks. Co-Authored-By: Claude Fable 5.1 <[email protected]> * ci(cache-perf): record the bsdtar result in the lab header Co-Authored-By: Claude Fable 5.1 <[email protected]> * ci: drop the cache-perf lab; the numbers and method live in the fix-log The lab did its job (four runs, every number in docs/fixes/2026-09-04-windows-go-caches-on-fast-disk.md) and is not worth maintaining on main. It remains in this branch's history at 8fe6ed6 if it is ever needed again. Co-Authored-By: Claude Fable 5.1 <[email protected]> * ci: codify the GNU tar choice as a windows-gnu-tar action The four hand-copied "Add GNU tar to PATH" steps become one idempotent local action. setup-go-cache calls it first, since both of setup-go's cache archives go through @actions/cache; the three jobs whose toolchain cache step runs before Set up Go (terraform-registry-cache, test, mock) call it directly at that point. No-op off Windows. Co-Authored-By: Claude Fable 5.1 <[email protected]> * ci: give the published actions/cache action its own GNU tar step on Windows The Atmos Cache action is consumed from other repositories, so it cannot reference the local windows-gnu-tar action; it carries the same idempotent step inline instead, which also gives every consumer the faster restores on Windows runners. With both cache-using actions provisioning their own tar, the explicit calls before the toolchain cache steps in test.yml go away. Co-Authored-By: Claude Fable 5.1 <[email protected]> * docs(fixes): toolchain cache measured; stays on C: Co-Authored-By: Claude Fable 5.1 <[email protected]> * feat(actions/cache): cache-home input to put the Atmos cache root on a chosen disk The published action's archive is whatever the consumer's ci.cache covers, which can be exactly the small-file kind the fast work disk helps. Since the paths derive from Atmos's cache root, the action cannot move the archive alone; cache-home exports ATMOS_XDG_CACHE_HOME for the rest of the job so toolchain installs, the cache save and the cached paths agree. Opt-in: moving a consumer's cache root silently would be a behavior change, and jobs whose tests assert the default locations (our own acceptance shards) must not use it. README documents both Windows levers and the one-time cold start. Co-Authored-By: Claude Fable 5.1 <[email protected]> * docs(fixes): first production numbers for the Windows Go cache on D: Co-Authored-By: Claude Fable 5.1 <[email protected]> * ci(setup-go-cache): put Go's temp dirs on the work disk too GOTMPDIR (Go's build scratch) and TEMP/TMP (what t.TempDir() and os.TempDir() resolve from) default to %LOCALAPPDATA%\Temp on the slow C: disk, so every fixture copy and scratch file the acceptance tests make paid the same small-file IOPS penalty as the caches did. Spotted from a test log path (C:\Users\RUNNER~1\AppData\Local\Temp\TestParse...). Co-Authored-By: Claude Fable 5.1 <[email protected]> * ci(setup-go-cache): temp dir beside RUNNER_TEMP, not under it RUNNER_TEMP is D:\a\_temp, and atmos's output layer mangles the "\_" in such paths into "_" (a Markdown-escape bug, tracked separately), so with TEMP under it the toolchain clean tests failed on the printed path (D:\a_temp\... vs D:\a\_temp\...). D:\a\tmp has no such sequence; the Go cache paths keep theirs since they never appear in atmos output. Co-Authored-By: Claude Fable 5.1 <[email protected]> * docs(fixes): temp dirs on the work disk: shard timings and the \_ output bug Co-Authored-By: Claude Fable 5.1 <[email protected]> * ci(actions/cache): reject CR/LF in cache-home and pin the README example Address CodeRabbit findings: a newline in cache-home would let it inject extra variables into GITHUB_ENV, and the Windows example referenced @main instead of the pinned-release convention documented just below it. Co-Authored-By: Claude Fable 5.1 <[email protected]> * ci(actions/cache): a mode input instead of a restore-only boolean restore-and-save (default) or restore-only. A value lets a caller pass its own mode straight through in one step; the boolean made every caller branch on which step to run. Co-Authored-By: Claude Fable 5.1 <[email protected]> * fix(actions/cache): make the post-step save work when nested in a composite action Post steps of an action nested inside another composite action do not see steps.*.outputs (actions/runner#2800): called from a repo-local toolchain action, actions/cache's save ran with an empty path ("Input required and not supplied: path") and stored nothing. The key, paths and restore-keys now also go through the job env, which post steps do see. Co-Authored-By: Claude Fable 5.1 <[email protected]> * docs(fixes): nested post-step save and the mode input Co-Authored-By: Claude Fable 5.1 <[email protected]> * docs: fix CodeRabbit-flagged doc issues on the cache/Defender fix notes - Correct cache entry total to 22, matching the listed 14 setup-go-* + 8 atmos-toolchain-* breakdown. - Fix the python3 YAML-validation snippet: f was never bound, so copying it raised NameError. Wrap it in a shell loop instead. - Add a text fence language to the unfenced diagnostic output block (markdownlint MD040). Co-Authored-By: Claude Sonnet 5 <[email protected]> * test(testhelpers): keep one record per fake-runtime invocation with multi-line args The fake container runtime wrote each invocation as one tab-joined line; a forwarded -e KEY=VALUE for a multi-line environment variable (ATMOS_CACHE_PATH, exported by the cache action for its nested post step) split the record and the container-override tests lost the interpreter fields on Windows shard 1. Newlines and tabs inside an argument are now escaped in the record. Co-Authored-By: Claude Fable 5.1 <[email protected]> * ci(actions/cache): keep restore-only as a deprecated mode alias Not fixing an actual break -- restore-only never shipped on main or in any release, so nothing external depends on it (confirmed via git history: introduced and replaced by mode entirely within this same unmerged branch). Adding it back anyway as cheap, harmless insurance: restore-only: true still maps to mode: restore-only, documented as deprecated in favor of mode. * fix(actions/cache): CR/LF guard, collision-safe delimiter, strict mode validation - Reject CR/LF in the resolved cache key before writing it as a single-line KEY=VALUE record to GITHUB_ENV (mirrors the existing cache-home guard in the same file); an embedded newline could otherwise inject arbitrary extra environment variables. - Use a random per-run delimiter for the multiline PATH/RESTORE_KEYS exports instead of a fixed one, since a cache path or restore key containing the literal delimiter line could end the heredoc early and inject assignments. - Add an explicit mode input validation step: an unrecognized value (e.g. a restore_only typo) previously fell through to the restore-and-save default silently, defeating the whole point of restore-only on fan-out shards. - tests/testhelpers/fake_container_runtime.go: escape backslash before newline/tab in recordArgs so the encoding is unambiguous -- a literal "\n" in an argument and an actual embedded newline previously produced identical encoded output. - docs/fixes: markdownlint MD018 fix (hard-wrapped issue reference). * fix(test): revert backslash-escaping in fake_container_runtime recordArgs A same-PR fix for a CodeRabbit finding (encoding ambiguity: a literal "\n" in an argument vs. an actual embedded newline) escaped backslash before newline/tab. That broke every Windows path argument recorded through this helper: every consumer (pkg/runner/step, cmd/custom_command_*_test.go, pkg/container, pkg/workflow) reads the log with a plain strings.Split on tabs and compares fields directly against real filesystem paths -- none of them decode escapes back out. Confirmed via TestCustomCommandContainerBuildPassesWithBlockToDocker failing deterministically (not flaky -- reproduced on rerun) on the Windows acceptance shard with every path separator doubled. The encoding ambiguity CodeRabbit flagged is real but was never exploitable: no caller has ever decoded this format. Revert rather than add a decoder nobody needs, restoring the behavior every existing consumer already depends on. * feat(ci/cache): atmos ci cache paths writes GITHUB_ENV directly; collapse action.yml bash actions/cache/action.yml's meta/validate/export steps (~35 lines of hand-rolled bash) existed only because a nested composite's post step can't see the outer step's steps.*.outputs (actions/runner#2800), so the action re-derived and re-wrote the same key/path/restore-keys to $GITHUB_ENV by hand -- duplicating, less safely, what pkg/github/actions already does correctly for $GITHUB_OUTPUT (collision-safe delimiter generation, tested). - cmd/ci/cache/paths.go: emitGitHubCachePaths now also writes ATMOS_CACHE_KEY/ATMOS_CACHE_PATH/ATMOS_CACHE_RESTORE_KEYS to $GITHUB_ENV (via the same env.Output/ghactions.FormatValue used for $GITHUB_OUTPUT) whenever $GITHUB_ENV is set, with explicit empty-key/empty-paths validation replacing the old bash checks. - errors/errors.go: new ErrCachePathsRequired sentinel, alongside the existing ErrCacheKeyRequired. - actions/cache/action.yml: meta+validate+export collapse into the one `atmos ci cache paths --format=github` line the action already mostly was. The CR/LF and delimiter-collision finding classes from the previous commit can't recur now that this is one tested Go code path instead of every consumer's own bash. * fix(ci/cache): isolate tests from ambient GITHUB_ENV, wrap write error; update stale regression test - cmd/ci/cache: this package's test binary runs inside real GitHub Actions CI, so every github-format test would otherwise inherit an ambient GITHUB_ENV left over from the job -- emitGitHubCachePaths writes to it whenever set, so an unrelated test could leak fixture cache metadata into the real job's environment file. initTestIO (called by every test in the package) now clears it by default; tests that specifically exercise the write path override it explicitly. Added a regression test proving initTestIO clears an ambient value. Also wrapped the GITHUB_ENV write's error so it's distinguishable from the preceding GITHUB_OUTPUT write's error. - cmd/docker_and_action_regression_test.go: TestAtmosCacheActionValidatesMetadataBeforeActionsCache asserted the exact bash validation strings the previous commit removed from action.yml (validation now lives in Go -- see TestEmitGitHubCachePaths_EmptyKey/_EmptyPaths). Failing across every acceptance shard and the race suite. Updated to check the real invariant -- metadata is still derived via `atmos ci cache paths --format=github` before either terminal cache step runs -- instead of bash string literals that no longer exist. * docs(ci): fix stale setup-go v6 comment and race-job exception note - .github/actions/setup-go-cache/action.yml: remove a leftover "setup-go v6" comment copy-pasted from a different call site; this action pins v5.6.0 and the v6-specific note about runner requirements doesn't apply. - docs/fixes/2026-09-04-windows-go-caches-on-fast-disk.md: the "adopted everywhere on Windows or v5.6.0" claim missed the race job, which still pins v5.6.0 directly (no Windows disk-relocation work needed). --------- Co-authored-by: Claude Fable 5.1 <[email protected]>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an opt-in env var
ACTIONS_CACHE_PREFER_BSD_TAR_ON_WINDOWSthat routescache archive/extract through
C:\Windows\System32\tar.exe(libarchive bsdtar)instead of Git-for-Windows' MSYS GNU tar. Default behavior is unchanged.
Refs actions/cache#752.
Why
On hosted
windows-latestrunners, extract of a many-small-files cache isdominated by MSYS tar's POSIX-shim + fork-per-file overhead. Concrete numbers
from a fresh bench on
windows-2025hosted runner (568 MB mise install dir,~40k files, zstd):
*Measured in production CI (
jdx/mise-actionon flint). Bench harness below.That's ~4× faster extract with no archive-size penalty. bsdtar makes native
Win32 syscalls and has zstd built in (no external
zstd.exefork-per-file).Windows Defender exclusions on the target dir only shave ~12 s off the MSYS
path and near-zero off bsdtar — confirming the bottleneck is tar, not AV scans.
Why opt-in (not default)
slashes, permission mapping). Archives written by one are readable by the
other in all formats this package uses (posix ustar + zstd), but switching
the default deserves its own follow-up once this has soaked.
jdx/mise-actionenable the fast path today.Design
getTarPath()onwin32:ACTIONS_CACHE_PREFER_BSD_TAR_ON_WINDOWS=trueandC:\Windows\System32\tar.exeexists → return BSD.The existing
BSD_TAR_ZSTDtwo-command path (zstd + tar piped via temp file)handles the BSD case end-to-end — no changes needed elsewhere.
Test plan
zstd extract tar prefers BSDtar when opt-in env var set— mirrors the existing BSDtar test but keeps GNU tar available, sets the
env var, asserts BSD path is selected and the two-command extract is
invoked. All 12 tar tests pass.
npx prettier --checkandnpx eslintclean on changed files.actions/cacheconsumer (e.g. a mise-actioncache hit) with the env var set shows the extract-time improvement.
Bench reproducer
Workflow used to produce the numbers above (ran on
windows-2025, populatedmise install dir):
https://github.com/grafana/flint/blob/ci/bench-win-extract/.github/workflows/bench-win-extract.yml