name: Rust Library CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
runs-on: depot-ubuntu-24.04
services:
postgres:
image: postgres:15
env:
POSTGRES_DB: test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.9
- name: Install cargo-binstall
uses: cargo-bins/cargo-binstall@main
- name: Install sqlx-cli
env:
RUSTC_WRAPPER: "sccache"
run: cargo binstall sqlx-cli --no-confirm
- name: Run database migrations
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/test
run: sqlx migrate run
- name: Run Tests
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/test
RUSTC_WRAPPER: "sccache"
run: cargo test --verbose
- name: Check formatting
run: cargo fmt --check
- name: Run Clippy
env:
RUSTC_WRAPPER: "sccache"
run: cargo clippy -- -D warnings