mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-24 05:25:17 +00:00
![]() This tackles three problems: * pre-commit was slow because it ran cargo commands * Improve the clarity on what you need to run to get your PR pass on CI (and make those fast) * You had to compile and run `cargo dev generate-all` separately, which was slow The first change is to remove all cargo commands except running ruff itself from pre-commit. With `cargo run --bin ruff` already compiled it takes about 7s on my machine. It would make sense to also use the ruff pre-commit action here even if we're then lagging a release behind for checking ruff on ruff. The contributing guide is now clear about what you need to run: ```shell cargo clippy --workspace --all-targets --all-features -- -D warnings # Linting... RUFF_UPDATE_SCHEMA=1 cargo test # Testing and updating ruff.schema.json pre-commit run --all-files # rust and python formatting, markdown and python linting, etc. ``` Example timings from my machine: `cargo clippy --workspace --all-targets --all-features -- -D warnings`: 23s `RUFF_UPDATE_SCHEMA=1 cargo test`: 2min (recompiling), 1min (no code changes, this is mainly doc tests) `pre-commit run --all-files`: 7s The exact numbers don't matter so much as the approximate experience (6s is easier to just wait than 1min, esp if you need to fix and rerun). The biggest remaining block seems to be doc tests, i'm surprised i didn't find any solution to speeding them up (nextest simply doesn't run them at all). Also note that the formatter has it's own tests which are much faster since they avoid linking ruff (`cargo test ruff_python_formatter`). The third change is to enable `cargo test` to update the schema. Similar to `INSTA_UPDATE=always`, i've added `RUFF_UPDATE_SCHEMA=1` (name open to bikeshedding), so `RUFF_UPDATE_SCHEMA=1 cargo test` updates the schema, while `cargo test` still fails as expected if the repo isn't up-to-date. --------- Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com> |
||
---|---|---|
.. | ||
src | ||
Cargo.toml |