mirror of
https://github.com/openai/codex.git
synced 2026-09-13 11:47:17 +00:00
Use released DotSlash package for argument-comment lint
This commit is contained in:
8
.github/workflows/rust-ci.yml
vendored
8
.github/workflows/rust-ci.yml
vendored
@@ -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:
|
||||
|
||||
7
justfile
7
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
|
||||
|
||||
@@ -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-<target>.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 <that-library>` 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
|
||||
```
|
||||
|
||||
79
tools/argument-comment-lint/argument-comment-lint
Executable file
79
tools/argument-comment-lint/argument-comment-lint
Executable file
@@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
74
tools/argument-comment-lint/run-prebuilt-linter.sh
Executable file
74
tools/argument-comment-lint/run-prebuilt-linter.sh
Executable file
@@ -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 <<EOF
|
||||
argument-comment-lint prebuilt wrapper requires dotslash.
|
||||
Install dotslash, or use:
|
||||
./tools/argument-comment-lint/run.sh ...
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exec "$dotslash_manifest" "${lint_args[@]}"
|
||||
@@ -5,6 +5,7 @@ set -euo pipefail
|
||||
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
lint_path="$repo_root/tools/argument-comment-lint"
|
||||
manifest_path="$repo_root/codex-rs/Cargo.toml"
|
||||
toolchain_channel="nightly-2025-09-18"
|
||||
strict_lint="uncommented-anonymous-literal-argument"
|
||||
noise_lint="unknown_lints"
|
||||
|
||||
@@ -14,6 +15,42 @@ has_no_deps=false
|
||||
has_library_selection=false
|
||||
expect_value=""
|
||||
|
||||
ensure_local_prerequisites() {
|
||||
if ! command -v cargo-dylint >/dev/null 2>&1 || ! command -v dylint-link >/dev/null 2>&1; then
|
||||
cat >&2 <<EOF
|
||||
argument-comment-lint source wrapper requires cargo-dylint and dylint-link.
|
||||
Install them with:
|
||||
cargo install --locked cargo-dylint dylint-link
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! rustup toolchain list | grep -q "^${toolchain_channel}"; then
|
||||
cat >&2 <<EOF
|
||||
argument-comment-lint source wrapper requires the ${toolchain_channel} toolchain with rustc-dev support.
|
||||
Install it with:
|
||||
rustup toolchain install ${toolchain_channel} \\
|
||||
--component llvm-tools-preview \\
|
||||
--component rustc-dev \\
|
||||
--component rust-src
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
set_default_env() {
|
||||
if [[ "${DYLINT_RUSTFLAGS:-}" != *"$strict_lint"* ]]; then
|
||||
export DYLINT_RUSTFLAGS="${DYLINT_RUSTFLAGS:+${DYLINT_RUSTFLAGS} }-D $strict_lint"
|
||||
fi
|
||||
if [[ "${DYLINT_RUSTFLAGS:-}" != *"$noise_lint"* ]]; then
|
||||
export DYLINT_RUSTFLAGS="${DYLINT_RUSTFLAGS:+${DYLINT_RUSTFLAGS} }-A $noise_lint"
|
||||
fi
|
||||
|
||||
if [[ -z "${CARGO_INCREMENTAL:-}" ]]; then
|
||||
export CARGO_INCREMENTAL=0
|
||||
fi
|
||||
}
|
||||
|
||||
for arg in "$@"; do
|
||||
if [[ -n "$expect_value" ]]; then
|
||||
case "$expect_value" in
|
||||
@@ -62,30 +99,25 @@ for arg in "$@"; do
|
||||
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+=("$@")
|
||||
|
||||
ensure_local_prerequisites
|
||||
set_default_env
|
||||
|
||||
cmd=(cargo dylint --path "$lint_path")
|
||||
if [[ "$has_library_selection" == false ]]; then
|
||||
cmd+=(--all)
|
||||
fi
|
||||
if [[ "$has_manifest_path" == false ]]; then
|
||||
cmd+=(--manifest-path "$manifest_path")
|
||||
fi
|
||||
if [[ "$has_package_selection" == false ]]; then
|
||||
cmd+=(--workspace)
|
||||
fi
|
||||
if [[ "$has_no_deps" == false ]]; then
|
||||
cmd+=(--no-deps)
|
||||
fi
|
||||
cmd+=("$@")
|
||||
|
||||
if [[ "${DYLINT_RUSTFLAGS:-}" != *"$strict_lint"* ]]; then
|
||||
export DYLINT_RUSTFLAGS="${DYLINT_RUSTFLAGS:+${DYLINT_RUSTFLAGS} }-D $strict_lint"
|
||||
fi
|
||||
if [[ "${DYLINT_RUSTFLAGS:-}" != *"$noise_lint"* ]]; then
|
||||
export DYLINT_RUSTFLAGS="${DYLINT_RUSTFLAGS:+${DYLINT_RUSTFLAGS} }-A $noise_lint"
|
||||
fi
|
||||
|
||||
if [[ -z "${CARGO_INCREMENTAL:-}" ]]; then
|
||||
export CARGO_INCREMENTAL=0
|
||||
fi
|
||||
cmd+=("${lint_args[@]}")
|
||||
|
||||
exec "${cmd[@]}"
|
||||
|
||||
Reference in New Issue
Block a user