name: CI on: push: branches: [main] pull_request: workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number || github.sha }} cancel-in-progress: true env: CARGO_INCREMENTAL: 0 CARGO_NET_RETRY: 10 CARGO_TERM_COLOR: always RUSTUP_MAX_RETRIES: 10 jobs: cargo-build: name: "cargo build" runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: "Install Rust toolchain" run: rustup show - 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 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 docs cargo-fmt: name: "cargo fmt" runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: "Install Rust toolchain" run: rustup component add rustfmt - run: cargo fmt --all --check cargo-clippy: name: "cargo clippy" runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: "Install Rust toolchain" run: | rustup component add clippy - uses: Swatinem/rust-cache@v1 - run: cargo clippy --workspace --all-targets --all-features -- -D warnings cargo-clippy-wasm: name: "cargo clippy (wasm)" runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: "Install Rust toolchain" run: | rustup component add clippy rustup target add wasm32-unknown-unknown - uses: Swatinem/rust-cache@v1 - run: cargo clippy -p ruff --target wasm32-unknown-unknown --all-features -- -D warnings cargo-test: strategy: matrix: os: [ubuntu-latest, windows-latest] runs-on: ${{ matrix.os }} name: "cargo test | ${{ matrix.os }}" steps: - uses: actions/checkout@v3 - name: "Install Rust toolchain" run: rustup show - uses: Swatinem/rust-cache@v1 - run: cargo install cargo-insta - run: pip install black[d]==22.12.0 - name: "Run tests (Ubuntu)" if: ${{ matrix.os == 'ubuntu-latest' }} run: | cargo insta test --all --all-features --delete-unreferenced-snapshots git diff --exit-code - name: "Run tests (Windows)" if: ${{ matrix.os == 'windows-latest' }} shell: bash run: | cargo insta test --all --all-features git diff --exit-code - run: cargo test --package ruff_cli --test black_compatibility_test -- --ignored # Check for broken links in the documentation. - run: cargo doc --all --no-deps env: # Setting RUSTDOCFLAGS because `cargo doc --check` isn't yet implemented (https://github.com/rust-lang/cargo/issues/10025). RUSTDOCFLAGS: "-D warnings" scripts: name: "test scripts" runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: "Install Rust toolchain" run: rustup show - uses: Swatinem/rust-cache@v1 - run: ./scripts/add_rule.py --name DoTheThing --code PLC999 --linter pylint - run: cargo check - run: | ./scripts/add_plugin.py test --url https://pypi.org/project/-test/0.1.0/ --prefix TST ./scripts/add_rule.py --name FirstRule --code TST001 --linter test - run: cargo check maturin-build: name: "maturin build" runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: "Install Rust toolchain" run: rustup show - uses: Swatinem/rust-cache@v1 - uses: actions/setup-python@v4 with: python-version: "3.11" - run: pip install maturin - run: maturin build -b bin - run: python scripts/transform_readme.py --target pypi typos: name: "spell check" runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: crate-ci/typos@master with: files: .