mirror of https://github.com/astral-sh/ruff
Move off nightly Rust for dev workflows (#2278)
This commit is contained in:
parent
df44c5124e
commit
0b34ca7107
|
|
@ -25,13 +25,11 @@ jobs:
|
||||||
- uses: actions-rs/toolchain@v1
|
- uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
profile: minimal
|
profile: minimal
|
||||||
toolchain: nightly-2022-11-01
|
|
||||||
override: true
|
|
||||||
- uses: Swatinem/rust-cache@v1
|
- uses: Swatinem/rust-cache@v1
|
||||||
- run: cargo build --all
|
- run: cargo build --all
|
||||||
- run: ./target/debug/ruff_dev generate-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 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 +nightly 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
|
- run: git diff --exit-code -- README.md ruff.schema.json
|
||||||
|
|
||||||
cargo-fmt:
|
cargo-fmt:
|
||||||
|
|
@ -42,8 +40,6 @@ jobs:
|
||||||
- uses: actions-rs/toolchain@v1
|
- uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
profile: minimal
|
profile: minimal
|
||||||
toolchain: nightly-2022-11-01
|
|
||||||
override: true
|
|
||||||
components: rustfmt
|
components: rustfmt
|
||||||
- run: cargo fmt --all --check
|
- run: cargo fmt --all --check
|
||||||
|
|
||||||
|
|
@ -55,8 +51,6 @@ jobs:
|
||||||
- uses: actions-rs/toolchain@v1
|
- uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
profile: minimal
|
profile: minimal
|
||||||
toolchain: nightly-2022-11-01
|
|
||||||
override: true
|
|
||||||
components: clippy
|
components: clippy
|
||||||
target: wasm32-unknown-unknown
|
target: wasm32-unknown-unknown
|
||||||
- uses: Swatinem/rust-cache@v1
|
- uses: Swatinem/rust-cache@v1
|
||||||
|
|
@ -74,8 +68,6 @@ jobs:
|
||||||
- uses: actions-rs/toolchain@v1
|
- uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
profile: minimal
|
profile: minimal
|
||||||
toolchain: 1.65.0
|
|
||||||
override: true
|
|
||||||
- uses: Swatinem/rust-cache@v1
|
- uses: Swatinem/rust-cache@v1
|
||||||
- run: cargo install cargo-insta
|
- run: cargo install cargo-insta
|
||||||
- run: pip install black[d]==22.12.0
|
- run: pip install black[d]==22.12.0
|
||||||
|
|
@ -105,7 +97,6 @@ jobs:
|
||||||
- uses: actions-rs/toolchain@v1
|
- uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
profile: minimal
|
profile: minimal
|
||||||
override: true
|
|
||||||
- uses: Swatinem/rust-cache@v1
|
- uses: Swatinem/rust-cache@v1
|
||||||
- run: ./scripts/add_rule.py --name DoTheThing --code PLC999 --linter pylint
|
- run: ./scripts/add_rule.py --name DoTheThing --code PLC999 --linter pylint
|
||||||
- run: cargo check
|
- run: cargo check
|
||||||
|
|
@ -126,8 +117,8 @@ jobs:
|
||||||
# - uses: actions-rs/toolchain@v1
|
# - uses: actions-rs/toolchain@v1
|
||||||
# with:
|
# with:
|
||||||
# profile: minimal
|
# profile: minimal
|
||||||
# toolchain: nightly-2022-11-01
|
|
||||||
# override: true
|
|
||||||
# - uses: actions/cache@v3
|
# - uses: actions/cache@v3
|
||||||
# env:
|
# env:
|
||||||
# cache-name: cache-cargo
|
# cache-name: cache-cargo
|
||||||
|
|
@ -152,8 +143,6 @@ jobs:
|
||||||
- uses: actions-rs/toolchain@v1
|
- uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
profile: minimal
|
profile: minimal
|
||||||
toolchain: 1.65.0
|
|
||||||
override: true
|
|
||||||
- uses: Swatinem/rust-cache@v1
|
- uses: Swatinem/rust-cache@v1
|
||||||
- uses: actions/setup-python@v4
|
- uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,6 @@ jobs:
|
||||||
- uses: actions-rs/toolchain@v1
|
- uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
profile: minimal
|
profile: minimal
|
||||||
toolchain: nightly-2022-11-01
|
|
||||||
override: true
|
|
||||||
target: wasm32-unknown-unknown
|
target: wasm32-unknown-unknown
|
||||||
- uses: actions/setup-node@v3
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,6 @@ repos:
|
||||||
hooks:
|
hooks:
|
||||||
- id: cargo-fmt
|
- id: cargo-fmt
|
||||||
name: cargo fmt
|
name: cargo fmt
|
||||||
entry: cargo +nightly fmt --
|
entry: cargo fmt --
|
||||||
language: rust
|
language: rust
|
||||||
types: [rust]
|
types: [rust]
|
||||||
|
|
|
||||||
|
|
@ -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,
|
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.
|
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.)
|
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
cargo +nightly fmt --all # Auto-formatting...
|
cargo fmt --all # Auto-formatting...
|
||||||
cargo +nightly clippy --fix --workspace --all-targets --all-features # Linting...
|
cargo clippy --fix --workspace --all-targets --all-features # Linting...
|
||||||
cargo test --all # Testing...
|
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
|
defines the Python AST visitor, responsible for iterating over the abstract syntax tree and
|
||||||
collecting diagnostics as it goes.
|
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.
|
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
|
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
|
contain a variety of violations and non-violations designed to evaluate and demonstrate the behavior
|
||||||
of your lint rule.
|
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`.
|
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
|
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
|
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.
|
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
|
### 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
|
responsible for converting `flake8` configuration files to Ruff's TOML format. This logic
|
||||||
lives in `flake8_to_ruff/src/converter.rs`.
|
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
|
## 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,
|
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).
|
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
|
|
||||||
|
|
|
||||||
11
rustfmt.toml
11
rustfmt.toml
|
|
@ -1,15 +1,4 @@
|
||||||
condense_wildcard_suffixes = true
|
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
format_strings = true
|
|
||||||
group_imports = "StdExternalCrate"
|
|
||||||
hex_literal_case = "Lower"
|
|
||||||
imports_granularity = "Module"
|
|
||||||
max_width = 100
|
max_width = 100
|
||||||
normalize_comments = true
|
|
||||||
normalize_doc_attributes = true
|
|
||||||
reorder_impl_items = true
|
|
||||||
reorder_imports = true
|
reorder_imports = true
|
||||||
reorder_modules = true
|
reorder_modules = true
|
||||||
unstable_features = true
|
|
||||||
use_field_init_shorthand = true
|
|
||||||
wrap_comments = true
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue