mirror of https://github.com/astral-sh/ruff
190 lines
6.1 KiB
YAML
190 lines
6.1 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
env:
|
|
CARGO_INCREMENTAL: 0
|
|
CARGO_NET_RETRY: 10
|
|
RUSTUP_MAX_RETRIES: 10
|
|
|
|
jobs:
|
|
cargo-build:
|
|
name: "cargo build"
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: actions-rs/toolchain@v1
|
|
with:
|
|
profile: minimal
|
|
toolchain: nightly-2022-11-01
|
|
override: true
|
|
components: rustfmt
|
|
- uses: actions/cache@v3
|
|
env:
|
|
cache-name: cache-cargo
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/Cargo.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-build-${{ env.cache-name }}-
|
|
${{ runner.os }}-build-
|
|
${{ runner.os }}-
|
|
- run: cargo build --all --release
|
|
- run: ./target/release/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 src/checks_gen.rs || echo "::error file=src/checks_gen.rs::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 --exit-code -- README.md src/checks_gen.rs ruff.schema.json
|
|
|
|
cargo-fmt:
|
|
name: "cargo fmt"
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: actions-rs/toolchain@v1
|
|
with:
|
|
profile: minimal
|
|
toolchain: nightly-2022-11-01
|
|
override: true
|
|
components: rustfmt
|
|
- uses: actions/cache@v3
|
|
env:
|
|
cache-name: cache-cargo
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/Cargo.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-build-${{ env.cache-name }}-
|
|
${{ runner.os }}-build-
|
|
${{ runner.os }}-
|
|
- run: cargo fmt --all --check
|
|
|
|
cargo_clippy:
|
|
name: "cargo clippy"
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: actions-rs/toolchain@v1
|
|
with:
|
|
profile: minimal
|
|
toolchain: nightly-2022-11-01
|
|
override: true
|
|
components: clippy
|
|
target: wasm32-unknown-unknown
|
|
- uses: actions/cache@v3
|
|
env:
|
|
cache-name: cache-cargo
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/Cargo.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-build-${{ env.cache-name }}-
|
|
${{ runner.os }}-build-
|
|
${{ runner.os }}-
|
|
- run: cargo clippy --workspace --all-targets --all-features -- -D warnings -W clippy::pedantic
|
|
- run: cargo clippy --workspace --target wasm32-unknown-unknown --all-features -- -D warnings -W clippy::pedantic
|
|
|
|
cargo-test:
|
|
name: "cargo test"
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: actions-rs/toolchain@v1
|
|
with:
|
|
profile: minimal
|
|
toolchain: nightly-2022-11-01
|
|
override: true
|
|
- uses: actions/cache@v3
|
|
env:
|
|
cache-name: cache-cargo
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/Cargo.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-build-${{ env.cache-name }}-
|
|
${{ runner.os }}-build-
|
|
${{ runner.os }}-
|
|
- run: pip install black[d]==22.12.0
|
|
- name: Run tests
|
|
run: |
|
|
export INSTA_SNAPSHOT_REFERENCES_FILE="$(mktemp)"
|
|
cargo test --all
|
|
USED_SNAPSHOTS=$(cat $INSTA_SNAPSHOT_REFERENCES_FILE | xargs realpath --relative-to $PWD)
|
|
UNUSED_SNAPSHOTS=$(cat <(git ls-files '*.snap') <(echo "$USED_SNAPSHOTS") | sort | uniq -u)
|
|
if [ ! -z "$UNUSED_SNAPSHOTS" ]; then
|
|
echo "Found unused snapshots:"
|
|
echo "$UNUSED_SNAPSHOTS"
|
|
exit 1
|
|
fi
|
|
- run: cargo test --package ruff --test black_compatibility_test -- --ignored
|
|
|
|
# TODO(charlie): Re-enable the `wasm-pack` tests.
|
|
# See: https://github.com/charliermarsh/ruff/issues/1425
|
|
# wasm-pack-test:
|
|
# name: "wasm-pack test"
|
|
# runs-on: ubuntu-latest
|
|
# env:
|
|
# WASM_BINDGEN_TEST_TIMEOUT: 60
|
|
# steps:
|
|
# - uses: actions/checkout@v3
|
|
# - uses: actions-rs/toolchain@v1
|
|
# with:
|
|
# profile: minimal
|
|
# toolchain: nightly-2022-11-01
|
|
# override: true
|
|
# - uses: actions/cache@v3
|
|
# env:
|
|
# cache-name: cache-cargo
|
|
# with:
|
|
# path: |
|
|
# ~/.cargo/registry
|
|
# ~/.cargo/git
|
|
# key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/Cargo.lock') }}
|
|
# restore-keys: |
|
|
# ${{ runner.os }}-build-${{ env.cache-name }}-
|
|
# ${{ runner.os }}-build-
|
|
# ${{ runner.os }}-
|
|
# - uses: jetli/wasm-pack-action@v0.4.0
|
|
# - uses: jetli/wasm-bindgen-action@v0.2.0
|
|
# - run: wasm-pack test --node
|
|
|
|
maturin-build:
|
|
name: "maturin build"
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: actions-rs/toolchain@v1
|
|
with:
|
|
profile: minimal
|
|
toolchain: nightly-2022-11-01
|
|
override: true
|
|
- uses: actions/setup-python@v4
|
|
with:
|
|
python-version: "3.11"
|
|
- run: pip install maturin
|
|
- uses: actions/cache@v3
|
|
env:
|
|
cache-name: cache-cargo
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/Cargo.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-build-${{ env.cache-name }}-
|
|
${{ runner.os }}-build-
|
|
${{ runner.os }}-
|
|
- run: maturin build -b bin
|