name: Rust CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
CARGO_TERM_COLOR: always
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- name: Check formatting
run: cargo fmt --all -- --check
- name: Run clippy
run: cargo clippy --all-features --all-targets -- -D warnings
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Build (default features)
run: cargo build
- name: Build (utoipa only)
run: cargo build --features utoipa
- name: Build (rest)
run: cargo build --features rest
- name: Build (postgres)
run: cargo build --features postgres
- name: Build (mongodb)
run: cargo build --features mongodb
- name: Build (all features)
run: cargo build --all-features
build-wasm:
name: Build WASM
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- uses: Swatinem/rust-cache@v2
- name: Build (wasm)
run: cargo build --target wasm32-unknown-unknown --features wasm
- name: Build (wasm + utoipa)
run: cargo build --target wasm32-unknown-unknown --features wasm,utoipa
test:
name: Test
runs-on: ubuntu-latest
services:
mongodb:
image: mongo:latest
ports:
- 27017:27017
postgres:
image: postgres:latest
env:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Run lib tests
run: cargo test --all-features
- name: Run bank tests
run: cargo test -p bank --all-features
env:
MONGODB_TEST_URI: mongodb://localhost:27017
- name: Run todolist tests
run: cargo test -p todolist --all-features
env:
PG_TEST_URI: postgres://postgres:postgres@localhost:5432/postgres
- name: Run ludotheque tests
run: cargo test -p ludotheque --all-features