Rust Checks #606
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*.*.*' | |
| paths: | |
| - crates/** | |
| - Cargo.toml | |
| - Cargo.lock | |
| - .github/workflows/ci-rust.yml | |
| - pyproject.toml | |
| - pixi.lock | |
| 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@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| - uses: prefix-dev/setup-pixi@v0.9.3 | |
| with: | |
| pixi-version: v0.59.0 | |
| frozen: true | |
| cache: true | |
| cache-write: ${{ github.ref == 'refs/heads/main' }} | |
| environments: 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 --locked 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@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| - uses: prefix-dev/setup-pixi@v0.9.3 | |
| with: | |
| pixi-version: v0.59.0 | |
| frozen: true | |
| cache: true | |
| cache-write: ${{ github.ref == 'refs/heads/main' }} | |
| environments: 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 --locked cargo fmt --all --check | |
| - name: Run cargo clippy | |
| run: | | |
| pixi run -e rdev --locked cargo clippy --locked --all-features --tests -- -D warnings | |
| test: | |
| # Only run tests if code looks OK | |
| needs: check | |
| name: Rust - Tests | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| steps: | |
| - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| - uses: prefix-dev/setup-pixi@v0.9.3 | |
| with: | |
| pixi-version: v0.59.0 | |
| frozen: true | |
| cache: true | |
| cache-write: ${{ github.ref == 'refs/heads/main' }} | |
| environments: rdev | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| shared-key: "gha" | |
| save-if: ${{ github.ref == 'refs/heads/main' }} | |
| - name: Run tests for windows | |
| if: runner.os == 'Windows' | |
| env: | |
| RUSTFLAGS: "-C link-args=rstrtmgr.lib" | |
| run: pixi run -e rdev tests-r | |
| - name: Run tests | |
| if: runner.os != 'Windows' | |
| run: pixi run -e rdev 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@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| - uses: prefix-dev/setup-pixi@v0.9.3 | |
| with: | |
| pixi-version: v0.59.0 | |
| 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 --locked publish-db --dry-run | |
| - name: Publish crates (CLI) | |
| run: | | |
| pixi run -e rdev --locked 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@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| - uses: prefix-dev/setup-pixi@v0.9.3 | |
| with: | |
| pixi-version: v0.59.0 | |
| 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 --locked 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@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| - uses: prefix-dev/setup-pixi@v0.9.3 | |
| with: | |
| pixi-version: v0.59.0 | |
| 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 --locked publish-db | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |