Windows searches the launching executable directory before PATH. Stage the CI copy of Ninja alongside the installed ccache shims and point ccache at the original CLANG64 toolchain. Log the detailed compiler counters.
342 lines
16 KiB
YAML
342 lines
16 KiB
YAML
name: Publish Runtime Preview
|
|
|
|
on:
|
|
push:
|
|
branches: [master]
|
|
paths:
|
|
- "packaging/windows-runtime/**"
|
|
schedule:
|
|
- cron: "23 3 * * *"
|
|
workflow_dispatch:
|
|
inputs:
|
|
upstream_commit:
|
|
description: "Reims vGPU fork commit (empty = runtime branch HEAD)"
|
|
required: false
|
|
default: ""
|
|
publish:
|
|
description: "Publish the verified preview as a GitHub prerelease"
|
|
type: boolean
|
|
default: true
|
|
supersede:
|
|
description: "Replace older builds for an automatic maintenance-branch push"
|
|
type: boolean
|
|
default: false
|
|
rebuild:
|
|
description: "Plan a rebuild of an already published runtime using verified compatibility"
|
|
type: boolean
|
|
default: false
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
env:
|
|
UPSTREAM_URL: ${{ github.server_url }}/${{ github.repository }}.git
|
|
UPSTREAM_BRANCH: intel-vm-suspend
|
|
|
|
jobs:
|
|
resolve:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
commit: ${{ steps.r.outputs.commit }}
|
|
skip: ${{ steps.r.outputs.skip }}
|
|
steps:
|
|
- id: r
|
|
env:
|
|
WANT: ${{ inputs.upstream_commit }}
|
|
CURRENT_ONLY: ${{ inputs.supersede }}
|
|
run: |
|
|
set -euo pipefail
|
|
git clone -q --filter=blob:none --no-checkout --single-branch --branch "$UPSTREAM_BRANCH" "$UPSTREAM_URL" up
|
|
commit="$(git -C up rev-parse --verify "${WANT:-HEAD}^{commit}")"
|
|
git -C up cat-file -e "$commit:reims-go-runtime.json"
|
|
echo "commit=$commit" >> "$GITHUB_OUTPUT"
|
|
if [[ "$CURRENT_ONLY" == true && "$commit" != "$(git -C up rev-parse HEAD)" ]]; then
|
|
echo "Skipping superseded runtime commit $commit"
|
|
echo "skip=true" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
build:
|
|
needs: resolve
|
|
if: needs.resolve.outputs.skip != 'true'
|
|
concurrency:
|
|
group: build-runtime
|
|
cancel-in-progress: ${{ github.event_name == 'push' || inputs.supersede }}
|
|
runs-on: windows-latest
|
|
timeout-minutes: 150
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
persist-credentials: false
|
|
|
|
# Select the version inside the build lock, including queued runs.
|
|
- name: Plan Alpha release
|
|
id: plan
|
|
shell: pwsh
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
RUNTIME_COMMIT: ${{ needs.resolve.outputs.commit }}
|
|
REBUILD: ${{ github.event_name == 'push' || inputs.rebuild }}
|
|
PACKAGING_PUSH: ${{ github.event_name == 'push' }}
|
|
run: |
|
|
$ErrorActionPreference = 'Stop'
|
|
$work = Join-Path $env:RUNNER_TEMP 'reims-vgpu'
|
|
git config --global core.autocrlf false
|
|
git clone -q --filter=blob:none --no-checkout --single-branch --branch $env:UPSTREAM_BRANCH $env:UPSTREAM_URL $work
|
|
if ($LASTEXITCODE) { throw 'runtime clone failed' }
|
|
$plan = & ./packaging/windows-runtime/scripts/plan-runtime-release.ps1 `
|
|
-RuntimeRepo $work -RuntimeCommit $env:RUNTIME_COMMIT `
|
|
-PackagingRepo $env:GITHUB_WORKSPACE -PackagingCommit $env:GITHUB_SHA `
|
|
-Repository $env:GITHUB_REPOSITORY -Rebuild:($env:REBUILD -eq 'true') `
|
|
-PackagingPush:($env:PACKAGING_PUSH -eq 'true')
|
|
"skip=$($plan.Skip.ToString().ToLowerInvariant())" >> $env:GITHUB_OUTPUT
|
|
if ($plan.Skip) { return }
|
|
"UPSTREAM_DIR=$work" >> $env:GITHUB_ENV
|
|
"RELEASE_ID=$($plan.ReleaseId)" >> $env:GITHUB_ENV
|
|
"SUSPEND_COMPAT_ID=$($plan.SuspendCompatID)" >> $env:GITHUB_ENV
|
|
"SUSPEND_VERIFICATION=$($plan.Evidence)" >> $env:GITHUB_ENV
|
|
"SUSPEND_PREDECESSOR=$($plan.Predecessor)" >> $env:GITHUB_ENV
|
|
|
|
- name: Setup MSYS2 CLANG64
|
|
if: steps.plan.outputs.skip != 'true'
|
|
id: msys2
|
|
uses: msys2/setup-msys2@v2
|
|
with:
|
|
msystem: CLANG64
|
|
update: true
|
|
install: >-
|
|
git curl diffutils make zstd tar mingw-w64-clang-x86_64-toolchain
|
|
mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-meson
|
|
mingw-w64-clang-x86_64-ninja mingw-w64-clang-x86_64-pkgconf
|
|
mingw-w64-clang-x86_64-glib2 mingw-w64-clang-x86_64-pixman
|
|
mingw-w64-clang-x86_64-gtk3 mingw-w64-clang-x86_64-libslirp
|
|
mingw-w64-clang-x86_64-libusb mingw-w64-clang-x86_64-usbredir
|
|
mingw-w64-clang-x86_64-gnutls mingw-w64-clang-x86_64-dtc
|
|
mingw-w64-clang-x86_64-libva mingw-w64-clang-x86_64-zstd
|
|
mingw-w64-clang-x86_64-mesa mingw-w64-clang-x86_64-vulkan-loader
|
|
mingw-w64-clang-x86_64-python mingw-w64-clang-x86_64-python-pip
|
|
mingw-w64-clang-x86_64-ccache mingw-w64-clang-x86_64-sccache
|
|
|
|
- name: Check out the runtime forks and apply dependency patches
|
|
if: steps.plan.outputs.skip != 'true'
|
|
id: patches
|
|
shell: pwsh
|
|
run: |
|
|
$ErrorActionPreference = 'Stop'
|
|
$work = $env:UPSTREAM_DIR
|
|
foreach ($d in 'cargo', 'xdg-data', 'xdg-cache') { New-Item -ItemType Directory -Force -Path (Join-Path $env:RUNNER_TEMP $d) | Out-Null }
|
|
git -C $work checkout -q '${{ needs.resolve.outputs.commit }}'
|
|
if ($LASTEXITCODE) { throw 'checkout failed' }
|
|
git -C $work submodule update --init --depth 1 vendor/qemu
|
|
if ($LASTEXITCODE) { git -C $work submodule update --init vendor/qemu }
|
|
if ($LASTEXITCODE) { throw 'vendor/qemu submodule failed' }
|
|
$pins = & ./packaging/windows-runtime/scripts/read-runtime-dependencies.ps1 -RuntimeRepo $work
|
|
function Get-DependencyCheckout($pin, [string]$path) {
|
|
git init -q $path
|
|
if ($LASTEXITCODE) { throw "Could not initialize $path" }
|
|
git -C $path remote add origin $pin.Url
|
|
if ($LASTEXITCODE) { throw "Could not add origin for $path" }
|
|
git -C $path fetch -q --depth 1 origin $pin.Rev
|
|
if ($LASTEXITCODE) { throw "Could not fetch $($pin.Url)@$($pin.Rev)" }
|
|
git -C $path checkout -q --detach $pin.Rev
|
|
if ($LASTEXITCODE) { throw "Could not check out $($pin.Url)@$($pin.Rev)" }
|
|
Write-Host "Using $($pin.Url)@$($pin.Rev)"
|
|
}
|
|
$utilRepo = Join-Path $env:RUNNER_TEMP 'reims-util'
|
|
$m2vRepo = Join-Path $env:RUNNER_TEMP 'metal2vulkan'
|
|
Get-DependencyCheckout $pins.Util $utilRepo
|
|
Get-DependencyCheckout $pins.Metal $m2vRepo
|
|
$short = (git -C $work rev-parse --short=7 HEAD).Trim()
|
|
|
|
# Applies what applies, skips what upstream already has, stops on a
|
|
# conflict without touching the patch (AGENTS.md rule 4).
|
|
$resultFile = Join-Path $env:RUNNER_TEMP 'patches.json'
|
|
try {
|
|
pwsh -NoProfile -File packaging/windows-runtime/scripts/apply-patch-series.ps1 -ReimsRepo $work -UtilRepo $utilRepo -Metal2VulkanRepo $m2vRepo -ResultFile $resultFile
|
|
$ok = $LASTEXITCODE -eq 0
|
|
} finally {
|
|
if (Test-Path $resultFile) {
|
|
$r = Get-Content -Raw $resultFile | ConvertFrom-Json
|
|
"merged=$(@($r.merged) -join ',')" >> $env:GITHUB_OUTPUT
|
|
"APPLIED_PATCHES=$(@($r.applied) -join ',')" >> $env:GITHUB_ENV
|
|
}
|
|
}
|
|
if (-not $ok) { throw 'patch queue does not apply' }
|
|
$cargoHome = Join-Path $env:RUNNER_TEMP 'cargo'
|
|
$m2vChanges = git -C $m2vRepo status --porcelain
|
|
if ($LASTEXITCODE) { throw 'Could not read metal2vulkan checkout status' }
|
|
if ($m2vChanges) {
|
|
$m2vFwd = $m2vRepo.Replace('\', '/')
|
|
$cargoCfg = @"
|
|
[patch."$($pins.Metal.Url)"]
|
|
metal2vulkan = { path = "$m2vFwd/crates/metal2vulkan" }
|
|
metal2vulkan-runtime = { path = "$m2vFwd/crates/metal2vulkan-runtime" }
|
|
"@
|
|
[IO.File]::WriteAllText((Join-Path $cargoHome 'config.toml'), ($cargoCfg.Replace("`r`n", "`n") + "`n"), [Text.UTF8Encoding]::new($false))
|
|
}
|
|
"REIMS_UTIL_DIR=$utilRepo" >> $env:GITHUB_ENV
|
|
"METAL2VULKAN_DIR=$m2vRepo" >> $env:GITHUB_ENV
|
|
"SHORT_COMMIT=$short" >> $env:GITHUB_ENV
|
|
"CARGO_HOME=$cargoHome" >> $env:GITHUB_ENV
|
|
"XDG_DATA_HOME=$(Join-Path $env:RUNNER_TEMP 'xdg-data')" >> $env:GITHUB_ENV
|
|
"XDG_CACHE_HOME=$(Join-Path $env:RUNNER_TEMP 'xdg-cache')" >> $env:GITHUB_ENV
|
|
|
|
- name: Identify the Windows build toolchain
|
|
if: steps.plan.outputs.skip != 'true'
|
|
id: toolchain
|
|
shell: msys2 {0}
|
|
run: |
|
|
set -euo pipefail
|
|
cd "$(cygpath -u "$UPSTREAM_DIR")"
|
|
fingerprint="$({ LC_ALL=C pacman -Q; cat rust-toolchain.toml; } | sha256sum)"
|
|
echo "fingerprint=${fingerprint%% *}" >> "$GITHUB_OUTPUT"
|
|
echo "Build toolchain: ${fingerprint%% *}"
|
|
|
|
- name: Cache compiler objects and Cargo downloads
|
|
if: steps.plan.outputs.skip != 'true'
|
|
uses: actions/cache@v5
|
|
with:
|
|
path: |
|
|
${{ runner.temp }}/compiler-cache/ccache
|
|
${{ runner.temp }}/compiler-cache/sccache
|
|
${{ runner.temp }}/cargo/registry/index
|
|
${{ runner.temp }}/cargo/registry/cache
|
|
${{ runner.temp }}/cargo/git/db
|
|
key: runtime-build-v1-${{ runner.arch }}-${{ steps.toolchain.outputs.fingerprint }}-${{ needs.resolve.outputs.commit }}-${{ github.sha }}
|
|
restore-keys: |
|
|
runtime-build-v1-${{ runner.arch }}-${{ steps.toolchain.outputs.fingerprint }}-
|
|
|
|
- name: Build upstream runtime in MSYS2 CLANG64
|
|
if: steps.plan.outputs.skip != 'true'
|
|
shell: msys2 {0}
|
|
env:
|
|
REIMS_INSTALL_SKIP_HOST_CHECKS: "1"
|
|
CCACHE_MAXSIZE: 750M
|
|
CCACHE_COMPILERCHECK: content
|
|
SCCACHE_CACHE_SIZE: 1G
|
|
SCCACHE_ALLOW_INCREMENTAL: "1"
|
|
run: |
|
|
set -euo pipefail
|
|
cd "$(cygpath -u "$UPSTREAM_DIR")"
|
|
# Native Ninja searches its own directory for the installer's bare
|
|
# clang/clang++ names before PATH. Put the cache shims beside its CI copy.
|
|
temp_dir="$(cygpath -u "$RUNNER_TEMP")"
|
|
tools_dir="$temp_dir/compiler-tools"
|
|
mkdir -p "$tools_dir"
|
|
cp "$MINGW_PREFIX/bin/ninja.exe" "$MINGW_PREFIX/lib/ccache/bin/"clang{,++}.exe "$tools_dir/"
|
|
export PATH="$tools_dir:$PATH"
|
|
export CCACHE_PATH="$(cygpath -m "$MINGW_PREFIX/bin")"
|
|
export CCACHE_DIR="$(cygpath -m "$temp_dir")/compiler-cache/ccache"
|
|
export SCCACHE_DIR="$(cygpath -m "$temp_dir")/compiler-cache/sccache"
|
|
export RUSTC_WRAPPER="$(cygpath -m "$MINGW_PREFIX/bin/sccache.exe")"
|
|
ccache --zero-stats
|
|
sccache --start-server
|
|
trap 'ccache --show-stats --verbose; sccache --stop-server' EXIT
|
|
# Upstream's own non-interactive CLANG64 build script.
|
|
bash scripts/install-ctl.sh --yes
|
|
util_repo="$(cygpath -u "$REIMS_UTIL_DIR")"
|
|
if [[ -n "$(git -C "$util_repo" status --porcelain)" ]]; then
|
|
toolchain="$(sed -n 's/^channel *= *"\([^"]*\)".*/\1/p' rust-toolchain.toml)"
|
|
export PATH="$(cygpath -u "$CARGO_HOME")/bin:$PATH"
|
|
CC=clang CXX=clang++ AR=llvm-ar cargo +"$toolchain-x86_64-pc-windows-gnullvm" install \
|
|
--locked --force --root "$CARGO_HOME" --path "$REIMS_UTIL_DIR"
|
|
fi
|
|
|
|
- name: Package alpha runtime and source archives
|
|
if: steps.plan.outputs.skip != 'true'
|
|
shell: pwsh
|
|
run: |
|
|
$ErrorActionPreference = 'Stop'
|
|
$outDir = Join-Path $env:RUNNER_TEMP 'releases'
|
|
New-Item -ItemType Directory -Force -Path $outDir | Out-Null
|
|
# In-process call, so an empty list (every patch already upstream) binds
|
|
# as an empty array rather than being dropped as an empty argument.
|
|
$applied = @($env:APPLIED_PATCHES -split ',' | Where-Object { $_ })
|
|
& ./packaging/windows-runtime/scripts/pack-runtime.ps1 `
|
|
-ReimsRepo $env:UPSTREAM_DIR `
|
|
-UtilRepo $env:REIMS_UTIL_DIR `
|
|
-Metal2VulkanRepo $env:METAL2VULKAN_DIR `
|
|
-CargoHome $env:CARGO_HOME `
|
|
-QemuDir (Join-Path $env:XDG_DATA_HOME 'reims-ctl\qemu\current') `
|
|
-Msys2 '${{ steps.msys2.outputs.msys2-location }}' `
|
|
-OutDir $outDir `
|
|
-TempRoot $env:RUNNER_TEMP `
|
|
-Channel alpha `
|
|
-ReleaseId $env:RELEASE_ID `
|
|
-SuspendCompatID $env:SUSPEND_COMPAT_ID `
|
|
-PackagingCommit $env:GITHUB_SHA `
|
|
-Patches $applied
|
|
|
|
- name: Alpha entry gate
|
|
if: steps.plan.outputs.skip != 'true'
|
|
shell: pwsh
|
|
run: |
|
|
$ErrorActionPreference = 'Stop'
|
|
& ./packaging/windows-runtime/scripts/check-runtime-alpha.ps1 `
|
|
-OutDir (Join-Path $env:RUNNER_TEMP 'releases') `
|
|
-Commit $env:RELEASE_ID -RequireSlim -RequiredCapability vm-suspend `
|
|
-RequiredSuspendCompatID $env:SUSPEND_COMPAT_ID -RequiredPackagingCommit $env:GITHUB_SHA `
|
|
-Zstd (Join-Path '${{ steps.msys2.outputs.msys2-location }}' 'usr\bin\zstd.exe') `
|
|
-AppliedPatches @($env:APPLIED_PATCHES -split ',' | Where-Object { $_ })
|
|
|
|
- name: Upload alpha artifacts
|
|
if: steps.plan.outputs.skip != 'true'
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: reims-runtime-win-x64-${{ env.RELEASE_ID }}-alpha
|
|
path: |
|
|
${{ runner.temp }}/releases/reims-runtime-*.tar.zst
|
|
${{ runner.temp }}/releases/SHA256SUMS.txt
|
|
compression-level: 0
|
|
retention-days: 14
|
|
|
|
- name: Publish alpha prerelease (never stable)
|
|
if: steps.plan.outputs.skip != 'true' && (github.event_name == 'push' || github.event_name == 'schedule' || inputs.publish)
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
CURRENT_ONLY: ${{ github.event_name == 'push' || inputs.supersede }}
|
|
MERGED: ${{ steps.patches.outputs.merged }}
|
|
shell: pwsh
|
|
run: |
|
|
$ErrorActionPreference = 'Stop'
|
|
if ($env:CURRENT_ONLY -eq 'true') {
|
|
$ref = "refs/heads/$env:UPSTREAM_BRANCH"
|
|
$remote = git ls-remote $env:UPSTREAM_URL $ref
|
|
if ($LASTEXITCODE -ne 0) { throw "Could not query the runtime maintenance ref $ref" }
|
|
if (!$remote) {
|
|
Write-Warning "Skipping Alpha publication because $ref no longer exists. The verified archives are available in the workflow artifact."
|
|
return
|
|
}
|
|
if (($remote -split '\s+')[0] -ne '${{ needs.resolve.outputs.commit }}') {
|
|
Write-Host 'Skipping Alpha publication for a superseded runtime commit.'
|
|
return
|
|
}
|
|
}
|
|
$c = $env:RELEASE_ID
|
|
$short = $env:SHORT_COMMIT
|
|
$sourceRepo = $env:UPSTREAM_URL -replace '\.git$', ''
|
|
$dir = Join-Path $env:RUNNER_TEMP 'releases'
|
|
$assets = @("reims-runtime-win-x64-$c.tar.zst", "reims-runtime-src-$c.tar.zst", "reims-runtime-msys2-src-$c.tar.zst", "reims-runtime-symbols-$c.tar.zst", 'SHA256SUMS.txt') |
|
|
ForEach-Object { Join-Path $dir $_ }
|
|
$applied = if ($env:APPLIED_PATCHES) { ($env:APPLIED_PATCHES -split ',' | ForEach-Object { "- ``$_``" }) -join "`n" } else { '- (none)' }
|
|
$merged = if ($env:MERGED) { "`n`nAlready upstream, skipped (retire from patches/): $env:MERGED" } else { '' }
|
|
$compatibility = if ($env:SUSPEND_PREDECESSOR) { "`nVerified against $env:SUSPEND_PREDECESSOR. $env:SUSPEND_VERIFICATION" } else { '' }
|
|
$notes = @"
|
|
**Alpha** runtime (``$c``), built from [the Reims vGPU fork@$short]($sourceRepo/commit/${{ needs.resolve.outputs.commit }}).
|
|
|
|
Preview for Windows x64. Stable promotion requires a real-host smoke test with ``packaging/windows-runtime/scripts/smoke-runtime.ps1`` and human approval.
|
|
|
|
Local patches applied (sources and patches are in the attached source packages):
|
|
$applied$merged
|
|
|
|
The optional ``reims-runtime-symbols-$c.tar.zst`` contains matching debug files for crash analysis.
|
|
|
|
Packaging commit: ``$env:GITHUB_SHA``
|
|
Suspend compatibility ID: ``$env:SUSPEND_COMPAT_ID``$compatibility
|
|
|
|
Build: $env:GITHUB_SERVER_URL/$env:GITHUB_REPOSITORY/actions/runs/$env:GITHUB_RUN_ID
|
|
"@
|
|
gh release create "runtime-$c" @assets --repo $env:GITHUB_REPOSITORY --target '${{ needs.resolve.outputs.commit }}' --prerelease --latest=false --title "Portable Runtime runtime-$c (alpha)" --notes $notes
|
|
if ($LASTEXITCODE) { throw "gh release create failed ($LASTEXITCODE)" }
|