Skip to content

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

Python

perf(ci): preserve rolling Zig build caches

Rach Pradhan1b44cb9a5186
diff --git a/.github/actions/setup-codegraff-zig/action.yml b/.github/actions/setup-codegraff-zig/action.yml
index 30e602cf..170022f6 100644
--- a/.github/actions/setup-codegraff-zig/action.yml
+++ b/.github/actions/setup-codegraff-zig/action.yml
@@ -9,13 +9,11 @@ inputs:
runs:
using: composite
steps:
- - name: Restore Zig toolchain and local build cache
+ - name: Restore verified Zig archive
uses: actions/cache@v6
with:
- path: |
- ${{ runner.temp }}/codegraff-zig-archives
- ${{ github.workspace }}/.zig-cache
- key: codegraff-zig-v2-${{ runner.os }}-${{ runner.arch }}-${{ inputs.version }}
+ path: ${{ runner.temp }}/codegraff-zig-archives
+ key: codegraff-zig-archive-v1-${{ runner.os }}-${{ runner.arch }}-${{ inputs.version }}
- name: Install pinned Zig (Unix)
if: runner.os != 'Windows'
@@ -26,3 +24,13 @@ runs:
if: runner.os == 'Windows'
shell: pwsh
run: python3 "${{ github.action_path }}/../../../scripts/install-zig-ci.py" --version "${{ inputs.version }}"
+
+ - name: Restore Zig build caches
+ uses: actions/cache@v6
+ with:
+ path: |
+ ${{ github.workspace }}/.zig-cache
+ ${{ github.workspace }}/.zig-global-cache
+ key: codegraff-zig-build-v1-${{ runner.os }}-${{ runner.arch }}-${{ inputs.version }}-${{ github.sha }}
+ restore-keys: |
+ codegraff-zig-build-v1-${{ runner.os }}-${{ runner.arch }}-${{ inputs.version }}-
diff --git a/scripts/install-zig-ci.py b/scripts/install-zig-ci.py
index 0e5aef39..07a90fcf 100644
--- a/scripts/install-zig-ci.py
+++ b/scripts/install-zig-ci.py
@@ -147,6 +147,16 @@ def main() -> int:
parser.error("GITHUB_PATH is required on a GitHub Actions runner")
with Path(github_path).open("a", encoding="utf-8") as path_file:
path_file.write(str(install_dir) + os.linesep)
+
+ github_env = os.environ.get("GITHUB_ENV")
+ github_workspace = os.environ.get("GITHUB_WORKSPACE")
+ if not github_env or not github_workspace:
+ parser.error("GITHUB_ENV and GITHUB_WORKSPACE are required on a GitHub Actions runner")
+ global_cache = Path(github_workspace).resolve() / ".zig-global-cache"
+ if "\n" in str(global_cache) or "\r" in str(global_cache):
+ parser.error("GITHUB_WORKSPACE may not contain newlines")
+ with Path(github_env).open("a", encoding="utf-8") as env_file:
+ env_file.write(f"ZIG_GLOBAL_CACHE_DIR={global_cache}{os.linesep}")
print(f"Installed Zig {actual_version} at {install_dir}")
return 0