patagia-control/justfile

109 lines
2.4 KiB
Makefile
Raw Normal View History

2024-10-20 19:29:28 +02:00
set shell := ["/usr/bin/env", "bash", "-euo", "pipefail", "-c"]
[private]
default:
@just --choose
2024-11-25 20:37:41 +01:00
# Run controller
[group('controller')]
run-controller $RUST_LOG="debug,h2=info,hyper_util=info,tower=info":
cargo run --package patagia-controller -- --log-stderr
2024-11-23 19:57:17 +01:00
2024-11-25 20:37:41 +01:00
# Run controller local development
[group('controller')]
dev-controller: dev-controller-db-migrate
2024-11-25 20:37:41 +01:00
watchexec --clear --restart --stop-signal INT --debounce 300ms -- just run-controller
2024-11-23 19:57:17 +01:00
2024-12-14 22:47:40 +01:00
# 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
2024-10-20 19:29:28 +02:00
# Lint all source code
lint:
2024-11-23 19:57:17 +01:00
cargo clippy
2024-10-20 19:29:28 +02:00
# Format all source code
fmt:
2024-11-23 19:57:17 +01:00
nix fmt
2024-10-20 19:29:28 +02:00
# Update all dependencies
2024-11-23 19:57:17 +01:00
update: update-nix update-rust-deps
# Update rust dependencies
update-rust-deps:
cargo upgrade --recursive
cargo update --recursive
2024-10-20 19:29:28 +02:00
# Update nix flake packages
2024-11-23 19:57:17 +01:00
update-nix:
2024-10-20 19:29:28 +02:00
nix flake update
2024-11-23 19:57:17 +01:00
# Find unused dependencies with cargo machete
machete:
cargo machete
2024-12-11 21:12:24 +01:00
# Generate OpenAPI spec
open-api:
cargo xtask open-api
# Update OpenAPI spec
gen-open-api:
cargo xtask open-api > api.json
2024-12-11 21:12:24 +01:00
# Run all tests
2025-01-06 20:40:02 +01:00
check: check-nix
2024-12-11 21:12:24 +01:00
# check-nix
check-nix:
nix flake check
2025-01-06 20:40:02 +01:00
# Run PostgreSQL for development and testing
[group('controller')]
2025-01-06 20:40:02 +01:00
dev-postgres:
mkdir -p "${XDG_RUNTIME_DIR}/patagia-postgres"
2025-01-06 20:40:02 +01:00
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" \
2025-01-06 20:40:02 +01:00
docker.io/postgres:17
sleep 0.3
2025-01-06 20:40:02 +01:00
# Clean up PostgreSQL data
[group('controller')]
2025-01-06 20:40:02 +01:00
dev-postgres-clean:
podman rm -f patagia-postgres || true
podman volume rm patagia-postgres || true
# Connect to PostgreSQL with psql
[group('controller')]
2025-01-06 20:40:02 +01:00
dev-postgres-psql:
podman exec -it patagia-postgres psql -U patagia
[group('controller')]
[working-directory: 'controller']
dev-controller-db-migrate: dev-postgres
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