From 02850422dbb8bd019620bb041e9c12c8d80c6f11 Mon Sep 17 00:00:00 2001 From: James Long Date: Mon, 16 Nov 2026 19:12:19 +0000 Subject: [PATCH 1/3] ci(process-daemon): cache and prefetch Ghostty dependencies User decisions: - Cache Zig dependencies on every platform in both daemon workflows - Fetch dependencies in a separate step before building - Ship it as its own PR - Also ship the MSVC pin in this build PR, separate from the daemon fix --- .github/actions/prefetch-ghostty/action.yml | 40 ++++++++++++++++++++ .github/workflows/check-process-daemon.yml | 7 +++- .github/workflows/release-process-daemon.yml | 10 ++++- 3 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 .github/actions/prefetch-ghostty/action.yml diff --git a/.github/actions/prefetch-ghostty/action.yml b/.github/actions/prefetch-ghostty/action.yml new file mode 100644 index 000000000000..cfa1419a7914 --- /dev/null +++ b/.github/actions/prefetch-ghostty/action.yml @@ -0,0 +1,40 @@ +name: Prefetch Ghostty dependencies +description: Prepare the pinned source and Zig packages for process-daemon's native build +runs: + using: composite + steps: + - name: Check out pinned Ghostty source + id: pins + shell: bash + env: + GHOSTTY_SOURCE_DIR: ${{ runner.temp }}/ghostty + ZIG_GLOBAL_CACHE_DIR: ${{ github.workspace }}/.zig-cache + run: | + revision=$(git show HEAD:packages/process-daemon/ghostty-revision) + git init --quiet "$GHOSTTY_SOURCE_DIR" + git -C "$GHOSTTY_SOURCE_DIR" fetch --depth=1 https://github.com/ghostty-org/ghostty.git "$revision" + git -C "$GHOSTTY_SOURCE_DIR" -c core.longpaths=true checkout --detach "$revision" + echo "revision=$revision" >> "$GITHUB_OUTPUT" + echo "zig=$(zig version)" >> "$GITHUB_OUTPUT" + echo "GHOSTTY_SOURCE_DIR=$GHOSTTY_SOURCE_DIR" >> "$GITHUB_ENV" + echo "ZIG_GLOBAL_CACHE_DIR=$ZIG_GLOBAL_CACHE_DIR" >> "$GITHUB_ENV" + + # Zig 0.16 stores portable, content-addressed source tarballs in p/. + - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + path: .zig-cache/p + key: ghostty-packages-${{ steps.pins.outputs.zig }}-${{ steps.pins.outputs.revision }} + enableCrossOsArchive: true + + - name: Fetch Zig packages + shell: bash + working-directory: ${{ env.GHOSTTY_SOURCE_DIR }} + run: | + for attempt in 1 2 3 4; do + echo "zig build --fetch=all (attempt $attempt/4)" + if zig build --fetch=all; then exit 0; fi + if [[ $attempt == 4 ]]; then exit 1; fi + delay=$((5 * 2 ** (attempt - 1))) + echo "Retrying in ${delay}s" + sleep "$delay" + done diff --git a/.github/workflows/check-process-daemon.yml b/.github/workflows/check-process-daemon.yml index b10e411bf681..ed4cff5ed823 100644 --- a/.github/workflows/check-process-daemon.yml +++ b/.github/workflows/check-process-daemon.yml @@ -4,11 +4,13 @@ on: pull_request: paths: - packages/process-daemon/** + - .github/actions/prefetch-ghostty/** - .github/workflows/check-process-daemon.yml push: branches: [dev] paths: - packages/process-daemon/** + - .github/actions/prefetch-ghostty/** - .github/workflows/check-process-daemon.yml workflow_dispatch: @@ -59,6 +61,8 @@ jobs: - uses: mlugg/setup-zig@8d6198c65fb0feaa111df26e6b467fea8345e46f # v2.0.5 with: version: 0.16.0 + use-cache: false + - uses: ./.github/actions/prefetch-ghostty - name: Install Rust run: rustup toolchain install 1.90.0 --profile minimal --component rustfmt --component clippy - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2 @@ -109,7 +113,7 @@ jobs: if: matrix.arch == 'x64' with: version: 0.16.0 - cache-key: ${{ matrix.target }} + use-cache: false # Zig 0.16 crashes when building Ghostty on the native ARM64 host. # Use x64-hosted compilers on this ARM64 runner, but execute ARM64 tests natively. - name: Install x64 Zig for ARM64 cross-compilation @@ -145,6 +149,7 @@ jobs: if ($compiler -notcontains 'host: x86_64-pc-windows-msvc') { throw 'Unexpected Rust compiler host' } Write-Output "Executable target: $env:CARGO_BUILD_TARGET" zig version + - uses: ./.github/actions/prefetch-ghostty # No cache-on-failure: a timed-out run once saved a partial cache that broke re-runs. - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2 with: diff --git a/.github/workflows/release-process-daemon.yml b/.github/workflows/release-process-daemon.yml index 04084b5d14ac..4fe9f486b0b0 100644 --- a/.github/workflows/release-process-daemon.yml +++ b/.github/workflows/release-process-daemon.yml @@ -10,8 +10,10 @@ on: - "process-daemon-v*" pull_request: paths: + - .github/actions/prefetch-ghostty/** - .github/workflows/release-process-daemon.yml - packages/process-daemon/build.rs + - packages/process-daemon/ghostty-revision - packages/process-daemon/npm/** - packages/process-daemon/script/npm-packages.mjs workflow_dispatch: @@ -39,6 +41,8 @@ jobs: - uses: mlugg/setup-zig@8d6198c65fb0feaa111df26e6b467fea8345e46f # v2.0.5 with: version: ${{ env.ZIG_VERSION }} + use-cache: false + - uses: ./.github/actions/prefetch-ghostty - name: Configure baseline Zig builds run: | chmod +x "$GITHUB_WORKSPACE/packages/process-daemon/script/release-bin/zig" @@ -94,7 +98,8 @@ jobs: - uses: mlugg/setup-zig@8d6198c65fb0feaa111df26e6b467fea8345e46f # v2.0.5 with: version: ${{ env.ZIG_VERSION }} - cache-key: ${{ matrix.target }} + use-cache: false + - uses: ./.github/actions/prefetch-ghostty - name: Configure baseline Zig builds run: | chmod +x "$GITHUB_WORKSPACE/packages/process-daemon/script/release-bin/zig" @@ -187,7 +192,7 @@ jobs: if: matrix.arch == 'x64' with: version: ${{ env.ZIG_VERSION }} - cache-key: release-${{ matrix.target }} + use-cache: false # Zig 0.16 crashes when building Ghostty on the native ARM64 host, so use # the x64-hosted compiler there (matching check-process-daemon.yml). - name: Install x64 Zig for ARM64 cross-compilation @@ -208,6 +213,7 @@ jobs: [System.IO.File]::WriteAllText($file, $source.Replace($old, '@ptrCast(@alignCast(try si.loadNtdllProc(@tagName(proc))))')) - name: Install Rust toolchain and target run: rustup toolchain install $env:RUSTUP_TOOLCHAIN --force-non-host --profile minimal --target $env:CARGO_BUILD_TARGET + - uses: ./.github/actions/prefetch-ghostty - name: Build run: cargo build --locked --release - name: Smoke test From 3dd5acd211c0e3d017fe9a8c058488dbef27931e Mon Sep 17 00:00:00 2001 From: James Long Date: Mon, 16 Nov 2026 19:10:10 +0000 Subject: [PATCH 2/3] ci(process-daemon): pin MSVC 14.51 for Windows builds User decisions: - Pin the older MSVC toolset rather than suppressing the compiler version check --- .github/workflows/check-process-daemon.yml | 21 ++++++++++++++++++++ .github/workflows/release-process-daemon.yml | 21 ++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/.github/workflows/check-process-daemon.yml b/.github/workflows/check-process-daemon.yml index ed4cff5ed823..90473445b890 100644 --- a/.github/workflows/check-process-daemon.yml +++ b/.github/workflows/check-process-daemon.yml @@ -134,6 +134,27 @@ jobs: $old = '@ptrCast(try si.loadNtdllProc(@tagName(proc)))' if (!$source.Contains($old)) { throw 'Zig alignment workaround no longer matches; re-evaluate it' } [System.IO.File]::WriteAllText($file, $source.Replace($old, '@ptrCast(@alignCast(try si.loadNtdllProc(@tagName(proc))))')) + - name: Pin MSVC 14.51 for Zig's Clang 21 + run: | + $installer = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer" + $vs = & "$installer\vswhere.exe" -latest -products * -property installationPath + $tools = "$vs\VC\Tools\MSVC" + $arch = '${{ matrix.arch }}' + if (!(Test-Path "$tools\14.51.*\lib\$arch\vcruntime.lib")) { + $components = '--add Microsoft.VisualStudio.Component.VC.14.51.x86.x64' + if ($arch -eq 'arm64') { $components += ' --add Microsoft.VisualStudio.Component.VC.14.51.ARM64' } + $setup = Start-Process "$installer\setup.exe" -ArgumentList "modify --installPath `"$vs`" $components --quiet --norestart" -Wait -PassThru + if ($setup.ExitCode -notin 0, 3010) { throw "VS installer exited with $($setup.ExitCode)" } + } + $toolset = Get-ChildItem $tools -Directory -Filter '14.51.*' | + Where-Object { Test-Path "$($_.FullName)\lib\$arch\vcruntime.lib" } | + Sort-Object { [version]$_.Name } -Descending | Select-Object -First 1 + if (!$toolset) { throw "Missing MSVC 14.51 for $arch" } + # Zig reads this file for both host and target tools on the disposable runner. + Set-Content "$vs\VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt" $toolset.Name -Encoding ascii + $libc = zig libc + $libc + if ($LASTEXITCODE -ne 0 -or $libc -inotcontains "sys_include_dir=$($toolset.FullName)\include") { throw 'Zig selected unexpected MSVC headers' } - name: Install Rust toolchain and target run: rustup toolchain install $env:RUSTUP_TOOLCHAIN --force-non-host --profile minimal --component rustfmt --component clippy --target $env:CARGO_BUILD_TARGET - name: Verify runner and compiler architecture diff --git a/.github/workflows/release-process-daemon.yml b/.github/workflows/release-process-daemon.yml index 4fe9f486b0b0..ea01d2c899ab 100644 --- a/.github/workflows/release-process-daemon.yml +++ b/.github/workflows/release-process-daemon.yml @@ -211,6 +211,27 @@ jobs: $old = '@ptrCast(try si.loadNtdllProc(@tagName(proc)))' if (!$source.Contains($old)) { throw 'Zig alignment workaround no longer matches; re-evaluate it' } [System.IO.File]::WriteAllText($file, $source.Replace($old, '@ptrCast(@alignCast(try si.loadNtdllProc(@tagName(proc))))')) + - name: Pin MSVC 14.51 for Zig's Clang 21 + run: | + $installer = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer" + $vs = & "$installer\vswhere.exe" -latest -products * -property installationPath + $tools = "$vs\VC\Tools\MSVC" + $arch = '${{ matrix.arch }}' + if (!(Test-Path "$tools\14.51.*\lib\$arch\vcruntime.lib")) { + $components = '--add Microsoft.VisualStudio.Component.VC.14.51.x86.x64' + if ($arch -eq 'arm64') { $components += ' --add Microsoft.VisualStudio.Component.VC.14.51.ARM64' } + $setup = Start-Process "$installer\setup.exe" -ArgumentList "modify --installPath `"$vs`" $components --quiet --norestart" -Wait -PassThru + if ($setup.ExitCode -notin 0, 3010) { throw "VS installer exited with $($setup.ExitCode)" } + } + $toolset = Get-ChildItem $tools -Directory -Filter '14.51.*' | + Where-Object { Test-Path "$($_.FullName)\lib\$arch\vcruntime.lib" } | + Sort-Object { [version]$_.Name } -Descending | Select-Object -First 1 + if (!$toolset) { throw "Missing MSVC 14.51 for $arch" } + # Zig reads this file for both host and target tools on the disposable runner. + Set-Content "$vs\VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt" $toolset.Name -Encoding ascii + $libc = zig libc + $libc + if ($LASTEXITCODE -ne 0 -or $libc -inotcontains "sys_include_dir=$($toolset.FullName)\include") { throw 'Zig selected unexpected MSVC headers' } - name: Install Rust toolchain and target run: rustup toolchain install $env:RUSTUP_TOOLCHAIN --force-non-host --profile minimal --target $env:CARGO_BUILD_TARGET - uses: ./.github/actions/prefetch-ghostty From fbfac79ff883e84f8b58af6b978aa1aab7d9999c Mon Sep 17 00:00:00 2001 From: James Long Date: Mon, 16 Nov 2026 20:51:37 +0000 Subject: [PATCH 3/3] ci(process-daemon): harden the MSVC pin step User decisions: - Keep setup-zig's cache off - Raise Windows timeouts and check both x64 and arm64 MSVC libraries --- .github/workflows/check-process-daemon.yml | 12 +++++++++--- .github/workflows/release-process-daemon.yml | 10 ++++++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.github/workflows/check-process-daemon.yml b/.github/workflows/check-process-daemon.yml index 90473445b890..b60f51ac1d35 100644 --- a/.github/workflows/check-process-daemon.yml +++ b/.github/workflows/check-process-daemon.yml @@ -83,7 +83,7 @@ jobs: windows: name: Windows (${{ matrix.arch }}) runs-on: ${{ matrix.runner }} - timeout-minutes: 30 + timeout-minutes: 45 strategy: fail-fast: false matrix: @@ -135,19 +135,25 @@ jobs: if (!$source.Contains($old)) { throw 'Zig alignment workaround no longer matches; re-evaluate it' } [System.IO.File]::WriteAllText($file, $source.Replace($old, '@ptrCast(@alignCast(try si.loadNtdllProc(@tagName(proc))))')) - name: Pin MSVC 14.51 for Zig's Clang 21 + timeout-minutes: 20 run: | $installer = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer" $vs = & "$installer\vswhere.exe" -latest -products * -property installationPath $tools = "$vs\VC\Tools\MSVC" $arch = '${{ matrix.arch }}' - if (!(Test-Path "$tools\14.51.*\lib\$arch\vcruntime.lib")) { + $hasRuntimes = { + (Test-Path "$($_.FullName)\lib\x64\vcruntime.lib") -and + (Test-Path "$($_.FullName)\lib\$arch\vcruntime.lib") + } + if (!(Get-ChildItem $tools -Directory -Filter '14.51.*' | Where-Object $hasRuntimes)) { $components = '--add Microsoft.VisualStudio.Component.VC.14.51.x86.x64' if ($arch -eq 'arm64') { $components += ' --add Microsoft.VisualStudio.Component.VC.14.51.ARM64' } $setup = Start-Process "$installer\setup.exe" -ArgumentList "modify --installPath `"$vs`" $components --quiet --norestart" -Wait -PassThru if ($setup.ExitCode -notin 0, 3010) { throw "VS installer exited with $($setup.ExitCode)" } + Write-Output "MSVC 14.51 installer exited with $($setup.ExitCode) for $arch" } $toolset = Get-ChildItem $tools -Directory -Filter '14.51.*' | - Where-Object { Test-Path "$($_.FullName)\lib\$arch\vcruntime.lib" } | + Where-Object $hasRuntimes | Sort-Object { [version]$_.Name } -Descending | Select-Object -First 1 if (!$toolset) { throw "Missing MSVC 14.51 for $arch" } # Zig reads this file for both host and target tools on the disposable runner. diff --git a/.github/workflows/release-process-daemon.yml b/.github/workflows/release-process-daemon.yml index ea01d2c899ab..fde87c1ed7a6 100644 --- a/.github/workflows/release-process-daemon.yml +++ b/.github/workflows/release-process-daemon.yml @@ -212,19 +212,25 @@ jobs: if (!$source.Contains($old)) { throw 'Zig alignment workaround no longer matches; re-evaluate it' } [System.IO.File]::WriteAllText($file, $source.Replace($old, '@ptrCast(@alignCast(try si.loadNtdllProc(@tagName(proc))))')) - name: Pin MSVC 14.51 for Zig's Clang 21 + timeout-minutes: 20 run: | $installer = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer" $vs = & "$installer\vswhere.exe" -latest -products * -property installationPath $tools = "$vs\VC\Tools\MSVC" $arch = '${{ matrix.arch }}' - if (!(Test-Path "$tools\14.51.*\lib\$arch\vcruntime.lib")) { + $hasRuntimes = { + (Test-Path "$($_.FullName)\lib\x64\vcruntime.lib") -and + (Test-Path "$($_.FullName)\lib\$arch\vcruntime.lib") + } + if (!(Get-ChildItem $tools -Directory -Filter '14.51.*' | Where-Object $hasRuntimes)) { $components = '--add Microsoft.VisualStudio.Component.VC.14.51.x86.x64' if ($arch -eq 'arm64') { $components += ' --add Microsoft.VisualStudio.Component.VC.14.51.ARM64' } $setup = Start-Process "$installer\setup.exe" -ArgumentList "modify --installPath `"$vs`" $components --quiet --norestart" -Wait -PassThru if ($setup.ExitCode -notin 0, 3010) { throw "VS installer exited with $($setup.ExitCode)" } + Write-Output "MSVC 14.51 installer exited with $($setup.ExitCode) for $arch" } $toolset = Get-ChildItem $tools -Directory -Filter '14.51.*' | - Where-Object { Test-Path "$($_.FullName)\lib\$arch\vcruntime.lib" } | + Where-Object $hasRuntimes | Sort-Object { [version]$_.Name } -Descending | Select-Object -First 1 if (!$toolset) { throw "Missing MSVC 14.51 for $arch" } # Zig reads this file for both host and target tools on the disposable runner.