Skip to content

Replace graph evaluation with per-file Python values #3001

Replace graph evaluation with per-file Python values

Replace graph evaluation with per-file Python values #3001

Workflow file for this run

name: lint
on:
pull_request:
push:
branches: [main]
workflow_call:
concurrency:
group: lint-${{ github.head_ref }}
cancel-in-progress: true
permissions:
contents: read
env:
AST_GREP_VERSION: "0.44.0"
CARGO_TERM_COLOR: always
FORCE_COLOR: "1"
PYTHONUNBUFFERED: "1"
jobs:
should-run:
if: "${{ github.event_name != 'push' || startsWith(github.ref, 'refs/tags/') || !contains(github.event.head_commit.message, ':bookmark: bump version') }}"
runs-on: ubuntu-latest
steps:
- run: true
pre-commit:
needs: should-run
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
with:
activate-environment: true
enable-cache: true
# HACK: there's a bug in either `astral-sh/setup-uv` or pre-commit-uv or both
# because uv gets installed to `/opt/hostedtoolcache/uv/<version>/x86_64/uv`
# and pre-commit-uv apparently only looks for it at `~/.local/bin/uv`
- run: |
mkdir -p ~/.local/bin
ln -sf $(which uv) ~/.local/bin/uv
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.cache/pre-commit/
key: pre-commit-1|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Cache ast-grep binary
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.cargo/bin/sg
~/.cargo/bin/ast-grep
key: ${{ runner.os }}-${{ runner.arch }}-ast-grep-${{ env.AST_GREP_VERSION }}
- name: Install ast-grep
run: |
if ! command -v sg >/dev/null 2>&1 || [ "$(sg --version)" != "ast-grep ${AST_GREP_VERSION}" ]; then
cargo install ast-grep --version "${AST_GREP_VERSION}" --locked --force
fi
- name: Run pre-commit
run: |
SKIP=no-commit-to-branch,cargo-fmt,cargo-clippy \
uv run --no-project --with "nox[uv]" nox --session lint
ast-grep-tests:
needs: should-run
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- name: Cache Cargo binaries
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.cargo/bin/sg
~/.cargo/bin/ast-grep
key: ${{ runner.os }}-${{ runner.arch }}-ast-grep-${{ env.AST_GREP_VERSION }}
- name: Install ast-grep
run: |
if ! command -v sg >/dev/null 2>&1 || [ "$(sg --version)" != "ast-grep ${AST_GREP_VERSION}" ]; then
cargo install ast-grep --version "${AST_GREP_VERSION}" --locked --force
fi
- name: Run ast-grep rule tests
run: sg test --config tools/ast-grep/sgconfig.yml --skip-snapshot-tests --color=never
rust-changes:
needs: should-run
runs-on: ubuntu-latest
outputs:
rust: ${{ steps.filter.outputs.rust }}
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- uses: dorny/paths-filter@7b450fff21473bca461d4b92ce414b9d0420d706 # v4.0.2
id: filter
with:
filters: |
rust:
- '.github/workflows/lint.yml'
- 'crates/**'
- 'Cargo.lock'
- 'Cargo.toml'
rustfmt:
runs-on: ubuntu-24.04
needs: rust-changes
if: needs.rust-changes.outputs.rust == 'true'
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- name: Cache rustup toolchain
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.rustup
key: ${{ runner.os }}-${{ runner.arch }}-rustup-nightly-${{ hashFiles('.github/workflows/lint.yml') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-rustup-nightly-
- name: Cache Cargo dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.cargo/git
~/.cargo/registry
key: ${{ runner.os }}-${{ runner.arch }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-cargo-registry-
${{ runner.os }}-cargo-registry-
- uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659
with:
toolchain: nightly
components: rustfmt
- name: Run rustfmt
run: cargo +nightly fmt --all -- --check
clippy:
runs-on: ubuntu-24.04
needs: rust-changes
if: needs.rust-changes.outputs.rust == 'true'
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- name: Cache rustup toolchain
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.rustup
key: ${{ runner.os }}-${{ runner.arch }}-rustup-pinned-${{ hashFiles('rust-toolchain.toml') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-rustup-pinned-
- name: Cache Cargo dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.cargo/git
~/.cargo/registry
key: ${{ runner.os }}-${{ runner.arch }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-cargo-registry-
${{ runner.os }}-cargo-registry-
- uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659
with:
components: clippy
- name: Run clippy
run: cargo clippy --all-targets --all-features --benches -- -D warnings
cargo-check:
runs-on: ubuntu-24.04
needs: rust-changes
if: needs.rust-changes.outputs.rust == 'true'
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- name: Cache rustup toolchain
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.rustup
key: ${{ runner.os }}-${{ runner.arch }}-rustup-pinned-${{ hashFiles('rust-toolchain.toml') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-rustup-pinned-
- name: Cache Cargo registry
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.cargo/git
~/.cargo/registry
key: ${{ runner.os }}-${{ runner.arch }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-cargo-registry-
${{ runner.os }}-cargo-registry-
- uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659
- name: Run cargo check
run: cargo check --all-targets --all-features