patagia-control/justfile
Daniel Lundin 6e38eaddad
Some checks failed
ci/woodpecker/pr/ci Pipeline failed
feat: Add user resource w/database as storage
2025-01-12 14:21:09 +01:00

107 lines
2.4 KiB
Makefile

set shell := ["/usr/bin/env", "bash", "-euo", "pipefail", "-c"]
[private]
default:
@just --choose
# Run controller
[group('controller')]
run-controller $RUST_LOG="debug,h2=info,hyper_util=info,tower=info":
cargo run --package patagia-controller -- --log-stderr
# Run controller local development
[group('controller')]
dev-controller:
watchexec --clear --restart --stop-signal INT --debounce 300ms -- just run-controller
# Run agent
run-agent $RUST_LOG="debug,h2=info,hyper_util=info,tower=info":
cargo run --package patagia-agent
# Run agent local development
dev-agent:
watchexec --clear --restart --stop-signal INT --debounce 300ms -- just run-agent
# Lint all source code
lint:
cargo clippy
# Format all source code
fmt:
nix fmt
# Update all dependencies
update: update-nix update-rust-deps
# Update rust dependencies
update-rust-deps:
cargo upgrade --recursive
cargo update --recursive
# Update nix flake packages
update-nix:
nix flake update
# Find unused dependencies with cargo machete
machete:
cargo machete
# Generate OpenAPI spec
open-api:
cargo xtask open-api
# Update OpenAPI spec
gen-open-api:
cargo xtask open-api > api.json
# Run all tests
check: check-nix
# check-nix
check-nix:
nix flake check
# Run PostgreSQL for development and testing
[group('controller')]
dev-postgres:
mkdir -p "${XDG_RUNTIME_DIR}/patagia-postgres"
podman volume exists patagia-postgres || podman volume create patagia-postgres
podman run \
--detach \
--replace \
--name patagia-postgres \
--env POSTGRES_DB=patagia \
--env POSTGRES_USER=patagia \
--env POSTGRES_PASSWORD=swordfish \
--volume patagia-postgres:/var/lib/postgresql/data \
--volume "${XDG_RUNTIME_DIR}/patagia-postgres:/var/run/postgresql" \
docker.io/postgres:17
# Clean up PostgreSQL data
[group('controller')]
dev-postgres-clean:
podman rm -f patagia-postgres || true
podman volume rm patagia-postgres || true
# Connect to PostgreSQL with psql
[group('controller')]
dev-postgres-psql:
podman exec -it patagia-postgres psql -U patagia
[group('controller')]
[working-directory: 'controller']
dev-controller-db-migrate:
cargo sqlx migrate run
[group('controller')]
[working-directory: 'controller']
dev-controller-db-reset:
cargo sqlx db reset -y
[group('controller')]
[working-directory: 'controller']
gen-controller-sqlx-prepare:
cargo sqlx prepare
gen: gen-open-api gen-controller-sqlx-prepare fmt