You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+34-3Lines changed: 34 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,21 +17,52 @@ Use Go 1.24+ and PostgreSQL.
17
17
18
18
```bash
19
19
go mod tidy
20
-
gotest ./...
20
+
make test-unit
21
21
go vet ./...
22
22
```
23
23
24
24
Dependencies are managed through normal Go module resolution. Review dependency changes in `go.mod` and `go.sum`; the repository does not commit a `vendor/` tree.
25
25
26
-
DB-backed integration tests skip when no Postgres connection is configured. To run them, provide libpq environment variables or `READINESS_TEST_DSN`. Tests create throwaway schemas and drop them during cleanup.
26
+
DB-backed integration tests are explicit. They skip unless `HEALTH_DB_TESTS=1` is set, even when `PGHOST` or other libpq variables are present in your shell. To run them, provide libpq environment variables or `READINESS_TEST_DSN`, then use:
27
+
28
+
```bash
29
+
HEALTH_DB_TESTS=1 make test-db-storage
30
+
HEALTH_DB_TESTS=1 make test-db-ui
31
+
HEALTH_DB_TESTS=1 make test-db-ui-fast
32
+
HEALTH_DB_TESTS=1 make test-db-energy
33
+
HEALTH_DB_TESTS=1 make test-db-energy-smoke
34
+
HEALTH_DB_TESTS=1 make test-db-readiness
35
+
HEALTH_DB_TESTS=1 make test-db
36
+
```
37
+
38
+
`test-db` is the routine DB contract aggregate: fast UI DB smoke, EnergyBank DB smoke, and targeted Readiness DB checks. It intentionally does not run the full UI package, full EnergyBank verdict-band suite, or full `./internal/storage` package. Use the full domain lanes when a change touches that area.
39
+
40
+
Lane commands:
41
+
42
+
```bash
43
+
make test-db # routine DB contract: ui-fast + energy-smoke + readiness
44
+
make test-db-ui-fast # representative UI/admin DB handler checks
45
+
make test-db-energy-smoke # one EnergyBank verdict-band DB contract check
46
+
make test-db-readiness # readiness schema/calibration DB checks
47
+
make test-db-ui # full internal/ui DB package sweep
48
+
make test-db-energy # full EnergyBank verdict-band DB group
49
+
make test-db-storage # full internal/storage DB package sweep
50
+
```
51
+
52
+
When `HEALTH_DB_TESTS=1` is set, missing or unreachable Postgres is a test failure, not a skip. Tests create throwaway schemas with test prefixes and drop them during cleanup.
53
+
Readiness monitoring and broad readiness writer families are intentionally outside the routine `test-db-readiness` lane until their fixtures are narrowed or runtime is measured separately. Full UI, full Energy, and full Storage lanes are manual/domain sweeps, not the normal edit-loop.
27
54
28
55
See `docs/TEST_COVERAGE.md` for the current focused coverage roadmap and fixture rules.
29
56
30
57
### CI and race detector policy
31
58
32
59
The default required-looking CI job is `Build, Vet & Test`. Keep that job name stable unless repository branch protection is updated at the same time.
33
60
34
-
Default PR and push CI uses `CGO_ENABLED=0` for build, vet, and tests, matching the production binary. Race detector tests are available as a manual GitHub Actions run: start the `CI` workflow with `run_race=true`. Race-only dispatches do not publish Docker images, even when the image build inputs are left at their defaults. Use this before merging changes that touch tenant management, scheduler goroutines, async AI generation, recompute coordination, Telegram webhook dispatch, or notification loops.
61
+
Default PR and push CI uses `CGO_ENABLED=0` for build, vet, and unit tests, matching the production binary, and also runs the stable DB lanes against an isolated Postgres service container: routine `make test-db`, full UI DB, and full Energy DB. Full Storage DB is still manual because the current full storage package exceeds the 120s lane timeout in chronic-load writer tests.
62
+
63
+
Manual DB runs are available through the `CI` workflow: set `run_db_tests=true` and choose `stable`, `routine`, `ui`, `energy`, `readiness`, or `storage`.
64
+
65
+
Race detector tests are also manual: start the `CI` workflow with `run_race=true`. Race-only and DB-only dispatches do not publish Docker images, even when the image build inputs are left at their defaults. Use the race detector before merging changes that touch tenant management, scheduler goroutines, async AI generation, recompute coordination, Telegram webhook dispatch, or notification loops.
35
66
36
67
For local checks on a machine with a CGO toolchain:
Copy file name to clipboardExpand all lines: Makefile
+27-1Lines changed: 27 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
.PHONY: dev build backfill backfill-force energy-backfill energy-backfill-dry import docker-up docker-down test
1
+
.PHONY: dev build backfill backfill-force energy-backfill energy-backfill-dry import docker-up docker-down test test-unit test-db-storage test-db-ui test-db-ui-fast test-db-energy test-db-energy-smoke test-db-readiness test-db smoke-health-post
2
2
3
3
ADDR ?= :8080
4
4
@@ -40,7 +40,33 @@ docker-up:
40
40
docker-down:
41
41
docker compose down
42
42
43
+
test-unit:
44
+
HEALTH_DB_TESTS= CGO_ENABLED=0 go test ./...
45
+
46
+
test-db-storage:
47
+
HEALTH_DB_TESTS=1 go test ./internal/storage -count=1 -timeout=120s
48
+
49
+
test-db-ui:
50
+
HEALTH_DB_TESTS=1 go test ./internal/ui -count=1 -timeout=120s
51
+
52
+
test-db-ui-fast:
53
+
HEALTH_DB_TESTS=1 go test ./internal/ui -run "^(TestAdminCheckinCoverage_JSONShape|TestOnboardingWizard_RejectsSchemaAll|TestFragmentAdminReadinessMonitoring_Renders)$$" -count=1 -timeout=60s
54
+
55
+
test-db-energy:
56
+
HEALTH_DB_TESTS=1 go test ./internal/storage -run "TestComputeUserVerdictBands" -count=1 -timeout=90s
57
+
58
+
test-db-energy-smoke:
59
+
HEALTH_DB_TESTS=1 go test ./internal/storage -run "^TestComputeUserVerdictBands_UsesCompatibleFormulaWarmup$$" -count=1 -timeout=30s
60
+
61
+
test-db-readiness:
62
+
HEALTH_DB_TESTS=1 go test ./internal/storage -run '^(TestSaveNaiveBaseline_NilValueWithValidReasonPersists|TestVerifyReadinessRedesignSchema_DetectsReasonColumnDrift|TestRecomputeChipCalibrations_Integration_(RejectsCrossEpochLabels|PercentileP80|InsufficientData))$$' -count=1 -timeout=90s
Copy file name to clipboardExpand all lines: docs/TEST_COVERAGE.md
+16-3Lines changed: 16 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,11 +4,24 @@ This roadmap tracks high-value Health Dashboard test coverage without turning th
4
4
5
5
## Constraints
6
6
7
-
- Default CI must stay pure and fast under `go test ./...`.
7
+
- Default CI must stay pure and fast under `make test-unit` / `go test ./...`.
8
8
- Fixtures must be synthetic or anonymized. Do not commit personal health exports, screenshots, logs, or raw metric dumps.
9
-
- DB-backed tests should skip cleanly unless a Postgres connection is configured.
9
+
- DB-backed tests should skip cleanly unless `HEALTH_DB_TESTS=1` is set. When that flag is set, missing or unreachable Postgres is a failure.
10
10
- Coverage thresholds are intentionally deferred until the active product contracts have a useful baseline.
11
11
12
+
## Test Lanes
13
+
14
+
| Lane | Command | Contract |
15
+
|---|---|---|
16
+
| Unit/default |`make test-unit`| Fast pure suite. DB tests skip even if libpq env vars are present. |
17
+
| Routine DB |`HEALTH_DB_TESTS=1 make test-db`| Fast sequential DB contract aggregate: UI smoke, Energy smoke, and targeted Readiness DB checks. This is the normal DB edit-loop. |
18
+
| UI DB smoke |`HEALTH_DB_TESTS=1 make test-db-ui-fast`| Representative UI/admin DB handler checks. |
19
+
| Energy DB smoke |`HEALTH_DB_TESTS=1 make test-db-energy-smoke`| One EnergyBank verdict-band DB contract check. |
20
+
| Readiness DB |`HEALTH_DB_TESTS=1 make test-db-readiness`| Runs an explicit readiness storage regex covering baseline persistence/schema drift and chip calibration recompute. Monitoring and broad readiness-adjacent writer families stay out until measured or migrated. |
21
+
| UI DB full |`HEALTH_DB_TESTS=1 make test-db-ui`| Full `./internal/ui` DB package sweep. Manual/domain verification; currently around 41s on the remote Postgres path. |
22
+
| Energy DB full |`HEALTH_DB_TESTS=1 make test-db-energy`| Full EnergyBank verdict-band DB group: `go test ./internal/storage -run "TestComputeUserVerdictBands" -count=1 -timeout=90s`. Domain verification; currently around 22s after fixture narrowing and batched seed inserts. |
23
+
| Full Storage DB |`HEALTH_DB_TESTS=1 make test-db-storage`| Full `./internal/storage` DB package run. Manual/pre-merge only; not part of `make test-db`. |
24
+
12
25
## Current Coverage Map
13
26
14
27
| Area | Current state | Next useful coverage |
@@ -18,7 +31,7 @@ This roadmap tracks high-value Health Dashboard test coverage without turning th
18
31
| UI and admin APIs | Contract tests cover admin pages, auth/session behavior, webhook dispatch, dashboard sections, and tenant scope. | Pin response-shape changes before frontend code starts depending on them. |
19
32
| Storage writers | Readiness redesign, EnergyBank, sleep gates, freshness, calibration, and tenant helpers have focused tests, with DB-backed tests gated. | Prefer bug-driven storage contract tests over broad repository-level sweeps. |
20
33
| Notifications | Morning/evening report, freshness banners, smart retry, Telegram webhook, and proactive framework tests cover key behavior. | Add regression tests when notification timing or skip conditions change. |
21
-
| CI policy | Default CI runs build, vet, and pure tests; race detector is manual and documented. | Keep race detector separate from default PR checks unless the runtime cost becomes acceptable. |
34
+
| CI policy | Default CI runs build, vet, pure tests, routine DB, full UI DB, and full Energy DB against an isolated Postgres service. Full Storage DB and race detector remain manual. | Move full storage into default CI only after the chronic/acute writer families fit a bounded timeout. |
0 commit comments