Files
MusicServer/justfile
T
Sansan 973ebf224b
CI / integration (push) Successful in 49s
CI / docker (push) Successful in 1m0s
CI / test (push) Successful in 1m6s
CI / publish (push) Skipped
Generate the OpenAPI spec with Huma instead of swag
The spec is now built from the same calls that register the routes, so it
can't drift from the router like the swag comments did (all /api/v1
routes were missing).

- /api/v1 endpoints are typed Huma operations; the spec is OpenAPI 3.1 at
  /openapi.json (3.0 at /openapi-3.0.json, YAML too), docs at /docs.
  /openapi and /swagger/* redirect there
- Bearer token security is declared per operation; token creation and
  the new GET /api/v1/health are public
- Legacy routes use the same handlers, are hidden from the spec and keep
  the Deprecation header
- /sync/reset is hidden (debug only); the /sync/new, /sync/quick and
  /sync/new/full aliases are removed (use /sync and /sync/full)
- Invalid parameters return 422 (validation); every error is
  {"error": "..."}; empty lists are [] instead of null
- /sync/progress is documented as progress or result (oneOf)
- Tests validate the spec and check real responses of every documented
  operation against it (kin-openapi)
- Removed swag annotations, cmd/docs, echo-swagger and the swag tool
2026-10-06 16:31:06 +02:00

61 lines
1.4 KiB
Makefile

set dotenv-load
# Build and run the unit tests
all: build test
# Generate templ components (version pinned in go.mod)
templ-build:
@echo "Building templ..."
@go tool templ generate
sqlc-generate:
@echo "Generating sqlc code..."
@sqlc generate
migrate-create name:
@migrate create -ext sql -dir internal/db/migrations -seq {{name}}
build: sqlc-generate templ-build
@echo "Building..."
@go build -o main cmd/main.go
run: templ-build
@go run cmd/main.go
build-run: build
@./main
# Unit tests: no database or Docker needed
test:
@go test -race ./...
# Integration tests against PostgreSQL in Docker (testcontainers), using the active docker context.
# Pass a pattern to run a subset, e.g. `just test-integration TestSQLDumps`
test-integration pattern=".":
@DOCKER_HOST="${DOCKER_HOST:-$(docker context inspect --format '{{{{.Endpoints.docker.Host}}')}" \
go test -tags integration -race -timeout 15m -run '{{pattern}}' ./...
clean:
@echo "Cleaning..."
@rm -f main
docker-build:
@docker build -t music-server .
docker-run:
@docker compose up --build
docker-down:
@docker compose down
watch-templ:
@go tool templ generate --watch --proxy="http://localhost:8080" --cmd="go run ./cmd"
# Live reload
watch:
@if ! command -v air > /dev/null; then \
echo "air is not installed. Install it with: go install github.com/air-verse/air@latest"; \
exit 1; \
fi
@air