mirror of
https://github.com/openai/codex.git
synced 2026-04-24 06:35:50 +00:00
## Why Bazel CI had two independent Windows issues: - The workflow saved/restored `~/.cache/bazel-repo-cache`, but `.bazelrc` configured `common:ci-windows --repository_cache=D:/a/.cache/bazel-repo-cache`, so `actions/cache` and Bazel could point at different directories. - The Windows `Bazel clippy` job passed the full explicit target list from `//codex-rs/...`, but some of those explicit targets are intentionally incompatible with `//:local_windows`. `run-argument-comment-lint-bazel.sh` already handles that with `--skip_incompatible_explicit_targets`; the clippy workflow path did not. I also tried switching the workflow cache path to `D:\a\.cache\bazel-repo-cache`, but the Windows clippy job repeatedly failed with `Failed to restore: Cache service responded with 400`, so the final change standardizes on `$HOME/.cache/bazel-repo-cache` and makes cache restore non-fatal. ## What Changed - Expose one repository-cache path from `.github/actions/setup-bazel-ci/action.yml` and export that path as `BAZEL_REPOSITORY_CACHE` so `run-bazel-ci.sh` passes it to Bazel after `--config=ci-*`. - Move `actions/cache/restore` out of the composite action into `.github/workflows/bazel.yml`, and make restore failures non-fatal there. - Save exactly the exported cache path in `.github/workflows/bazel.yml`. - Remove `common:ci-windows --repository_cache=D:/a/.cache/bazel-repo-cache` from `.bazelrc` so the Windows CI config no longer disagrees with the workflow cache path. - Pass `--skip_incompatible_explicit_targets` in the Windows `Bazel clippy` job so incompatible explicit targets do not fail analysis while the lint aspect still traverses compatible Rust dependencies. ## Verification - Parsed `.github/actions/setup-bazel-ci/action.yml` and `.github/workflows/bazel.yml` with Ruby's YAML loader. - Resubmitted PR `#16740`; CI is rerunning on the amended commit.
129 lines
5.3 KiB
YAML
129 lines
5.3 KiB
YAML
name: setup-bazel-ci
|
|
description: Prepare a Bazel CI runner with shared caches and optional test prerequisites.
|
|
inputs:
|
|
target:
|
|
description: Target triple used for cache namespacing.
|
|
required: true
|
|
install-test-prereqs:
|
|
description: Install Node.js and DotSlash for Bazel-backed test jobs.
|
|
required: false
|
|
default: "false"
|
|
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:
|
|
- name: Set up Node.js for js_repl tests
|
|
if: inputs.install-test-prereqs == 'true'
|
|
uses: actions/setup-node@v6
|
|
with:
|
|
node-version-file: codex-rs/node-version.txt
|
|
|
|
# Some integration tests rely on DotSlash being installed.
|
|
# See https://github.com/openai/codex/pull/7617.
|
|
- name: Install DotSlash
|
|
if: inputs.install-test-prereqs == 'true'
|
|
uses: facebook/install-dotslash@v2
|
|
|
|
- name: Make DotSlash available in PATH (Unix)
|
|
if: inputs.install-test-prereqs == 'true' && runner.os != 'Windows'
|
|
shell: bash
|
|
run: cp "$(which dotslash)" /usr/local/bin
|
|
|
|
- name: Make DotSlash available in PATH (Windows)
|
|
if: inputs.install-test-prereqs == 'true' && runner.os == 'Windows'
|
|
shell: pwsh
|
|
run: Copy-Item (Get-Command dotslash).Source -Destination "$env:LOCALAPPDATA\Microsoft\WindowsApps\dotslash.exe"
|
|
|
|
- name: Set up Bazel
|
|
uses: bazelbuild/setup-bazelisk@v3
|
|
|
|
- name: Configure Bazel repository cache
|
|
id: configure_bazel_repository_cache
|
|
shell: pwsh
|
|
run: |
|
|
# Keep the repository cache under HOME on all runners. Windows `D:\a`
|
|
# cache paths match `.bazelrc`, but `actions/cache/restore` currently
|
|
# returns HTTP 400 for that path in the Windows clippy job.
|
|
$repositoryCachePath = Join-Path $HOME '.cache/bazel-repo-cache'
|
|
"repository-cache-path=$repositoryCachePath" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
|
|
"BAZEL_REPOSITORY_CACHE=$repositoryCachePath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
|
|
|
- name: Configure Bazel output root (Windows)
|
|
if: runner.os == 'Windows'
|
|
shell: pwsh
|
|
run: |
|
|
# Use the shortest available drive to reduce argv/path length issues,
|
|
# but avoid the drive root because some Windows test launchers mis-handle
|
|
# MANIFEST paths there.
|
|
$hasDDrive = Test-Path 'D:\'
|
|
$bazelOutputUserRoot = if ($hasDDrive) { 'D:\b' } else { 'C:\b' }
|
|
$repoContentsCache = Join-Path $env:RUNNER_TEMP "bazel-repo-contents-cache-$env:GITHUB_RUN_ID-$env:GITHUB_JOB"
|
|
"BAZEL_OUTPUT_USER_ROOT=$bazelOutputUserRoot" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
|
"BAZEL_REPO_CONTENTS_CACHE=$repoContentsCache" | Out-File -FilePath $env:GITHUB_ENV -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: Enable Git long paths (Windows)
|
|
if: runner.os == 'Windows'
|
|
shell: pwsh
|
|
run: git config --global core.longpaths true
|