Dev #18
This file contains 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
# .github/workflows/test.yml | |
name: Tests | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
workflow_dispatch: | |
env: | |
CARGO_TERM_COLOR: always | |
REDIS_URI: redis://localhost:6379 | |
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/testdb | |
MONGODB_URI: mongodb://localhost:27017/testdb | |
jobs: | |
test: | |
name: Test Suite | |
runs-on: ubuntu-latest | |
services: | |
redis: | |
image: redis | |
ports: | |
- 6379:6379 | |
options: >- | |
--health-cmd "redis-cli ping" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
mongodb: | |
image: mongo:6 | |
ports: | |
- 27017:27017 | |
options: >- | |
--health-cmd "mongosh --eval 'db.runCommand(\"ping\").ok'" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
postgres: | |
image: postgres:15 | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_DB: testdb | |
ports: | |
- 5432:5432 | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Install sqlx-cli | |
run: cargo install sqlx-cli --no-default-features --features postgres | |
- name: Run database migrations | |
run: cargo sqlx migrate run | |
- name: Cargo check | |
run: cargo check --all-features --workspace | |
- name: Run unit tests | |
run: cargo test --lib --all-features --workspace | |
- name: Run integration tests | |
run: cargo test --test '*' --all-features --workspace |