mirror of
https://github.com/openai/codex.git
synced 2026-09-05 15:18:41 +00:00
## Why Windows Cargo and Bazel jobs spend significant time in filesystem-heavy build and cache directories. Route those directories through one CI build root so Windows can use its Dev Drive and Unix can use a stable cache root. ## What - Have `setup-ci` define `CI_BUILD_ROOT`, `CARGO_TARGET_DIR`, Bazel cache/output paths, and temp paths. - Require Windows to find or provision a verified Dev Drive instead of falling back to `C:`. - Pass the shared Bazel output base to `setup-bazel` so its explicit `output_base` does not defeat Dev Drive routing. - Point nextest, release, and V8 source-build paths at the shared environment contract. ## Benchmark results One-off cold-cache WPR/ETW traces show the explicit Bazel output-base routing removes the dominant `C:` traffic: | sample | `C:\_bazel` | summed `C:` traffic | traced test step | |---|---:|---:|---:| | shard 1 before | 62.2 GiB | 85.2 GiB | 16m22s | | shard 1 updated | 0 | 16.5 GiB | 12m05s | | shard 3 before | 67.2 GiB | 84.6 GiB | 16m48s | | shard 3 updated | 0 | 13.5 GiB | 11m08s | For a cold x64 V8 source build, the retained build-tail sample showed `D:\cargo-target` at ~1.29 GiB while measured `C:` roots totaled ~0.45 GiB (`C:\Users` ~0.33 GiB, `C:\Program Files` ~0.06 GiB, `C:\Windows` ~0.03 GiB). The full cold build took 2h20m36s. The Bazel timing improvement is directional because both refreshed shards failed tests. The V8 trace is a bounded build-tail sample, not the full build. All final samples had zero lost ETW events; VHDX traffic was excluded from the optimization ranking. Runs: [baseline Bazel](https://github.com/openai/codex/actions/runs/28911908527), [updated Bazel](https://github.com/openai/codex/actions/runs/28917133701), [V8 build tail](https://github.com/openai/codex/actions/runs/28933626678). ## Manual validation - Ran `just fmt`. - Ran `just test-github-scripts` (35 tests). - Parsed GitHub Actions YAML with `yq`. - Ran `git diff --check`. ## Stack - [#31332](https://github.com/openai/codex/pull/31332) — parameterize Cargo target paths - [#31356](https://github.com/openai/codex/pull/31356) — Windows 2025 runner bump - [#31357](https://github.com/openai/codex/pull/31357) — Dev Drive I/O routing
95 lines
3.6 KiB
YAML
95 lines
3.6 KiB
YAML
name: setup-bazel-ci
|
|
description: Prepare a Bazel CI runner with shared caches.
|
|
inputs:
|
|
target:
|
|
description: Target triple used for cache namespacing.
|
|
required: true
|
|
outputs:
|
|
repository-cache-path:
|
|
description: Filesystem path used for the Bazel repository cache.
|
|
value: ${{ steps.configure_bazel_repository_cache.outputs.repository-cache-path }}
|
|
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- id: setup_ci
|
|
uses: ./.github/actions/setup-ci
|
|
|
|
- name: Set up Bazel
|
|
uses: bazel-contrib/setup-bazel@c5acdfb288317d0b5c0bbd7a396a3dc868bb0f86 # 0.19.0
|
|
# Without an explicit Bazelisk version, setup-bazel leaves PATH unchanged
|
|
# and Windows can use the runner's standalone Bazel, ignoring .bazelversion.
|
|
with:
|
|
bazelisk-version: 1.28.1
|
|
# setup-bazel writes an explicit output_base, which otherwise overrides
|
|
# BAZEL_OUTPUT_USER_ROOT and leaves Bazel's I/O-heavy trees on C:.
|
|
output-base: ${{ steps.setup_ci.outputs.bazel-output-base }}
|
|
|
|
- name: Configure Bazel repository cache
|
|
id: configure_bazel_repository_cache
|
|
shell: pwsh
|
|
run: |
|
|
"repository-cache-path=$env:BAZEL_REPOSITORY_CACHE" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
|
|
|
|
- name: Expose MSVC SDK environment (Windows)
|
|
if: runner.os == 'Windows'
|
|
shell: pwsh
|
|
run: |
|
|
# Bazel exec-side Rust build scripts do not reliably inherit the MSVC developer
|
|
# shell on GitHub-hosted Windows runners, so discover the latest VS install and
|
|
# ask `VsDevCmd.bat` to materialize the x64/x64 compiler + SDK environment.
|
|
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
|
|
if (-not (Test-Path $vswhere)) {
|
|
throw "vswhere.exe not found"
|
|
}
|
|
|
|
$installPath = & $vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath 2>$null
|
|
if (-not $installPath) {
|
|
throw "Could not locate a Visual Studio installation with VC tools"
|
|
}
|
|
|
|
$vsDevCmd = Join-Path $installPath 'Common7\Tools\VsDevCmd.bat'
|
|
if (-not (Test-Path $vsDevCmd)) {
|
|
throw "VsDevCmd.bat not found at $vsDevCmd"
|
|
}
|
|
|
|
# Keep the export surface explicit: these are the paths and SDK roots that the
|
|
# MSVC toolchain probes need later when Bazel runs Windows exec-platform build
|
|
# scripts such as `aws-lc-sys`.
|
|
$varsToExport = @(
|
|
'INCLUDE',
|
|
'LIB',
|
|
'LIBPATH',
|
|
'PATH',
|
|
'UCRTVersion',
|
|
'UniversalCRTSdkDir',
|
|
'VCINSTALLDIR',
|
|
'VCToolsInstallDir',
|
|
'WindowsLibPath',
|
|
'WindowsSdkBinPath',
|
|
'WindowsSdkDir',
|
|
'WindowsSDKLibVersion',
|
|
'WindowsSDKVersion'
|
|
)
|
|
|
|
# `VsDevCmd.bat` is a batch file, so invoke it under `cmd.exe`, suppress its
|
|
# banner, then dump the resulting environment with `set`. Re-export only the
|
|
# approved keys into `GITHUB_ENV` so later steps inherit the same MSVC context.
|
|
$envLines = & cmd.exe /c ('"{0}" -no_logo -arch=x64 -host_arch=x64 >nul && set' -f $vsDevCmd)
|
|
foreach ($line in $envLines) {
|
|
if ($line -notmatch '^(.*?)=(.*)$') {
|
|
continue
|
|
}
|
|
|
|
$name = $matches[1]
|
|
$value = $matches[2]
|
|
if ($varsToExport -contains $name) {
|
|
"$name=$value" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
|
}
|
|
}
|
|
|
|
- name: Compute cache-stable Windows Bazel PATH
|
|
if: runner.os == 'Windows'
|
|
shell: pwsh
|
|
run: ./.github/scripts/compute-bazel-windows-path.ps1
|