mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
ebb7980369
## Why Bazel remote configuration was selected in several CI scripts and workflow steps. That made the BuildBuddy tenant policy easy to duplicate and harder to audit, especially for fork pull requests that must not use the OpenAI tenant. This builds on [sluongng/buildbuddy-ci-host-routing](https://github.com/openai/codex/compare/main...sluongng:codex:sluongng/buildbuddy-ci-host-routing) and consolidates the policy in one place. ## What to do if this breaks you See `codex-rs/docs/bazel.md` for details. TLDR: 1. make a BuildBuddy API key and put it in `~/.bazelrc` 2. if you're an OpenAI employee, add `common --config=buildbuddy-openai-rbe` to `user.bazelrc` in the repo root Run `just bazel-test` to ensure it works. Note that `just bazel-remote-test` no longer exists, you need to select a remote configuration as documented to use RBE. ## What changed - Add `.github/scripts/run_bazel_with_buildbuddy.py` as the shared Bazel wrapper and Python library. It selects the OpenAI host only for trusted upstream GitHub Actions runs, routes keyed fork runs to the generic host, and falls back to local Bazel execution when no key is available. - Move endpoint selection into explicit `.bazelrc` configurations and update Bazel CI, query helpers, and `rusty_v8` staging to use the shared policy. Loading-phase target-discovery queries remain local. - Add wrapper and `rusty_v8` unit coverage, plus `just test-scripts` for the `.github/scripts` Python tests. - Document local Bazel usage, `user.bazelrc` setup, BuildBuddy configurations, and CI behavior in `codex-rs/docs/bazel.md`. ## Validation - `just test-scripts` - `bash -n .github/scripts/run-bazel-ci.sh .github/scripts/run-bazel-query-ci.sh .github/scripts/run-argument-comment-lint-bazel.sh scripts/list-bazel-clippy-targets.sh` - `python3 -m py_compile .github/scripts/run_bazel_with_buildbuddy.py .github/scripts/test_run_bazel_with_buildbuddy.py .github/scripts/test_rusty_v8_bazel.py .github/scripts/rusty_v8_bazel.py` - `ruff check .github/scripts/run_bazel_with_buildbuddy.py .github/scripts/test_run_bazel_with_buildbuddy.py .github/scripts/test_rusty_v8_bazel.py .github/scripts/rusty_v8_bazel.py`
179 lines
5.7 KiB
Makefile
179 lines
5.7 KiB
Makefile
set working-directory := "codex-rs"
|
|
set positional-arguments
|
|
export JUST_SHELL := justfile_directory() / "scripts/just-shell.py"
|
|
set shell := ["python3", "-c", 'import os, runpy; runpy.run_path(os.environ["JUST_SHELL"], run_name="__main__")']
|
|
set windows-shell := ["python", "-c", 'import os, runpy; runpy.run_path(os.environ["JUST_SHELL"], run_name="__main__")']
|
|
|
|
rust_min_stack := "8388608" # 8 MiB
|
|
python := if os_family() == "windows" { "python" } else { "python3" }
|
|
|
|
# Display help
|
|
help:
|
|
just -l
|
|
|
|
# `codex`
|
|
alias c := codex
|
|
codex *args:
|
|
cargo run --bin codex -- {args}
|
|
|
|
# `codex exec`
|
|
exec *args:
|
|
cargo run --bin codex -- exec {args}
|
|
|
|
# Start `codex exec-server` and run codex-tui.
|
|
[no-cd]
|
|
[positional-arguments]
|
|
[unix]
|
|
tui-with-exec-server *args:
|
|
{{ justfile_directory() }}/scripts/run_tui_with_exec_server.sh "$@"
|
|
|
|
# Run the CLI version of the file-search crate.
|
|
file-search *args:
|
|
cargo run --bin codex-file-search -- {args}
|
|
|
|
# Build the CLI and run the app-server test client
|
|
app-server-test-client *args:
|
|
cargo build -p codex-cli
|
|
cargo run -p codex-app-server-test-client -- --codex-bin ./target/debug/codex {args}
|
|
|
|
# Format the justfile, Rust, Python SDK code, and Python scripts.
|
|
fmt:
|
|
{{ python }} ../scripts/format.py
|
|
|
|
# Check formatting without modifying files.
|
|
fmt-check:
|
|
{{ python }} ../scripts/format.py --check
|
|
|
|
fix *args:
|
|
cargo clippy --fix --tests --allow-dirty {args}
|
|
|
|
clippy *args:
|
|
cargo clippy --tests {args}
|
|
|
|
[unix]
|
|
install:
|
|
rustup show active-toolchain
|
|
cargo fetch
|
|
|
|
[windows]
|
|
install:
|
|
#!powershell.exe -File
|
|
$pwsh = Get-Command pwsh.exe -ErrorAction SilentlyContinue
|
|
if (-not $pwsh) {
|
|
winget install --exact --id Microsoft.PowerShell --source winget --accept-package-agreements --accept-source-agreements
|
|
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
|
}
|
|
rustup show active-toolchain
|
|
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
|
cargo fetch
|
|
exit $LASTEXITCODE
|
|
|
|
# Run nextest with --no-fail-fast so all tests are run.
|
|
#
|
|
# Run `cargo install --locked cargo-nextest` if you don't have it installed.
|
|
# Prefer this for routine local runs. Workspace crate features are banned, so
|
|
# there should be no need to add `--all-features`.
|
|
[unix]
|
|
test *args:
|
|
RUST_MIN_STACK={{ rust_min_stack }} cargo nextest run --no-fail-fast "$@"
|
|
just bench-smoke
|
|
|
|
[windows]
|
|
test *args:
|
|
$env:RUST_MIN_STACK = "{{ rust_min_stack }}"; cargo nextest run --no-fail-fast @($args | Select-Object -Skip 1)
|
|
just bench-smoke
|
|
|
|
# Run from the repository root so scripts that resolve paths from `cwd` see
|
|
# the same layout they use in GitHub Actions.
|
|
[no-cd]
|
|
test-github-scripts:
|
|
{{ python }} -m unittest discover -s {{ justfile_directory() }}/.github/scripts -p 'test_*.py'
|
|
|
|
# Run explicit workspace benchmark targets.
|
|
bench *args:
|
|
cargo bench --workspace --bench '*' {args}
|
|
|
|
# Run benchmark targets once to ensure they start successfully.
|
|
bench-smoke:
|
|
just bench -- --test
|
|
|
|
# Build and run Codex from source using Bazel.
|
|
# On Unix, use `[no-cd]` and `--run_under="cd $PWD &&"` to ensure Bazel runs
|
|
# the command in the current working directory.
|
|
[no-cd]
|
|
[unix]
|
|
bazel-codex *args:
|
|
bazel run //codex-rs/cli:codex --run_under="cd $PWD &&" -- "$@"
|
|
|
|
[windows]
|
|
bazel-codex *args:
|
|
bazel run //codex-rs/cli:codex --run_under='cd /d "{{ invocation_directory_native() }}" &&' -- @($args | Select-Object -Skip 1)
|
|
|
|
[no-cd]
|
|
bazel-lock-update:
|
|
bazel mod deps --lockfile_mode=update
|
|
|
|
[no-cd]
|
|
[unix]
|
|
bazel-lock-check:
|
|
{{ justfile_directory() }}/scripts/check-module-bazel-lock.sh
|
|
|
|
[windows]
|
|
bazel-lock-check:
|
|
bazel mod deps --lockfile_mode=error; if ($LASTEXITCODE -ne 0) { Write-Error "MODULE.bazel.lock is out of date. Run 'just bazel-lock-update' and commit the updated lockfile."; exit 1 }
|
|
|
|
bazel-test:
|
|
bazel test --test_tag_filters=-argument-comment-lint //... --keep_going
|
|
|
|
[no-cd]
|
|
[unix]
|
|
bazel-clippy:
|
|
bazel_targets="$({{ justfile_directory() }}/scripts/list-bazel-clippy-targets.sh)" && bazel build --config=clippy -- ${bazel_targets}
|
|
|
|
[no-cd]
|
|
[unix]
|
|
bazel-argument-comment-lint:
|
|
bazel build --config=argument-comment-lint -- $({{ justfile_directory() }}/tools/argument-comment-lint/list-bazel-targets.sh)
|
|
|
|
build-for-release:
|
|
bazel build //codex-rs/cli:release_binaries
|
|
|
|
# Run the MCP server
|
|
mcp-server-run *args:
|
|
cargo run -p codex-mcp-server -- {args}
|
|
|
|
# Regenerate the json schema for config.toml from the current config types.
|
|
write-config-schema:
|
|
cargo run -p codex-core --bin codex-write-config-schema
|
|
|
|
# Regenerate vendored app-server protocol schema artifacts.
|
|
write-app-server-schema *args:
|
|
cargo run -p codex-app-server-protocol --bin write_schema_fixtures -- {args}
|
|
|
|
[no-cd]
|
|
write-hooks-schema:
|
|
cargo run --manifest-path {{ justfile_directory() }}/codex-rs/Cargo.toml -p codex-hooks --bin write_hooks_schema_fixtures
|
|
|
|
# Run the argument-comment Dylint checks across codex-rs.
|
|
[no-cd]
|
|
[unix]
|
|
argument-comment-lint *args:
|
|
if [ "$#" -eq 0 ]; then \
|
|
bazel build --config=argument-comment-lint -- $({{ justfile_directory() }}/tools/argument-comment-lint/list-bazel-targets.sh); \
|
|
else \
|
|
{{ justfile_directory() }}/tools/argument-comment-lint/run-prebuilt-linter.py "$@"; \
|
|
fi
|
|
|
|
[no-cd]
|
|
argument-comment-lint-from-source *args:
|
|
{{ python }} {{ justfile_directory() }}/tools/argument-comment-lint/run.py {args}
|
|
|
|
# Tail logs from the state SQLite database
|
|
[unix]
|
|
log *args:
|
|
if [ "${1:-}" = "--" ]; then shift; fi; cargo run -p codex-state --bin logs_client -- "$@"
|
|
|
|
[windows]
|
|
log *args:
|
|
$forwarded_args = @($args | Select-Object -Skip 1); if ($forwarded_args.Count -gt 0 -and $forwarded_args[0] -eq "--") { $forwarded_args = @($forwarded_args | Select-Object -Skip 1) }; cargo run -p codex-state --bin logs_client -- @forwarded_args
|