From f1b2e8533976ac3400e49ee1285ea9433757a8ec Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Wed, 27 Nov 2024 22:19:52 +0000 Subject: [PATCH] py-fuzzer: recommend using `uvx` rather than `uv run` to run the fuzzer (#14645) --- .github/workflows/ci.yaml | 5 ++--- .github/workflows/daily_fuzz.yaml | 5 ++--- crates/ruff_python_parser/CONTRIBUTING.md | 2 +- python/py-fuzzer/README.md | 2 +- python/py-fuzzer/fuzz.py | 8 ++++---- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b19948958f267..05dfe6fca7510 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -330,10 +330,9 @@ jobs: chmod +x ${{ steps.download-cached-binary.outputs.download-path }}/ruff ( - uv run \ - --no-project \ + uvx \ --python=${{ env.PYTHON_VERSION }} \ - --with=./python/py-fuzzer \ + --from=./python/py-fuzzer \ fuzz \ --test-executable=${{ steps.download-cached-binary.outputs.download-path }}/ruff \ --bin=ruff \ diff --git a/.github/workflows/daily_fuzz.yaml b/.github/workflows/daily_fuzz.yaml index af7462b187b15..e4f31e7790121 100644 --- a/.github/workflows/daily_fuzz.yaml +++ b/.github/workflows/daily_fuzz.yaml @@ -45,10 +45,9 @@ jobs: - name: Fuzz run: | ( - uv run \ - --no-project \ + uvx \ --python=3.12 \ - --with=./python/py-fuzzer \ + --from=./python/py-fuzzer \ fuzz \ --test-executable=target/debug/ruff \ --bin=ruff \ diff --git a/crates/ruff_python_parser/CONTRIBUTING.md b/crates/ruff_python_parser/CONTRIBUTING.md index e881cedb977d9..0a5c580121ef4 100644 --- a/crates/ruff_python_parser/CONTRIBUTING.md +++ b/crates/ruff_python_parser/CONTRIBUTING.md @@ -62,7 +62,7 @@ To run the fuzzer, execute the following command (requires [`uv`](https://github.com/astral-sh/uv) to be installed): ```sh -uv run --no-project --with ./python/py-fuzzer fuzz +uvx --from ./python/py-fuzzer fuzz ``` Refer to the [py-fuzzer](https://github.com/astral-sh/ruff/blob/main/python/py-fuzzer/fuzz.py) diff --git a/python/py-fuzzer/README.md b/python/py-fuzzer/README.md index 5ee4383326260..5e6c71340592c 100644 --- a/python/py-fuzzer/README.md +++ b/python/py-fuzzer/README.md @@ -3,6 +3,6 @@ A fuzzer script to run Ruff executables on randomly generated (but syntactically valid) Python source-code files. -Run `uv run --no-project --with ./python/py-fuzzer fuzz -h` from the repository root +Run `uvx --from ./python/py-fuzzer fuzz -h` from the repository root for more information and example invocations (requires [`uv`](https://github.com/astral-sh/uv) to be installed). diff --git a/python/py-fuzzer/fuzz.py b/python/py-fuzzer/fuzz.py index 1b98cf2beaea6..c4713f4028c40 100644 --- a/python/py-fuzzer/fuzz.py +++ b/python/py-fuzzer/fuzz.py @@ -4,19 +4,19 @@ This script can be installed into a virtual environment using `uv pip install -e ./python/py-fuzzer` from the Ruff repository root, -or can be run using `uv run --no-project --with ./python/py-fuzzer` +or can be run using `uvx --from ./python/py-fuzzer fuzz` (in which case the virtual environment does not need to be activated). Example invocations of the script using `uv`: - Run the fuzzer on Ruff's parser using seeds 0, 1, 2, 78 and 93 to generate the code: - `uv run --no-project --with ./python/py-fuzzer fuzz --bin ruff 0-2 78 93` + `uvx --from ./python/py-fuzzer fuzz --bin ruff 0-2 78 93` - Run the fuzzer concurrently using seeds in range 0-10 inclusive, but only reporting bugs that are new on your branch: - `uv run --no-project --with ./python/py-fuzzer fuzz --bin ruff 0-10 --new-bugs-only` + `uvx --from ./python/py-fuzzer fuzz --bin ruff 0-10 --new-bugs-only` - Run the fuzzer concurrently on 10,000 different Python source-code files, using a random selection of seeds, and only print a summary at the end (the `shuf` command is Unix-specific): - `uv run --no-project --with ./python/py-fuzzer fuzz --bin ruff $(shuf -i 0-1000000 -n 10000) --quiet + `uvx --from ./python/py-fuzzer fuzz --bin ruff $(shuf -i 0-1000000 -n 10000) --quiet """ from __future__ import annotations