Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/actions/prefetch-ghostty/action.yml
Original file line number Diff line number Diff line change
@@ -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
36 changes: 34 additions & 2 deletions .github/workflows/check-process-daemon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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
Expand All @@ -79,7 +83,7 @@ jobs:
windows:
name: Windows (${{ matrix.arch }})
runs-on: ${{ matrix.runner }}
timeout-minutes: 30
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -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
Expand All @@ -130,6 +134,33 @@ 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
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 }}'
$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 $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.
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
Expand All @@ -145,6 +176,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:
Expand Down
37 changes: 35 additions & 2 deletions .github/workflows/release-process-daemon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -206,8 +211,36 @@ 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
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 }}'
$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 $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.
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
- name: Build
run: cargo build --locked --release
- name: Smoke test
Expand Down
Loading