mirror of
https://github.com/herdrdev/herdr.git
synced 2026-09-30 16:01:19 +00:00
ci: reuse compiler state on every os and save caches only from master
This commit is contained in:
+77
-14
@@ -17,6 +17,10 @@ env:
|
||||
# Persist both Zig caches; local build outputs otherwise stay in the uncached vendor tree.
|
||||
ZIG_GLOBAL_CACHE_DIR: ${{ github.workspace }}/.zig-cache
|
||||
ZIG_LOCAL_CACHE_DIR: ${{ github.workspace }}/.zig-cache
|
||||
# PR caches are visible only to their own PR, and every save pushes the
|
||||
# repository toward GitHub's cache limit, evicting the master caches PRs
|
||||
# restore from. Only branch pushes save.
|
||||
SAVE_CACHES: ${{ github.event_name == 'push' }}
|
||||
|
||||
concurrency:
|
||||
group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||
@@ -91,7 +95,17 @@ jobs:
|
||||
with:
|
||||
bun-version: 1.3.14
|
||||
|
||||
# Zig downloads come from ziglang.org or a random community mirror and
|
||||
# vary from seconds to minutes; reuse the verified install instead.
|
||||
- name: Restore Zig compiler
|
||||
id: zig-compiler
|
||||
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||
with:
|
||||
path: ${{ runner.temp }}/herdr-zig-0.16.0
|
||||
key: zig-compiler-v1-${{ runner.os }}-${{ runner.arch }}-0.16.0
|
||||
|
||||
- name: Install Zig
|
||||
if: steps.zig-compiler.outputs.cache-hit != 'true'
|
||||
uses: vercel-labs/setup-zig@83c1594f26b86da8a9a8ddd9b5ee5f3af0f96943 # v1.0.2
|
||||
with:
|
||||
version: 0.16.0
|
||||
@@ -99,24 +113,39 @@ jobs:
|
||||
# Zig's C-header cache keys include the compiler installation path.
|
||||
- name: Stabilize Zig installation path on Unix
|
||||
if: matrix.kind == 'unix'
|
||||
env:
|
||||
ZIG_RESTORED: ${{ steps.zig-compiler.outputs.cache-hit }}
|
||||
run: |
|
||||
stable_zig="$RUNNER_TEMP/herdr-zig-0.16.0"
|
||||
mv "$(dirname "$(command -v zig)")" "$stable_zig"
|
||||
if [ "$ZIG_RESTORED" != "true" ]; then
|
||||
mv "$(dirname "$(command -v zig)")" "$stable_zig"
|
||||
fi
|
||||
echo "$stable_zig" >> "$GITHUB_PATH"
|
||||
echo "ZIG=$stable_zig/zig" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Stabilize Zig installation path on Windows
|
||||
if: matrix.kind == 'windows'
|
||||
shell: pwsh
|
||||
env:
|
||||
ZIG_RESTORED: ${{ steps.zig-compiler.outputs.cache-hit }}
|
||||
run: |
|
||||
$source = Split-Path (Get-Command zig).Source
|
||||
$stable = Join-Path $env:RUNNER_TEMP "herdr-zig-0.16.0"
|
||||
Move-Item -LiteralPath $source -Destination $stable
|
||||
if ($env:ZIG_RESTORED -ne "true") {
|
||||
$source = Split-Path (Get-Command zig).Source
|
||||
Move-Item -LiteralPath $source -Destination $stable
|
||||
}
|
||||
$stable | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
||||
"ZIG=$(Join-Path $stable 'zig.exe')" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
|
||||
- name: Save Zig compiler
|
||||
if: steps.zig-compiler.outputs.cache-hit != 'true' && env.SAVE_CACHES == 'true'
|
||||
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||
with:
|
||||
path: ${{ runner.temp }}/herdr-zig-0.16.0
|
||||
key: zig-compiler-v1-${{ runner.os }}-${{ runner.arch }}-0.16.0
|
||||
|
||||
- name: Restore Zig build cache
|
||||
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||
with:
|
||||
path: .zig-cache
|
||||
key: zig-build-v1-${{ runner.os }}-${{ runner.arch }}-0.16.0-${{ github.run_id }}-${{ github.run_attempt }}
|
||||
@@ -128,12 +157,11 @@ jobs:
|
||||
with:
|
||||
cache-bin: false
|
||||
key: ${{ matrix.os }}
|
||||
save-if: ${{ env.SAVE_CACHES }}
|
||||
|
||||
# Save before rust-cache's post-step removes incremental state. Cargo still
|
||||
# rebuilds workspace targets; only rustc's validated query state is retained.
|
||||
- name: Restore Windows incremental compiler state
|
||||
if: matrix.kind == 'windows'
|
||||
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||
# Cargo still rebuilds workspace targets; only rustc's validated query state is retained.
|
||||
- name: Restore incremental compiler state
|
||||
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||
with:
|
||||
path: target/debug/incremental
|
||||
key: ci-incremental-v1-${{ runner.os }}-${{ runner.arch }}-${{ env.RUST_TOOLCHAIN_VERSION }}-${{ env.CARGO_PROFILE_DEV_DEBUG }}-${{ env.CARGO_PROFILE_TEST_DEBUG }}-${{ hashFiles('Cargo.lock', 'Cargo.toml', '.cargo/config.toml', 'build.rs') }}-${{ github.sha }}
|
||||
@@ -142,7 +170,7 @@ jobs:
|
||||
|
||||
- name: Run Linux lint
|
||||
if: runner.os == 'Linux'
|
||||
run: just lint
|
||||
run: CARGO_INCREMENTAL=1 just lint
|
||||
|
||||
- name: Run Linux tests
|
||||
if: runner.os == 'Linux'
|
||||
@@ -150,7 +178,7 @@ jobs:
|
||||
|
||||
- name: Run macOS checks
|
||||
if: runner.os == 'macOS'
|
||||
run: just ci '${{ matrix.nextest_filter }}'
|
||||
run: CARGO_INCREMENTAL=1 just ci '${{ matrix.nextest_filter }}'
|
||||
|
||||
- name: Check scalar libghostty with runtime safety
|
||||
if: runner.os == 'Linux'
|
||||
@@ -174,6 +202,21 @@ jobs:
|
||||
$exe = Join-Path $PWD "target\debug\herdr.exe"
|
||||
.\scripts\windows_smoke_conpty_path.ps1 -ExePath $exe -Session "ci-windows-$env:GITHUB_RUN_ID-$env:GITHUB_RUN_ATTEMPT"
|
||||
|
||||
# Save before rust-cache's post-step removes incremental state.
|
||||
- name: Save incremental compiler state
|
||||
if: env.SAVE_CACHES == 'true'
|
||||
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||
with:
|
||||
path: target/debug/incremental
|
||||
key: ci-incremental-v1-${{ runner.os }}-${{ runner.arch }}-${{ env.RUST_TOOLCHAIN_VERSION }}-${{ env.CARGO_PROFILE_DEV_DEBUG }}-${{ env.CARGO_PROFILE_TEST_DEBUG }}-${{ hashFiles('Cargo.lock', 'Cargo.toml', '.cargo/config.toml', 'build.rs') }}-${{ github.sha }}
|
||||
|
||||
- name: Save Zig build cache
|
||||
if: env.SAVE_CACHES == 'true'
|
||||
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||
with:
|
||||
path: .zig-cache
|
||||
key: zig-build-v1-${{ runner.os }}-${{ runner.arch }}-0.16.0-${{ github.run_id }}-${{ github.run_attempt }}
|
||||
|
||||
windows-conpty-package:
|
||||
name: Windows ConPTY package
|
||||
runs-on: windows-2022
|
||||
@@ -190,22 +233,34 @@ jobs:
|
||||
toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }}
|
||||
targets: x86_64-pc-windows-msvc
|
||||
|
||||
- name: Restore Zig compiler
|
||||
id: zig-compiler
|
||||
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||
with:
|
||||
path: ${{ runner.temp }}/herdr-zig-0.16.0
|
||||
key: zig-compiler-v1-${{ runner.os }}-${{ runner.arch }}-0.16.0
|
||||
|
||||
- name: Install Zig
|
||||
if: steps.zig-compiler.outputs.cache-hit != 'true'
|
||||
uses: vercel-labs/setup-zig@83c1594f26b86da8a9a8ddd9b5ee5f3af0f96943 # v1.0.2
|
||||
with:
|
||||
version: 0.16.0
|
||||
|
||||
- name: Stabilize Zig installation path
|
||||
shell: pwsh
|
||||
env:
|
||||
ZIG_RESTORED: ${{ steps.zig-compiler.outputs.cache-hit }}
|
||||
run: |
|
||||
$source = Split-Path (Get-Command zig).Source
|
||||
$stable = Join-Path $env:RUNNER_TEMP "herdr-zig-0.16.0"
|
||||
Move-Item -LiteralPath $source -Destination $stable
|
||||
if ($env:ZIG_RESTORED -ne "true") {
|
||||
$source = Split-Path (Get-Command zig).Source
|
||||
Move-Item -LiteralPath $source -Destination $stable
|
||||
}
|
||||
$stable | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
||||
"ZIG=$(Join-Path $stable 'zig.exe')" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
|
||||
- name: Restore Zig build cache
|
||||
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||
with:
|
||||
path: .zig-cache
|
||||
key: zig-build-v1-conpty-package-windows-2022-${{ runner.arch }}-0.16.0-${{ github.run_id }}-${{ github.run_attempt }}
|
||||
@@ -217,10 +272,18 @@ jobs:
|
||||
with:
|
||||
cache-bin: false
|
||||
key: conpty-package-windows-2022
|
||||
save-if: ${{ env.SAVE_CACHES }}
|
||||
|
||||
- name: Build Herdr
|
||||
run: cargo build --locked --target x86_64-pc-windows-msvc
|
||||
|
||||
- name: Save Zig build cache
|
||||
if: env.SAVE_CACHES == 'true'
|
||||
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||
with:
|
||||
path: .zig-cache
|
||||
key: zig-build-v1-conpty-package-windows-2022-${{ runner.arch }}-0.16.0-${{ github.run_id }}-${{ github.run_attempt }}
|
||||
|
||||
- name: Verify invalid bundle is rejected and system override recovers
|
||||
shell: pwsh
|
||||
run: |
|
||||
|
||||
Reference in New Issue
Block a user