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:
@@ -181,15 +181,24 @@ To track time outside: `tracker goal add --kind place --label away --op '>=' --t
|
||||
## Development
|
||||
|
||||
```sh
|
||||
make test # unit tests
|
||||
make up && make test-integration # also runs the API tests against the compose Postgres (truncates its tables!)
|
||||
make check # everything CI runs: gofmt, vet, staticcheck, all tests (-race), web typecheck. Needs `make up`
|
||||
make test # unit tests only; database tests skip themselves
|
||||
make run # build the app, then run the server locally against the compose Postgres
|
||||
make web-dev # with `make run` going: Vite on :5173 with hot reload, proxying /api to :8080
|
||||
```
|
||||
|
||||
The dashboard is a Vue 3 + Vite app in `web/`. `make web` (and `make build`, `make run`, the Docker build) builds it into `internal/web/dist/app`, which the binary embeds. That directory isn't committed, so a plain `go build` serves a "not built" page at `/` but everything else works, and `go test` needs no Node.
|
||||
|
||||
Layout: `cmd/tracker` (server and admin CLI), `cmd/hypr-agent`, `internal/{api,auth,ingest,store,summary,migrations,config,web}` (`internal/web/tracker.user.js` is the browser collector), `web/` (dashboard app), `internal/agent/hypr`, `deploy/`.
|
||||
Database tests call `testdb.New(t)`, which creates a fresh, migrated database for that test on the server in `TEST_DATABASE_URL` and drops it afterwards. Tests never touch your data and can run in parallel. CI starts a throwaway Postgres for them.
|
||||
|
||||
To add a collector that uploads intervals:
|
||||
|
||||
1. Add a `Spec` (source and accepted kinds) in `internal/ingest/ingest.go`.
|
||||
2. Route `POST /<name>/events` to it in `internal/api/api.go`.
|
||||
3. Add it to the API table above, and to the kind picker and a `<Collector>` section in `web/src/views/Setup.vue`.
|
||||
4. If the kind needs a friendlier name or a fixed timeline lane, add it to `KINDS` in `web/src/api.ts` and `ORDER` in `web/src/components/DayTimeline.vue`.
|
||||
|
||||
Layout: `cmd/tracker` (server and admin CLI), `cmd/hypr-agent`, `internal/{api,auth,ingest,store,summary,migrations,config,web,testdb}` (`internal/web/tracker.user.js` is the browser collector), `web/` (dashboard app), `internal/agent/hypr`, `deploy/`.
|
||||
|
||||
## Roadmap
|
||||
|
||||
|
||||
Reference in New Issue
Block a user