Skip to content

graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs

Python

perf(ci): keep Windows on archive restore

Rach Pradhan994c42d3771c
diff --git a/.github/actions/setup-codegraff-zig/action.yml b/.github/actions/setup-codegraff-zig/action.yml
index 78c36034..b56988e7 100644
--- a/.github/actions/setup-codegraff-zig/action.yml
+++ b/.github/actions/setup-codegraff-zig/action.yml
@@ -11,13 +11,14 @@ runs:
steps:
- name: Restore verified Zig toolchain
id: toolchain-cache
+ if: runner.os != 'Windows'
uses: actions/cache@v6
with:
path: ${{ runner.temp }}/codegraff-zig-${{ inputs.version }}
key: codegraff-zig-toolchain-v1-${{ runner.os }}-${{ runner.arch }}-${{ inputs.version }}
- name: Restore verified Zig archive
- if: steps.toolchain-cache.outputs.cache-hit != 'true'
+ if: runner.os == 'Windows' || steps.toolchain-cache.outputs.cache-hit != 'true'
uses: actions/cache@v6
with:
path: ${{ runner.temp }}/codegraff-zig-archives
diff --git a/scripts/install-zig-ci.py b/scripts/install-zig-ci.py
index 8fec9bea..4b9a5ecd 100644
--- a/scripts/install-zig-ci.py
+++ b/scripts/install-zig-ci.py
@@ -137,16 +137,17 @@ def validate_toolchain(
system: str,
version: str,
expected_binary_sha: str,
- expected_tree_sha: str,
+ expected_tree_sha: str | None,
) -> tuple[bool, str]:
if not install_dir.is_dir():
return False, "toolchain directory is missing"
- try:
- actual_tree_sha = tree_sha256(install_dir)
- except (OSError, RuntimeError) as error:
- return False, f"tree validation failed: {error}"
- if actual_tree_sha != expected_tree_sha:
- return False, f"tree SHA-256 mismatch: got {actual_tree_sha}"
+ if expected_tree_sha is not None:
+ try:
+ actual_tree_sha = tree_sha256(install_dir)
+ except (OSError, RuntimeError) as error:
+ return False, f"tree validation failed: {error}"
+ if actual_tree_sha != expected_tree_sha:
+ return False, f"tree SHA-256 mismatch: got {actual_tree_sha}"
binary = zig_binary(install_dir, system)
if not binary.is_file() or sha256(binary) != expected_binary_sha:
return False, "Zig binary failed its pinned SHA-256 check"
@@ -177,9 +178,15 @@ def main() -> int:
parser.error("RUNNER_TEMP must name an existing directory")
install_dir = runner_temp / f"codegraff-zig-{args.version}"
- valid, result = validate_toolchain(
- install_dir, system, args.version, expected_binary_sha, expected_tree_sha
- )
+ # Restoring the extracted compiler tree invalidates Zig's build artifacts on
+ # Windows, so that runner keeps the faster verified-archive path.
+ reuse_cached_toolchain = system != "Windows"
+ if reuse_cached_toolchain:
+ valid, result = validate_toolchain(
+ install_dir, system, args.version, expected_binary_sha, expected_tree_sha
+ )
+ else:
+ valid, result = False, "extracted cache reuse is disabled on Windows"
if valid:
actual_version = result
print(f"Verified cached Zig toolchain at {install_dir}")
@@ -194,7 +201,11 @@ def main() -> int:
download(filename, archive, expected_sha)
extract(archive, install_dir)
valid, result = validate_toolchain(
- install_dir, system, args.version, expected_binary_sha, expected_tree_sha
+ install_dir,
+ system,
+ args.version,
+ expected_binary_sha,
+ expected_tree_sha if reuse_cached_toolchain else None,
)
if not valid:
shutil.rmtree(install_dir, ignore_errors=True)
diff --git a/scripts/test-install-zig-ci.py b/scripts/test-install-zig-ci.py
index db4f902a..4621db4c 100644
--- a/scripts/test-install-zig-ci.py
+++ b/scripts/test-install-zig-ci.py
@@ -72,6 +72,18 @@ class ToolchainIntegrityTests(unittest.TestCase):
self.assertFalse(valid)
self.assertIn("tree SHA-256 mismatch", reason)
+ def test_binary_tamper_is_rejected_without_tree_digest(self) -> None:
+ self.binary.write_bytes(b"tampered binary\n")
+ valid, reason = installer.validate_toolchain(
+ self.root,
+ "Linux",
+ installer.PINNED_VERSION,
+ self.binary_sha,
+ None,
+ )
+ self.assertFalse(valid)
+ self.assertIn("binary failed", reason)
+
def test_invalid_cache_recovers_from_verified_archive(self) -> None:
runner_temp = Path(self.scratch.name)
archive_dir = runner_temp / "codegraff-zig-archives"