Migrated to native Rust and containerized Postgres.

This commit is contained in:
2026-09-21 22:10:11 +02:00
parent b1b81f60f9
commit 87c5e4bab1
5 changed files with 112 additions and 43 deletions
+105
View File
@@ -0,0 +1,105 @@
version: "3"
vars:
SERVER_DIR: "{{.TASKFILE_DIR}}/server"
COMPOSE_CMD: docker compose -f "{{.TASKFILE_DIR}}/compose.yaml"
DATABASE_URL: '{{.DATABASE_URL | default "postgres://expenses:expenses@127.0.0.1:5432/expenses"}}'
tasks:
default:
cmds:
- task --list
setup:
internal: true
cmds:
- test -f "{{.SERVER_DIR}}/.env" || cp "{{.SERVER_DIR}}/.env.example" "{{.SERVER_DIR}}/.env"
db-up:
desc: Start PostgreSQL
cmds:
- "{{.COMPOSE_CMD}} up -d --wait postgres"
db-down:
desc: Stop PostgreSQL and remove containers
cmds:
- "{{.COMPOSE_CMD}} down"
db-logs:
desc: Follow PostgreSQL logs
cmds:
- "{{.COMPOSE_CMD}} logs -f postgres"
db-shell:
desc: Open a PostgreSQL shell
cmds:
- "{{.COMPOSE_CMD}} exec postgres psql -U expenses -d expenses"
db-reset:
desc: Stop PostgreSQL and delete its data volume
cmds:
- echo "Resetting PostgreSQL data volume..."
- "{{.COMPOSE_CMD}} down -v"
run:
desc: Run the API
deps: [db-up]
cmds:
- cd "{{.SERVER_DIR}}" && DATABASE_URL="{{.DATABASE_URL}}" cargo run --locked
dev:
desc: Run the API with cargo-watch
deps: [setup, db-up]
cmds:
- cd "{{.SERVER_DIR}}" && DATABASE_URL="{{.DATABASE_URL}}" cargo watch -w src -w migrations -w Cargo.toml -w Cargo.lock -x 'run --locked'
migrate:
desc: Run database migrations
deps: [db-up]
cmds:
- cd "{{.SERVER_DIR}}" && DATABASE_URL="{{.DATABASE_URL}}" SQLX_OFFLINE=false cargo sqlx migrate run
sqlx-prepare:
desc: Prepare SQLx query metadata
deps: [migrate]
cmds:
- cd "{{.SERVER_DIR}}" && DATABASE_URL="{{.DATABASE_URL}}" SQLX_OFFLINE=false cargo sqlx prepare --all
sqlx-check:
desc: Check SQLx query metadata
deps: [migrate]
cmds:
- cd "{{.SERVER_DIR}}" && DATABASE_URL="{{.DATABASE_URL}}" SQLX_OFFLINE=false cargo sqlx prepare --check --all
fmt:
desc: Format Rust code
cmds:
- cd "{{.SERVER_DIR}}" && cargo fmt --all
fmt-check:
desc: Check Rust formatting
cmds:
- cd "{{.SERVER_DIR}}" && cargo fmt --all -- --check
check:
desc: Run cargo check
cmds:
- cd "{{.SERVER_DIR}}" && SQLX_OFFLINE=true cargo check --locked
clippy:
desc: Run Clippy with warnings denied
cmds:
- cd "{{.SERVER_DIR}}" && SQLX_OFFLINE=true cargo clippy --locked --all-targets -- -D warnings
test:
desc: Run Rust tests
cmds:
- cd "{{.SERVER_DIR}}" && SQLX_OFFLINE=true cargo test --locked
ci-offline:
desc: Run offline CI checks
deps: [fmt-check, check, clippy, test]
ci:
desc: Run the full CI checks
deps: [db-up, sqlx-check, ci-offline]