Fix location races, run database tests in CI, add make check
Location: a leave decided its destination before taking the device lock, so a "leave home" racing an "arrive gym" could undo the arrival. The decision (now ingest.Destination) runs inside MoveTo under the lock. Transition external IDs were device|label|time, which collided (500) when out-of-order events were clamped to the same start; they now name the interval being closed. hypr-agent: a control command arriving during shutdown no longer blocks its goroutine forever. Tests: internal/testdb gives each database test its own throwaway database, so they run in parallel and no longer truncate the dev data. New store tests cover both location bugs. CI starts a Postgres container so these tests actually run, and adds gofmt, staticcheck (pinned as a go tool) and -race. `make check` runs the same locally. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
COMPOSE := docker compose -f deploy/docker-compose.yml
|
||||
DEV_DB := postgres://tracker:tracker@localhost:5432/tracker?sslmode=disable
|
||||
|
||||
.PHONY: web web-dev build test test-integration run up down docker migrate install-agent
|
||||
.PHONY: web web-dev build check lint test test-integration run up down docker migrate install-agent
|
||||
|
||||
# Builds the Vue app into internal/web/dist/app, which the binary embeds.
|
||||
web:
|
||||
@@ -14,12 +14,21 @@ web-dev:
|
||||
build: web
|
||||
go build -o bin/ ./cmd/...
|
||||
|
||||
# Everything CI checks. Database tests run if the compose Postgres is up
|
||||
# (`make up`); each gets its own throwaway database, so your data is safe.
|
||||
check: lint test-integration
|
||||
cd web && { [ -d node_modules ] || npm ci; } && npm run typecheck
|
||||
|
||||
lint:
|
||||
@test -z "$$(gofmt -l .)" || { echo "gofmt needed:"; gofmt -l .; exit 1; }
|
||||
go vet ./...
|
||||
go tool staticcheck ./...
|
||||
|
||||
test:
|
||||
go test ./...
|
||||
|
||||
# Runs the API tests against the compose Postgres (make up first).
|
||||
test-integration:
|
||||
TEST_DATABASE_URL='$(DEV_DB)' go test -count=1 ./...
|
||||
TEST_DATABASE_URL='$(DEV_DB)' go test -race -count=1 ./...
|
||||
|
||||
run: web
|
||||
AUTH_MODE=dev DEV_MODE=true DATABASE_URL='$(DEV_DB)' go run ./cmd/tracker serve
|
||||
|
||||
Reference in New Issue
Block a user