From 0b34ca71072c6e6043fb60e694b211918aa6f485 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Fri, 27 Jan 2023 18:35:19 -0500 Subject: [PATCH] Move off nightly Rust for dev workflows (#2278) --- .github/workflows/ci.yaml | 19 ++++--------------- .github/workflows/playground.yaml | 2 -- .pre-commit-config.yaml | 2 +- CONTRIBUTING.md | 19 +++++++------------ rustfmt.toml | 11 ----------- 5 files changed, 12 insertions(+), 41 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 74baaec943..780f152bc1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -25,13 +25,11 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: nightly-2022-11-01 - override: true - uses: Swatinem/rust-cache@v1 - run: cargo build --all - run: ./target/debug/ruff_dev generate-all - - run: git diff --quiet README.md || echo "::error file=README.md::This file is outdated. Run 'cargo +nightly dev generate-all'." - - run: git diff --quiet ruff.schema.json || echo "::error file=ruff.schema.json::This file is outdated. Run 'cargo +nightly dev generate-all'." + - run: git diff --quiet README.md || echo "::error file=README.md::This file is outdated. Run 'cargo dev generate-all'." + - run: git diff --quiet ruff.schema.json || echo "::error file=ruff.schema.json::This file is outdated. Run 'cargo dev generate-all'." - run: git diff --exit-code -- README.md ruff.schema.json cargo-fmt: @@ -42,8 +40,6 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: nightly-2022-11-01 - override: true components: rustfmt - run: cargo fmt --all --check @@ -55,8 +51,6 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: nightly-2022-11-01 - override: true components: clippy target: wasm32-unknown-unknown - uses: Swatinem/rust-cache@v1 @@ -74,8 +68,6 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.65.0 - override: true - uses: Swatinem/rust-cache@v1 - run: cargo install cargo-insta - run: pip install black[d]==22.12.0 @@ -105,7 +97,6 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - override: true - uses: Swatinem/rust-cache@v1 - run: ./scripts/add_rule.py --name DoTheThing --code PLC999 --linter pylint - run: cargo check @@ -126,8 +117,8 @@ jobs: # - uses: actions-rs/toolchain@v1 # with: # profile: minimal -# toolchain: nightly-2022-11-01 -# override: true + + # - uses: actions/cache@v3 # env: # cache-name: cache-cargo @@ -152,8 +143,6 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.65.0 - override: true - uses: Swatinem/rust-cache@v1 - uses: actions/setup-python@v4 with: diff --git a/.github/workflows/playground.yaml b/.github/workflows/playground.yaml index 7be584d8c5..de7a8ba241 100644 --- a/.github/workflows/playground.yaml +++ b/.github/workflows/playground.yaml @@ -21,8 +21,6 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: nightly-2022-11-01 - override: true target: wasm32-unknown-unknown - uses: actions/setup-node@v3 with: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 940acfd353..06ebbc31f6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,6 +15,6 @@ repos: hooks: - id: cargo-fmt name: cargo fmt - entry: cargo +nightly fmt -- + entry: cargo fmt -- language: rust types: [rust] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8533cc278f..8ffc8662f3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -39,14 +39,11 @@ cargo run resources/test/fixtures --no-cache ``` Prior to opening a pull request, ensure that your code has been auto-formatted, -and that it passes both the lint and test validation checks. - -For rustfmt and Clippy, we use [nightly Rust][nightly], as it is stricter than stable Rust. -(However, tests and builds use stable Rust.) +and that it passes both the lint and test validation checks: ```shell -cargo +nightly fmt --all # Auto-formatting... -cargo +nightly clippy --fix --workspace --all-targets --all-features # Linting... +cargo fmt --all # Auto-formatting... +cargo clippy --fix --workspace --all-targets --all-features # Linting... cargo test --all # Testing... ``` @@ -79,7 +76,7 @@ To trigger the violation, you'll likely want to augment the logic in `src/checke defines the Python AST visitor, responsible for iterating over the abstract syntax tree and collecting diagnostics as it goes. -If you need to inspect the AST, you can run `cargo +nightly dev print-ast` with a Python file. Grep +If you need to inspect the AST, you can run `cargo dev print-ast` with a Python file. Grep for the `Check::new` invocations to understand how other, similar rules are implemented. To add a test fixture, create a file under `resources/test/fixtures/[linter]`, named to match @@ -87,7 +84,7 @@ the code you defined earlier (e.g., `resources/test/fixtures/pycodestyle/E402.py contain a variety of violations and non-violations designed to evaluate and demonstrate the behavior of your lint rule. -Run `cargo +nightly dev generate-all` to generate the code for your new fixture. Then run Ruff +Run `cargo dev generate-all` to generate the code for your new fixture. Then run Ruff locally with (e.g.) `cargo run resources/test/fixtures/pycodestyle/E402.py --no-cache --select E402`. Once you're satisfied with the output, codify the behavior as a snapshot test by adding a new @@ -95,7 +92,7 @@ Once you're satisfied with the output, codify the behavior as a snapshot test by Your test will fail, but you'll be prompted to follow-up with `cargo insta review`. Accept the generated snapshot, then commit the snapshot file alongside the rest of your changes. -Finally, regenerate the documentation and generated code with `cargo +nightly dev generate-all`. +Finally, regenerate the documentation and generated code with `cargo dev generate-all`. ### Example: Adding a new configuration option @@ -121,7 +118,7 @@ You may also want to add the new configuration option to the `flake8-to-ruff` to responsible for converting `flake8` configuration files to Ruff's TOML format. This logic lives in `flake8_to_ruff/src/converter.rs`. -Finally, regenerate the documentation and generated code with `cargo +nightly dev generate-all`. +Finally, regenerate the documentation and generated code with `cargo dev generate-all`. ## Release process @@ -131,5 +128,3 @@ them to [PyPI](https://pypi.org/project/ruff/). Ruff follows the [semver](https://semver.org/) versioning standard. However, as pre-1.0 software, even patch releases may contain [non-backwards-compatible changes](https://semver.org/#spec-item-4). - -[nightly]: https://rust-lang.github.io/rustup/concepts/channels.html#working-with-nightly-rust diff --git a/rustfmt.toml b/rustfmt.toml index b22a925c16..5325a858f8 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,15 +1,4 @@ -condense_wildcard_suffixes = true edition = "2021" -format_strings = true -group_imports = "StdExternalCrate" -hex_literal_case = "Lower" -imports_granularity = "Module" max_width = 100 -normalize_comments = true -normalize_doc_attributes = true -reorder_impl_items = true reorder_imports = true reorder_modules = true -unstable_features = true -use_field_init_shorthand = true -wrap_comments = true