Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Rust CI

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

env:
CARGO_TERM_COLOR: always
SQLX_VERSION: 0.7.0
DATABASE_URL: "postgres://postgres:postgres@localhost:55432/task_master"

jobs:
test:
name: Test & Migrate
runs-on: ubuntu-latest
# Service Containers: The standard GitHub way to run sidecar DBs
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: task_master
ports:
- 55432:5432
# Health check to ensure DB is ready before steps run
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- uses: actions/checkout@v4

- name: Install Rust Toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy

- name: Cache Cargo dependencies
uses: Swatinem/rust-cache@v2

# Compiling sqlx-cli takes forever. We cache the binary.
- name: Cache sqlx-cli
uses: actions/cache@v3
id: cache-sqlx
with:
path: ~/.cargo/bin/sqlx
key: ${{ runner.os }}-sqlx-${{ env.SQLX_VERSION }}

- name: Install sqlx-cli
if: steps.cache-sqlx.outputs.cache-hit != 'true'
run: cargo install sqlx-cli --version ${{ env.SQLX_VERSION }} --no-default-features --features postgres,native-tls

- name: Run Migrations
run: sqlx migrate run

- name: Check Formatting
run: cargo fmt --all -- --check

# Run tests (Non-chain only, as requested)
- name: Run Tests
run: cargo test -- --skip chain_ --test-threads=1 --nocapture