Skip to content
Merged
Show file tree
Hide file tree
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
89 changes: 89 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: CI

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

env:
CARGO_TERM_COLOR: always
DATABASE_URL: postgres://capsule:capsule_password@localhost:5432/capsule_dev
JWT_SECRET: dev-secret-change-me

jobs:
ci:
name: CI
runs-on: ubuntu-latest

services:
postgres:
image: postgres:16
env:
POSTGRES_USER: capsule
POSTGRES_PASSWORD: capsule_password
POSTGRES_DB: capsule_dev
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- name: Checkout code
uses: actions/checkout@v4

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

- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "ci-cache"

- name: Install tools
run: |
cargo install sqlx-cli --no-default-features --features native-tls,postgres
cargo install cargo-audit
cargo install cargo-deny

- name: Cache SQLx
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/sqlx
.sqlx
key: sqlx-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}

- name: Wait for PostgreSQL
run: |
until pg_isready -h localhost -p 5432 -U capsule; do
echo "Waiting for PostgreSQL..."
sleep 2
done

- name: Run database migrations
run: sqlx migrate run

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

- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings

- name: Run tests
run: cargo test --all-features

- name: SQLx prepare check
run: cargo sqlx prepare --check --workspace -- --all-features

# - name: Security audit
# run: cargo audit

# - name: License/dependency check
# run: cargo deny check
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/target
.envrc
/erd
/.sqlx
/erd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# build
FROM rust:1.85-bookworm AS build
FROM rust:1.89-bookworm AS build
WORKDIR /app
# cache deps
COPY Cargo.toml Cargo.lock ./
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# capsule

[![CI](https://github.com/charlieroth/capsule/actions/workflows/ci.yml/badge.svg)](https://github.com/charlieroth/capsule/actions/workflows/ci.yml)

A pragmatic "read later" service built in Rust to explore production-grade web service patterns:

- Authentication
Expand Down
Loading