Upgrade Ruff (#254) #492
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Rust checks | |
on: | |
push: | |
branches: [main] | |
tags: | |
- 'c*.*.*' | |
- 'd*.*.*' | |
pull_request: | |
paths: | |
- crates/** | |
- Cargo.toml | |
- Cargo.lock | |
- .github/workflows/ci-rust.yml | |
- pyproject.toml | |
- pixi.lock | |
schedule: | |
- cron: '0 5 * * 1' | |
jobs: | |
check: | |
name: Rust - Check | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v5 | |
- uses: prefix-dev/[email protected] | |
with: | |
pixi-version: v0.50.2 | |
frozen: true | |
cache: true | |
cache-write: ${{ github.ref == 'refs/heads/main' }} | |
environments: pdev rdev | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
shared-key: "gha" | |
# Don't save cache for cargo check! | |
save-if: false | |
- name: Run cargo check | |
run: | | |
pixi run -e rdev --frozen cargo check --workspace --locked | |
lints: | |
# Only run tests if code looks OK | |
needs: check | |
name: Rust - Lint | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v5 | |
- uses: prefix-dev/[email protected] | |
with: | |
pixi-version: v0.50.2 | |
frozen: true | |
cache: true | |
cache-write: ${{ github.ref == 'refs/heads/main' }} | |
environments: pdev rdev | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
shared-key: "gha" | |
# Don't save cache for cargo fmt or clippy! | |
save-if: false | |
- name: Run cargo fmt | |
run: | | |
pixi run -e rdev --frozen cargo fmt --all --check | |
- name: Run cargo clippy | |
run: | | |
pixi run -e rdev --frozen cargo clippy --locked --all-features --tests -- -D warnings | |
test: | |
# Only run tests if code looks OK | |
needs: check | |
name: Rust - Test | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
steps: | |
- uses: actions/checkout@v5 | |
- uses: prefix-dev/[email protected] | |
with: | |
pixi-version: v0.50.2 | |
frozen: true | |
cache: true | |
cache-write: ${{ github.ref == 'refs/heads/main' }} | |
environments: pdev rdev | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
shared-key: "gha" | |
save-if: ${{ github.ref == 'refs/heads/main' }} | |
- run: pixi run -e rdev --frozen tests-r | |
publish-dry: | |
name: Rust - Publish (dry-run) | |
# Only run tests if code looks OK | |
needs: check | |
runs-on: ubuntu-latest | |
if: ${{ !startsWith(github.ref, 'refs/heads/main') && !startsWith(github.ref, 'refs/tags/c') && !startsWith(github.ref, 'refs/tags/d') }} | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v5 | |
- uses: prefix-dev/[email protected] | |
with: | |
pixi-version: v0.50.2 | |
frozen: true | |
cache: true | |
cache-write: ${{ github.ref == 'refs/heads/main' }} | |
environments: rdev | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
shared-key: "gha" | |
save-if: false | |
- name: Publish crates (DB) | |
run: | | |
pixi run -e rdev --frozen publish-db --dry-run | |
- name: Publish crates (CLI) | |
run: | | |
pixi run -e rdev --frozen publish-cli --dry-run | |
publish-cli: | |
name: Publish Rust CLI crate | |
# Only publish if tests pass | |
needs: test | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/c') | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v5 | |
- uses: prefix-dev/[email protected] | |
with: | |
pixi-version: v0.50.2 | |
frozen: true | |
cache: true | |
cache-write: ${{ github.ref == 'refs/heads/main' }} | |
environments: rdev | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
shared-key: "gha" | |
save-if: false | |
- name: Publish crates (CLI) | |
run: | | |
pixi run -e rdev --frozen publish-cli | |
env: | |
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
publish-db: | |
name: Publish Rust DB crate | |
# Only publish if tests pass | |
needs: test | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/d') | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v5 | |
- uses: prefix-dev/[email protected] | |
with: | |
pixi-version: v0.50.2 | |
frozen: true | |
cache: true | |
cache-write: ${{ github.ref == 'refs/heads/main' }} | |
environments: rdev | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
shared-key: "gha" | |
save-if: false | |
- name: Publish crates (DB) | |
run: | | |
pixi run -e rdev --frozen publish-db | |
env: | |
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |