mirror of
https://github.com/openai/codex.git
synced 2026-08-23 13:09:46 +00:00
[codex] Add comprehensive root formatting check (#25683)
## Why The root formatting entrypoints could drift: `just fmt` did not format the Justfile itself, and the CI-facing check recipe only checked Python scripts instead of matching everything formatted by `just fmt`. ## What changed - Add a shared cross-platform Python formatter driver used by both `just fmt` and `just fmt-check`. - Run Justfile, Rust, Python SDK, and internal-script formatter groups concurrently while buffering each formatter group's output until it finishes. - Log formatter starts immediately, then print each formatter group's labeled output when it completes. - Keep the SDK lint-fix and Ruff formatting passes ordered, with source comments explaining their distinct roles and the check-mode equivalents. - Run Ruff through shared `uv run --no-sync --with ruff` overlays so formatting works on clean glibc Linux checkouts without installing the platform-specific SDK runtime wheel. - Show `fmt-check` help text in `just -l` and simplify CI to call the shared driver through `just fmt-check`. - Pin the general CI workflow to `just@1.51.0` so its formatter agrees with the checked-in Justfile. - Add regression coverage for the thin Just recipes and the driver's formatter graph. ## Validation - `just fmt` - `just fmt-check` - `python3 -m pytest sdk/python/tests/test_artifact_workflow_and_binaries.py -k 'root_fmt or root_format' -q` - `pnpm run format` - `git diff --check` - `just -l | rg -n '^ fmt|fmt-check'` - `uvx --from uv==0.7.22 uv run --frozen --project sdk/python --no-sync --with ruff ruff check --diff sdk/python`
This commit is contained in:
committed by
GitHub
parent
0002316687
commit
747f1003dd
27
justfile
27
justfile
@@ -21,9 +21,9 @@ exec *args:
|
||||
cargo run --bin codex -- exec {args}
|
||||
|
||||
# Start `codex exec-server` and run codex-tui.
|
||||
[unix]
|
||||
[no-cd]
|
||||
[positional-arguments]
|
||||
[unix]
|
||||
tui-with-exec-server *args:
|
||||
{{ justfile_directory() }}/scripts/run_tui_with_exec_server.sh "$@"
|
||||
|
||||
@@ -36,16 +36,13 @@ 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 Rust, Python SDK code, and Python scripts.
|
||||
# Format the justfile, Rust, Python SDK code, and Python scripts.
|
||||
fmt:
|
||||
cargo fmt -- --config imports_granularity=Item {stderr-null}
|
||||
uv run --frozen --project ../sdk/python --extra dev ruff check --fix --fix-only ../sdk/python
|
||||
uv run --frozen --project ../sdk/python --extra dev ruff format ../sdk/python
|
||||
# Root scripts have their own locked Ruff environment.
|
||||
uv run --frozen --project ../scripts ruff format ../scripts
|
||||
{{ python }} ../scripts/format.py
|
||||
|
||||
fmt-scripts-check:
|
||||
uv run --frozen --project ../scripts ruff format --check ../scripts
|
||||
# Check formatting without modifying files.
|
||||
fmt-check:
|
||||
{{ python }} ../scripts/format.py --check
|
||||
|
||||
fix *args:
|
||||
cargo clippy --fix --tests --allow-dirty {args}
|
||||
@@ -97,21 +94,21 @@ bench-smoke:
|
||||
# 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.
|
||||
[unix]
|
||||
[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)
|
||||
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
|
||||
|
||||
[unix]
|
||||
[no-cd]
|
||||
[unix]
|
||||
bazel-lock-check:
|
||||
{{ justfile_directory() }}/scripts/check-module-bazel-lock.sh
|
||||
|
||||
@@ -122,13 +119,13 @@ bazel-lock-check:
|
||||
bazel-test:
|
||||
bazel test --test_tag_filters=-argument-comment-lint //... --keep_going
|
||||
|
||||
[unix]
|
||||
[no-cd]
|
||||
[unix]
|
||||
bazel-clippy:
|
||||
bazel_targets="$({{ justfile_directory() }}/scripts/list-bazel-clippy-targets.sh)" && bazel build --config=clippy -- ${bazel_targets}
|
||||
|
||||
[unix]
|
||||
[no-cd]
|
||||
[unix]
|
||||
bazel-argument-comment-lint:
|
||||
bazel build --config=argument-comment-lint -- $({{ justfile_directory() }}/tools/argument-comment-lint/list-bazel-targets.sh)
|
||||
|
||||
@@ -155,8 +152,8 @@ 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.
|
||||
[unix]
|
||||
[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); \
|
||||
|
||||
Reference in New Issue
Block a user