name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: "-D warnings"
SQLX_OFFLINE: true
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install protoc
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler
- name: Install Rust
uses: dtolnay/rust-toolchain@1.85.0
with:
components: rustfmt, clippy
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
- name: Check formatting
run: cargo fmt --all -- --check
- name: Clippy
run: cargo clippy -- -D warnings
test:
name: Build and Test
runs-on: ubuntu-latest
needs: lint
services:
redis:
image: redis
ports:
- 6379:6379
postgres:
image: pgvector/pgvector:pg17
env:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: waypoint
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- name: Install protoc and database clients
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler redis-tools postgresql-client
- name: Install Rust
uses: dtolnay/rust-toolchain@1.85.0
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
- name: Verify Redis Connection
run: redis-cli ping
- name: Verify Postgres Connection
run: pg_isready -h localhost -p 5432
- name: Run database migrations
run: ./scripts/run-migrations.sh
env:
PGPASSWORD: postgres
DB_HOST: localhost
DB_PORT: 5432
DB_USER: postgres
DB_NAME: waypoint
- name: Build
run: cargo build
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/waypoint
- name: Make build
run: make build
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/waypoint
- name: Run tests
run: cargo test
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/waypoint
REDIS_URL: redis://localhost:6379
- name: Run tests without database connection
run: cargo test --no-default-features