diff --git a/.github/workflows/rust-ci.yml b/.github/workflows/rust-ci.yml index 287e7e540f..fd4333e79b 100644 --- a/.github/workflows/rust-ci.yml +++ b/.github/workflows/rust-ci.yml @@ -103,11 +103,13 @@ jobs: sudo DEBIAN_FRONTEND=noninteractive apt-get update sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends pkg-config libcap-dev - uses: dtolnay/rust-toolchain@1.93.0 + if: ${{ needs.changed.outputs.argument_comment_lint_package == 'true' || github.event_name == 'push' }} with: toolchain: nightly-2025-09-18 components: llvm-tools-preview, rustc-dev, rust-src - name: Cache cargo-dylint tooling id: cargo_dylint_cache + if: ${{ needs.changed.outputs.argument_comment_lint_package == 'true' || github.event_name == 'push' }} uses: actions/cache@v5 with: path: | @@ -118,16 +120,18 @@ jobs: ~/.cargo/git/db key: argument-comment-lint-${{ runner.os }}-${{ hashFiles('tools/argument-comment-lint/Cargo.lock', 'tools/argument-comment-lint/rust-toolchain', '.github/workflows/rust-ci.yml') }} - name: Install cargo-dylint tooling - if: ${{ steps.cargo_dylint_cache.outputs.cache-hit != 'true' }} + if: ${{ (needs.changed.outputs.argument_comment_lint_package == 'true' || github.event_name == 'push') && steps.cargo_dylint_cache.outputs.cache-hit != 'true' }} run: cargo install --locked cargo-dylint dylint-link + - uses: facebook/install-dotslash@v2 - name: Test argument comment lint package if: ${{ needs.changed.outputs.argument_comment_lint_package == 'true' || github.event_name == 'push' }} working-directory: tools/argument-comment-lint run: cargo test - name: Run argument comment lint on codex-rs run: | + bash -n tools/argument-comment-lint/run-prebuilt-linter.sh bash -n tools/argument-comment-lint/run.sh - ./tools/argument-comment-lint/run.sh + ./tools/argument-comment-lint/run-prebuilt-linter.sh # --- CI to validate on different os/targets -------------------------------- lint_build: diff --git a/justfile b/justfile index e32a96181e..9e1fa42f0e 100644 --- a/justfile +++ b/justfile @@ -30,8 +30,9 @@ fmt: fix *args: cargo clippy --fix --tests --allow-dirty "$@" -clippy: +clippy *args: cargo clippy --tests "$@" + ../tools/argument-comment-lint/run-prebuilt-linter.sh "$@" install: rustup show active-toolchain @@ -89,6 +90,10 @@ write-hooks-schema: # Run the argument-comment Dylint checks across codex-rs. [no-cd] argument-comment-lint *args: + ./tools/argument-comment-lint/run-prebuilt-linter.sh "$@" + +[no-cd] +argument-comment-lint-from-source *args: ./tools/argument-comment-lint/run.sh "$@" # Tail logs from the state SQLite database diff --git a/tools/argument-comment-lint/README.md b/tools/argument-comment-lint/README.md index 91c1fdecc8..45894d41bb 100644 --- a/tools/argument-comment-lint/README.md +++ b/tools/argument-comment-lint/README.md @@ -73,21 +73,53 @@ GitHub releases also publish a DotSlash file named x64. The published package contains a small runner executable, a bundled `cargo-dylint`, and the prebuilt lint library. -Run the lint against `codex-rs` from the repo root: +The checked-in DotSlash file lives at `tools/argument-comment-lint/argument-comment-lint`. +`run-prebuilt-linter.sh` resolves that file via `dotslash` and is the path used by +`just clippy`, `just argument-comment-lint`, and the Rust CI job. The +source-build path remains available in `run.sh` for people +iterating on the lint crate itself. + +The Unix archive layout is: + +```text +argument-comment-lint/ + bin/ + argument-comment-lint + cargo-dylint + lib/ + libargument_comment_lint@nightly-2025-09-18-.dylib|so +``` + +On Windows the same layout is published as a `.zip`, with `.exe` and `.dll` +filenames instead. + +DotSlash resolves the package entrypoint to `argument-comment-lint/bin/argument-comment-lint` +(or `.exe` on Windows). That runner then finds the sibling bundled +`cargo-dylint` binary and the single packaged Dylint library under `lib/`, and +invokes `cargo-dylint dylint --lib-path ` with the repo's default +`DYLINT_RUSTFLAGS` and `CARGO_INCREMENTAL=0` settings. + +If you are changing the lint crate itself, use the source-build wrapper: ```bash ./tools/argument-comment-lint/run.sh -p codex-core +``` + +Run the lint against `codex-rs` from the repo root: + +```bash +./tools/argument-comment-lint/run-prebuilt-linter.sh -p codex-core just argument-comment-lint -p codex-core ``` -If no package selection is provided, `run.sh` defaults to checking the +If no package selection is provided, `run-prebuilt-linter.sh` defaults to checking the `codex-rs` workspace with `--workspace --no-deps`. Repo runs also promote `uncommented_anonymous_literal_argument` to an error by default: ```bash -./tools/argument-comment-lint/run.sh -p codex-core +./tools/argument-comment-lint/run-prebuilt-linter.sh -p codex-core ``` The wrapper does that by setting `DYLINT_RUSTFLAGS`, and it leaves an explicit @@ -105,5 +137,5 @@ CARGO_INCREMENTAL=1 \ To expand target coverage for an ad hoc run: ```bash -./tools/argument-comment-lint/run.sh -p codex-core -- --all-targets +./tools/argument-comment-lint/run-prebuilt-linter.sh -p codex-core -- --all-targets ``` diff --git a/tools/argument-comment-lint/argument-comment-lint b/tools/argument-comment-lint/argument-comment-lint new file mode 100755 index 0000000000..602117e3ce --- /dev/null +++ b/tools/argument-comment-lint/argument-comment-lint @@ -0,0 +1,79 @@ +#!/usr/bin/env dotslash + +{ + "name": "argument-comment-lint", + "platforms": { + "macos-aarch64": { + "size": 3402747, + "hash": "blake3", + "digest": "a11669d2f184a2c6f226cedce1bf10d1ec478d53413c42fe80d17dd873fdb2d7", + "format": "tar.gz", + "path": "argument-comment-lint/bin/argument-comment-lint", + "providers": [ + { + "url": "https://github.com/openai/codex/releases/download/rust-v0.117.0-alpha.2/argument-comment-lint-aarch64-apple-darwin.tar.gz" + }, + { + "type": "github-release", + "repo": "https://github.com/openai/codex", + "tag": "rust-v0.117.0-alpha.2", + "name": "argument-comment-lint-aarch64-apple-darwin.tar.gz" + } + ] + }, + "linux-x86_64": { + "size": 3869711, + "hash": "blake3", + "digest": "1015f4ba07d57edc5ec79c8f6709ddc1516f64c903e909820437a4b89d8d853a", + "format": "tar.gz", + "path": "argument-comment-lint/bin/argument-comment-lint", + "providers": [ + { + "url": "https://github.com/openai/codex/releases/download/rust-v0.117.0-alpha.2/argument-comment-lint-x86_64-unknown-linux-gnu.tar.gz" + }, + { + "type": "github-release", + "repo": "https://github.com/openai/codex", + "tag": "rust-v0.117.0-alpha.2", + "name": "argument-comment-lint-x86_64-unknown-linux-gnu.tar.gz" + } + ] + }, + "linux-aarch64": { + "size": 3759446, + "hash": "blake3", + "digest": "91f2a31e6390ca728ad09ae1aa6b6f379c67d996efcc22956001df89f068af5b", + "format": "tar.gz", + "path": "argument-comment-lint/bin/argument-comment-lint", + "providers": [ + { + "url": "https://github.com/openai/codex/releases/download/rust-v0.117.0-alpha.2/argument-comment-lint-aarch64-unknown-linux-gnu.tar.gz" + }, + { + "type": "github-release", + "repo": "https://github.com/openai/codex", + "tag": "rust-v0.117.0-alpha.2", + "name": "argument-comment-lint-aarch64-unknown-linux-gnu.tar.gz" + } + ] + }, + "windows-x86_64": { + "size": 3244599, + "hash": "blake3", + "digest": "dc711c6d85b1cabbe52447dda3872deb20c2e64b155da8be0ecb207c7c391683", + "format": "zip", + "path": "argument-comment-lint/bin/argument-comment-lint.exe", + "providers": [ + { + "url": "https://github.com/openai/codex/releases/download/rust-v0.117.0-alpha.2/argument-comment-lint-x86_64-pc-windows-msvc.zip" + }, + { + "type": "github-release", + "repo": "https://github.com/openai/codex", + "tag": "rust-v0.117.0-alpha.2", + "name": "argument-comment-lint-x86_64-pc-windows-msvc.zip" + } + ] + } + } +} diff --git a/tools/argument-comment-lint/run-prebuilt-linter.sh b/tools/argument-comment-lint/run-prebuilt-linter.sh new file mode 100755 index 0000000000..9fbd15c432 --- /dev/null +++ b/tools/argument-comment-lint/run-prebuilt-linter.sh @@ -0,0 +1,74 @@ +#!/usr/bin/env bash + +set -euo pipefail + +repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" +manifest_path="$repo_root/codex-rs/Cargo.toml" +dotslash_manifest="$repo_root/tools/argument-comment-lint/argument-comment-lint" + +has_manifest_path=false +has_package_selection=false +has_no_deps=false +expect_value="" + +for arg in "$@"; do + if [[ -n "$expect_value" ]]; then + case "$expect_value" in + manifest_path) + has_manifest_path=true + ;; + package_selection) + has_package_selection=true + ;; + esac + expect_value="" + continue + fi + + case "$arg" in + --) + break + ;; + --manifest-path) + expect_value="manifest_path" + ;; + --manifest-path=*) + has_manifest_path=true + ;; + -p|--package) + expect_value="package_selection" + ;; + --package=*) + has_package_selection=true + ;; + --workspace) + has_package_selection=true + ;; + --no-deps) + has_no_deps=true + ;; + esac +done + +lint_args=() +if [[ "$has_manifest_path" == false ]]; then + lint_args+=(--manifest-path "$manifest_path") +fi +if [[ "$has_package_selection" == false ]]; then + lint_args+=(--workspace) +fi +if [[ "$has_no_deps" == false ]]; then + lint_args+=(--no-deps) +fi +lint_args+=("$@") + +if ! command -v dotslash >/dev/null 2>&1; then + cat >&2 </dev/null 2>&1 || ! command -v dylint-link >/dev/null 2>&1; then + cat >&2 <&2 <