mirror of
https://github.com/astral-sh/ruff
synced 2026-01-21 13:30:49 -05:00
166 lines
4.9 KiB
YAML
166 lines
4.9 KiB
YAML
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-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@v2
|
|
- 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@v2
|
|
- run: cargo clippy -p ruff_wasm --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@v2
|
|
- run: cargo install cargo-insta
|
|
- run: pip install black[d]==23.1.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"
|
|
- uses: actions/upload-artifact@v3
|
|
with:
|
|
name: ruff
|
|
path: target/debug/ruff
|
|
|
|
|
|
cargo-test-wasm:
|
|
runs-on: ubuntu-latest
|
|
name: "cargo test (wasm)"
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- name: "Install Rust toolchain"
|
|
run: rustup target add wasm32-unknown-unknown
|
|
- uses: actions/setup-node@v3
|
|
with:
|
|
node-version: 18
|
|
cache: "npm"
|
|
cache-dependency-path: playground/package-lock.json
|
|
- uses: jetli/wasm-pack-action@v0.4.0
|
|
- uses: Swatinem/rust-cache@v2
|
|
- name: "Run wasm-pack"
|
|
run: |
|
|
cd crates/ruff_wasm
|
|
wasm-pack test --node
|
|
|
|
scripts:
|
|
name: "test scripts"
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- name: "Install Rust toolchain"
|
|
run: rustup show
|
|
- uses: Swatinem/rust-cache@v2
|
|
- 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
|
|
|
|
typos:
|
|
name: "spell check"
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: crate-ci/typos@master
|
|
with:
|
|
files: .
|
|
|
|
ecosystem:
|
|
name: "ecosystem"
|
|
runs-on: ubuntu-latest
|
|
needs: cargo-test
|
|
# Only runs on pull requests, since that is the only we way we can find the base version for comparison.
|
|
if: github.event_name == 'pull_request'
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: actions/setup-python@v4
|
|
with:
|
|
python-version: "3.11"
|
|
- uses: actions/download-artifact@v3
|
|
id: ruff-target
|
|
with:
|
|
name: ruff
|
|
path: target/debug
|
|
- uses: dawidd6/action-download-artifact@v2
|
|
with:
|
|
name: ruff
|
|
branch: ${{ github.event.pull_request.base.ref }}
|
|
check_artifacts: true
|
|
- name: Run ecosystem check
|
|
run: |
|
|
# Make executable, since artifact download doesn't preserve this
|
|
chmod +x ruff ${{ steps.ruff-target.outputs.download-path }}/ruff
|
|
|
|
scripts/check_ecosystem.py ruff ${{ steps.ruff-target.outputs.download-path }}/ruff | tee ecosystem-result
|
|
|
|
echo ${{ github.event.number }} > pr-number
|
|
- uses: actions/upload-artifact@v3
|
|
with:
|
|
name: ecosystem-result
|
|
path: |
|
|
ecosystem-result
|
|
pr-number
|