101 lines
3.2 KiB
Makefile
101 lines
3.2 KiB
Makefile
# Dev entry points. `just` with no args lists them.
|
|
|
|
# The local development database. Committed offline query data (.sqlx) means
|
|
# neither CI nor a plain `cargo build` needs this to exist.
|
|
database_url := env_var_or_default("DATABASE_URL", "sqlite://dev.db")
|
|
|
|
# The full per-push gate, same as CI. Run this before pushing.
|
|
ci: fmt-check lint deps test web-check
|
|
|
|
# Formatting, checked not applied.
|
|
fmt-check:
|
|
cargo fmt --all -- --check
|
|
|
|
# Format every Rust source.
|
|
fmt:
|
|
cargo fmt --all
|
|
|
|
# Clippy, warnings denied.
|
|
lint:
|
|
cargo clippy --all-targets -- -D warnings
|
|
|
|
# Unused workspace dependencies. Stable toolchain, unlike cargo-udeps.
|
|
deps:
|
|
cargo machete
|
|
|
|
# Unit and integration tests, excluding the e2e crate.
|
|
test:
|
|
cargo nextest run --workspace --exclude arr-e2e
|
|
|
|
# End-to-end tests. Needs a Transmission container (`just e2e-up`); not part
|
|
# of the push gate. Never point this at the production Transmission LXC.
|
|
e2e:
|
|
cargo nextest run -p arr-e2e
|
|
|
|
# Throwaway local Transmission for `just e2e`, mirroring the CI service.
|
|
e2e-up:
|
|
docker run --rm -d --name arr-e2e-transmission \
|
|
-e PUID=1000 -e PGID=1000 -p 9091:9091 \
|
|
linuxserver/transmission:latest
|
|
|
|
# Stop and discard the local Transmission container.
|
|
e2e-down:
|
|
docker stop arr-e2e-transmission
|
|
|
|
# Frontend lint and typecheck. No-op until the SPA exists (issue #6). Probes
|
|
# for package.json, not the directory: `just gen-client` writes into web/ and
|
|
# must not turn the gate on before there is a project to check.
|
|
web-check:
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
if [ ! -f web/package.json ]; then echo "web/ not present yet, skipping"; exit 0; fi
|
|
pnpm -C web install --frozen-lockfile
|
|
pnpm -C web exec biome ci .
|
|
pnpm -C web exec tsc -b --noEmit
|
|
pnpm -C web run check-tokens
|
|
|
|
# Build the SPA and the binary that embeds it.
|
|
build:
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
if [ -f web/package.json ]; then
|
|
pnpm -C web install --frozen-lockfile
|
|
pnpm -C web build
|
|
fi
|
|
cargo build --release
|
|
|
|
# Regenerate the TypeScript client from the OpenAPI document (DESIGN.md §9.1).
|
|
# The document is dumped from the binary, so nothing has to be running. Both
|
|
# outputs are generated: never edit them, and never hand-write the spec.
|
|
gen-client:
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
mkdir -p web/src/api
|
|
cargo run --quiet -p arr-daemon --bin arr -- --openapi > web/src/api/openapi.json
|
|
pnpm dlx openapi-typescript@7 web/src/api/openapi.json -o web/src/api/schema.d.ts
|
|
|
|
# Recreate the development database from an empty file.
|
|
db-reset:
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
export DATABASE_URL="{{database_url}}"
|
|
sqlx database drop -y
|
|
sqlx database create
|
|
sqlx migrate run --source crates/arr-db/migrations
|
|
|
|
# Refresh the committed offline query data. Run after changing any query.
|
|
db-prepare: db-reset
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
export DATABASE_URL="{{database_url}}"
|
|
cargo sqlx prepare --workspace -- --all-targets
|
|
|
|
# Advisory and licence scan. Scheduled, not part of the push gate.
|
|
audit:
|
|
cargo deny check
|
|
|
|
# Install the tools the gate needs.
|
|
setup:
|
|
cargo install cargo-nextest cargo-machete --locked
|
|
cargo install sqlx-cli --no-default-features --features sqlite,rustls --locked
|