Skip to content

Commit e3cb474

Browse files
Ci fixes
1 parent 428f994 commit e3cb474

6 files changed

Lines changed: 88 additions & 10 deletions

File tree

.github/workflows/ci.yml

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ jobs:
1515
ci:
1616
name: CI
1717
runs-on: ubuntu-latest
18-
# TIMEOUT EXCEPTION: Postgres startup, DB migration, embedding service model load, and 5 test projects with coverage require ~20 min.
19-
timeout-minutes: 30
18+
# TIMEOUT EXCEPTION: Postgres startup, DB migration, embedding service model load, 5 test projects with coverage,
19+
# 4 API processes, dashboard dev server, and Playwright e2e suite require ~35 min.
20+
timeout-minutes: 45
2021
env:
2122
DB_PASSWORD: changeme
2223
TEST_POSTGRES_CONNECTION: Host=localhost;Database=postgres;Username=postgres;Password=changeme
@@ -75,13 +76,68 @@ jobs:
7576
- name: Test
7677
run: make test
7778

79+
- name: Install Playwright browsers
80+
run: cd Dashboard/dashboard-ts && pnpm exec playwright install --with-deps chromium
81+
82+
- name: Start APIs for e2e tests
83+
run: |
84+
dotnet build --configuration Release --no-restore
85+
ConnectionStrings__Postgres="Host=localhost;Database=gatekeeper;Username=postgres;Password=changeme" \
86+
dotnet run --no-build --project Gatekeeper/Gatekeeper.Api/Gatekeeper.Api.csproj \
87+
--no-launch-profile --urls "http://localhost:5002" &
88+
ConnectionStrings__Postgres="Host=localhost;Database=clinical;Username=postgres;Password=changeme" \
89+
dotnet run --no-build --project Clinical/Clinical.Api/Clinical.Api.csproj \
90+
--no-launch-profile --urls "http://localhost:5080" &
91+
ConnectionStrings__Postgres="Host=localhost;Database=scheduling;Username=postgres;Password=changeme" \
92+
dotnet run --no-build --project Scheduling/Scheduling.Api/Scheduling.Api.csproj \
93+
--no-launch-profile --urls "http://localhost:5001" &
94+
ConnectionStrings__Postgres="Host=localhost;Database=icd10;Username=postgres;Password=changeme" \
95+
dotnet run --no-build --project ICD10/ICD10.Api/ICD10.Api.csproj \
96+
--no-launch-profile --urls "http://localhost:5090" &
97+
# Wait for all 4 APIs to be healthy
98+
for url in http://localhost:5002/health http://localhost:5080/health http://localhost:5001/health http://localhost:5090/health; do
99+
for i in $(seq 1 60); do
100+
if curl -sf "$url" > /dev/null; then
101+
echo "$url ready"
102+
break
103+
fi
104+
sleep 2
105+
done
106+
done
107+
108+
- name: Start dashboard dev server for e2e
109+
run: |
110+
cd Dashboard/dashboard-ts
111+
pnpm dev --host 0.0.0.0 &
112+
for i in $(seq 1 30); do
113+
if curl -sf http://localhost:5173 > /dev/null; then
114+
echo "Dashboard ready"
115+
exit 0
116+
fi
117+
sleep 2
118+
done
119+
echo "Dashboard failed to start"
120+
exit 1
121+
122+
- name: E2E tests (Playwright)
123+
run: make dashboard-ts-e2e
124+
78125
- name: Upload coverage
79126
uses: actions/upload-artifact@v4
80127
if: always()
81128
with:
82129
name: coverage-report
83130
path: |
84131
TestResults/**/coverage.*
132+
Dashboard/dashboard-ts/coverage/**
133+
retention-days: 7
134+
135+
- name: Upload Playwright report
136+
uses: actions/upload-artifact@v4
137+
if: always()
138+
with:
139+
name: playwright-report
140+
path: Dashboard/dashboard-ts/playwright-report/
85141
retention-days: 7
86142

87143
- name: Build

Dashboard/dashboard-ts/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
"lint": "eslint . --max-warnings=0",
1313
"format": "prettier --check .",
1414
"format:fix": "prettier --write .",
15-
"test": "vitest run",
15+
"test": "vitest run --coverage",
1616
"test:watch": "vitest",
17-
"test:coverage": "vitest run --coverage",
1817
"e2e": "playwright test",
1918
"e2e:headed": "playwright test --headed",
2019
"check": "pnpm typecheck && pnpm lint && pnpm format && pnpm test && pnpm build"

Dashboard/dashboard-ts/vitest.config.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,14 @@ export default defineConfig({
1313
coverage: {
1414
provider: 'v8',
1515
reporter: ['text', 'lcov', 'json-summary'],
16-
include: ['src/**/*.{ts,tsx}'],
17-
exclude: ['src/**/*.test.{ts,tsx}', 'src/test/**', 'src/main.tsx'],
16+
include: ['src/auth/**/*.{ts,tsx}', 'src/api/client.ts'],
17+
exclude: ['src/**/*.test.{ts,tsx}', 'src/test/**'],
18+
thresholds: {
19+
lines: 60,
20+
functions: 50,
21+
branches: 55,
22+
statements: 60,
23+
},
1824
},
1925
},
2026
});

Makefile

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Cross-platform: Linux, macOS, Windows (via GNU Make)
55
# =============================================================================
66

7-
.PHONY: build test lint fmt clean ci setup db-up db-down db-reset db-wait db-migrate start-local start-docker resume-docker deploy-dashboard dashboard-ts dashboard-ts-dev dashboard-ts-build dashboard-ts-lint dashboard-ts-test dashboard-ts-check nuke _reclaim-ports
7+
.PHONY: build test lint fmt clean ci setup db-up db-down db-reset db-wait db-migrate start-local start-docker resume-docker deploy-dashboard dashboard-ts dashboard-ts-dev dashboard-ts-build dashboard-ts-lint dashboard-ts-test dashboard-ts-e2e dashboard-ts-check nuke _reclaim-ports
88

99
# -----------------------------------------------------------------------------
1010
# OS Detection
@@ -103,6 +103,7 @@ test: db-migrate
103103
fi; \
104104
done
105105
@$(MAKE) dashboard-ts-test
106+
@$(MAKE) dashboard-ts-e2e
106107

107108
## lint: Run all linters/analyzers (read-only). Does NOT format.
108109
lint: db-migrate
@@ -208,6 +209,12 @@ db-migrate: db-up
208209
--output "$(PG_BASE_URL);Database=scheduling" --provider postgres
209210
dotnet DataProviderMigrate --schema ICD10/ICD10.Api/icd10-schema.yaml \
210211
--output "$(PG_BASE_URL);Database=icd10" --provider postgres
212+
@echo "==> Reassigning table ownership and granting privileges to service users..."
213+
@for db in gatekeeper clinical scheduling icd10; do \
214+
PGPASSWORD=$(DB_PASSWORD) psql -h $(DB_HOST) -p $(DB_PORT) -U postgres -d $$db -q \
215+
-c "REASSIGN OWNED BY postgres TO $$db;" \
216+
> /dev/null 2>&1 || true; \
217+
done
211218

212219
# =============================================================================
213220
# RUN THE STACK
@@ -253,10 +260,16 @@ dashboard-ts-build:
253260
dashboard-ts-lint:
254261
cd Dashboard/dashboard-ts && pnpm install --frozen-lockfile --silent && pnpm typecheck && pnpm lint && pnpm format
255262

256-
## dashboard-ts-test: Run unit tests for the new TypeScript dashboard
263+
## dashboard-ts-test: Run unit tests with coverage for the new TypeScript dashboard
257264
dashboard-ts-test:
258265
cd Dashboard/dashboard-ts && pnpm install --frozen-lockfile --silent && pnpm test
259266

267+
## dashboard-ts-e2e: Run Playwright e2e tests (requires all APIs + dashboard running on default ports)
268+
## Set E2E_CLINICAL_URL, E2E_SCHEDULING_URL, E2E_GATEKEEPER_URL, E2E_ICD10_URL, E2E_DASHBOARD_URL
269+
## to override the default localhost endpoints.
270+
dashboard-ts-e2e:
271+
cd Dashboard/dashboard-ts && pnpm install --frozen-lockfile --silent && pnpm e2e
272+
260273
## dashboard-ts-check: Typecheck + lint + test + build for the new TypeScript dashboard
261274
dashboard-ts-check:
262275
cd Dashboard/dashboard-ts && pnpm install --frozen-lockfile --silent && pnpm check

coverage-thresholds.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@
2727
"include": "[ICD10.Cli]*",
2828
"threshold": 67
2929
}
30-
}
30+
},
31+
"_dashboard_ts_note": "TS unit test thresholds enforced in vitest.config.ts (scoped to src/auth + src/api/client.ts). Page/component coverage comes from Playwright e2e."
3132
}

docker/init-db/init.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@ psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-E
1919
GRANT ALL PRIVILEGES ON DATABASE icd10 TO icd10;
2020
EOSQL
2121

22-
# Grant schema privileges
22+
# Grant schema privileges and default privileges so tables created by superuser are accessible
2323
for db in gatekeeper clinical scheduling icd10; do
2424
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$db" <<-EOSQL
2525
GRANT ALL ON SCHEMA public TO $db;
26+
-- Tables created by the postgres superuser (e.g. via db-migrate) are reassigned to $db
27+
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON TABLES TO $db;
28+
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON SEQUENCES TO $db;
2629
EOSQL
2730
done
2831

0 commit comments

Comments
 (0)