The first public release of Fabled Minstrel #158

Merged
bvandeusen merged 256 commits from dev into main 2026-12-03 21:41:58 -05:00
5 changed files with 41 additions and 18 deletions
Showing only changes of commit 7fe0c68899 - Show all commits
+17 -9
View File
@@ -286,16 +286,24 @@ jobs:
fi fi
# Apply embedded migrations to the fresh test DB, then run the # Apply embedded migrations to the fresh test DB, then run the
# full suite (no -short → integration tests execute). -p 1: # packages that hold database tests (no -short, so they execute).
# every integration package TRUNCATEs the one shared test DB; # The `go` lane already runs every unit test; packages with no
# concurrent package binaries → TRUNCATE deadlocks. Serialize # database test are left to it (ci/db-test-packages.sh).
# package execution (the documented local invocation too). #
# -timeout 20m: internal/api alone takes several minutes under # -p 1: every database package TRUNCATEs the one shared test DB,
# -race on an idle runner, and a dev and a main run sharing the # and concurrent package binaries deadlock on TRUNCATE. -p also
# runner can push it past go test's default 10m with nothing # bounds compiling, so the test binaries are built first with
# hung. # full parallelism (-run '^$' runs no test), and the serial pass
# reuses the build cache.
#
# -timeout 20m: internal/api alone takes minutes under -race on a
# busy runner, and a dev and a main run sharing the runner can
# push it past go test's default 10m with nothing hung.
MINSTREL_DATABASE_URL="$MINSTREL_TEST_DATABASE_URL" go run ./cmd/minstrel migrate MINSTREL_DATABASE_URL="$MINSTREL_TEST_DATABASE_URL" go run ./cmd/minstrel migrate
go test -p 1 -race -timeout 20m ./... PKGS=$(sh ci/db-test-packages.sh)
echo "database test packages: $(echo "$PKGS" | wc -l)"
go test -race -run '^$' $PKGS
go test -p 1 -race -timeout 20m $PKGS
web: web:
runs-on: go-ci runs-on: go-ci
+4 -3
View File
@@ -38,9 +38,10 @@ test-short:
test-integration: test-integration:
docker compose up -d postgres docker compose up -d postgres
-docker compose exec -T postgres createdb -U minstrel minstrel_test -docker compose exec -T postgres createdb -U minstrel minstrel_test
# -p 1: integration packages share one test DB and each TRUNCATEs it; # Only packages with database tests; test-short covers the rest.
# concurrent package binaries deadlock on TRUNCATE. Serialize packages. # -p 1: they share one test DB and each TRUNCATEs it; concurrent
MINSTREL_TEST_DATABASE_URL=postgres://minstrel:minstrel@localhost:5432/minstrel_test?sslmode=disable go test -p 1 -race ./... # package binaries deadlock on TRUNCATE. Serialize packages.
MINSTREL_TEST_DATABASE_URL=postgres://minstrel:minstrel@localhost:5432/minstrel_test?sslmode=disable go test -p 1 -race $$(sh ci/db-test-packages.sh)
lint: lint:
golangci-lint run ./... golangci-lint run ./...
+1 -1
View File
@@ -128,7 +128,7 @@ Minstrel is not affiliated with or endorsed by ListenBrainz, MusicBrainz or Subs
- **Backend:** `docker compose up` in this repo runs Postgres and Minstrel on `:4533`. - **Backend:** `docker compose up` in this repo runs Postgres and Minstrel on `:4533`.
- **Web:** `cd web && npm install && npm run dev` starts Vite on `:5173`. It proxies `/api/*` and `/rest/*` to `:4533`. - **Web:** `cd web && npm install && npm run dev` starts Vite on `:5173`. It proxies `/api/*` and `/rest/*` to `:4533`.
- **Tests:** `make test-short` runs the unit tests. `make test-integration` also runs the database tests, against a separate `minstrel_test` database so your dev data is never truncated. - **Tests:** `make test-short` runs the unit tests. `make test-integration` runs the database tests, against a separate `minstrel_test` database so your dev data is never truncated.
- **Image:** `docker build -t minstrel .` builds the web app and embeds it in the server binary. - **Image:** `docker build -t minstrel .` builds the web app and embeds it in the server binary.
- **Branches:** work lands on `dev`; `main` changes through pull requests from `dev`. - **Branches:** work lands on `dev`; `main` changes through pull requests from `dev`.
+19
View File
@@ -0,0 +1,19 @@
#!/bin/sh
#
# Prints the Go packages that hold database tests, one import path per line.
#
# A database test gets its Postgres from MINSTREL_TEST_DATABASE_URL, either
# through internal/dbtest or by reading the variable itself. A package whose
# tests mention neither cannot reach the database, so its tests are all unit
# tests: the `go` lane already runs them, and the `integration` lane skips the
# package instead of compiling and running it a second time, serially.
#
# Usage: go test -p 1 -race $(sh ci/db-test-packages.sh)
set -eu
go list -f '{{if or .TestGoFiles .XTestGoFiles}}{{.ImportPath}} {{.Dir}}{{end}}' ./... |
while read -r pkg dir; do
if grep -qs -e 'dbtest\.' -e 'MINSTREL_TEST_DATABASE_URL' "$dir"/*_test.go; then
echo "$pkg"
fi
done
-5
View File
@@ -11,11 +11,6 @@
// 2. Always create test user rows with a username that begins with // 2. Always create test user rows with a username that begins with
// TestUserPrefix; otherwise those rows survive across runs and // TestUserPrefix; otherwise those rows survive across runs and
// leak into other tests. // leak into other tests.
//
// One test legitimately needs to wipe the entire users table:
// internal/auth/bootstrap_test.go, which exercises first-time admin
// bootstrap. That file does its own TRUNCATE and does not use this
// helper.
package dbtest package dbtest
import ( import (