## Pre-commit hook
- Add .husky/pre-commit at repo root: runs `cd frontend && npm run lint`
- Update prepare script in package.json to auto-configure git hooks path
on npm install (git -C .. config core.hooksPath .husky)
- Add lint step to CI unit-tests job so it catches issues before tests run
- Add generated dirs to .prettierignore (paraglide_bak*, test-results, .auth)
- Add src/lib/paraglide_bak* to .gitignore so ESLint can ignore them
## ESLint fixes (all pre-existing)
- Disable svelte/no-navigation-without-resolve: false positive in SvelteKit
(rule targets Svelte 5 standalone routing, not SvelteKit <a href>)
- Fix svelte/require-each-key: add (item.id)/(item) keys to all {#each} blocks
across 10 files — improves Svelte reconciliation performance
- Fix svelte/prefer-writable-derived in PersonTypeahead: $state+$effect → $derived
- Fix svelte/prefer-svelte-reactivity: URLSearchParams → SvelteURLSearchParams,
Map → SvelteMap (enables Svelte reactive tracking)
- Fix @typescript-eslint/no-unused-vars: remove dead imports/variables
## Prettier
- Run npm run format to bring all source files in line with .prettierrc
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
200 lines
7.4 KiB
YAML
200 lines
7.4 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
pull_request:
|
|
|
|
jobs:
|
|
# ─── Unit & Browser Component Tests ──────────────────────────────────────────
|
|
# Runs inside the official Playwright Docker image — Chromium and all system
|
|
# deps are pre-installed, so no install or cache step is needed for the browser.
|
|
unit-tests:
|
|
name: Unit & Component Tests
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: mcr.microsoft.com/playwright:v1.58.2-noble
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Cache node_modules
|
|
id: node-modules-cache
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: frontend/node_modules
|
|
key: node-modules-${{ hashFiles('frontend/package-lock.json') }}
|
|
|
|
- name: Install dependencies
|
|
if: steps.node-modules-cache.outputs.cache-hit != 'true'
|
|
run: npm ci
|
|
working-directory: frontend
|
|
|
|
- name: Lint
|
|
run: npm run lint
|
|
working-directory: frontend
|
|
|
|
- name: Run unit and component tests
|
|
run: npm test
|
|
working-directory: frontend
|
|
|
|
- name: Upload screenshots
|
|
if: always()
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: unit-test-screenshots
|
|
path: frontend/test-results/screenshots/
|
|
|
|
# ─── Backend Unit & Slice Tests ───────────────────────────────────────────────
|
|
# Pure Mockito + WebMvcTest — no DB or S3 needed.
|
|
backend-unit-tests:
|
|
name: Backend Unit Tests
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-java@v4
|
|
with:
|
|
java-version: '21'
|
|
distribution: temurin
|
|
|
|
- name: Cache Maven repository
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.m2/repository
|
|
key: maven-${{ hashFiles('backend/pom.xml') }}
|
|
restore-keys: maven-
|
|
|
|
- name: Run backend tests
|
|
run: |
|
|
chmod +x mvnw
|
|
./mvnw clean test
|
|
working-directory: backend
|
|
|
|
# ─── E2E Tests ────────────────────────────────────────────────────────────────
|
|
# Needs: PostgreSQL + MinIO (via docker-compose) + Spring Boot + SvelteKit dev server.
|
|
# Test data is seeded by DataInitializer on first startup (admin user + e2e profile data).
|
|
e2e-tests:
|
|
name: E2E Tests
|
|
runs-on: ubuntu-latest
|
|
|
|
# These env vars are picked up by docker-compose (overrides .env file)
|
|
env:
|
|
DOCKER_API_VERSION: "1.43"
|
|
POSTGRES_USER: archive_user
|
|
POSTGRES_PASSWORD: ci_db_password
|
|
POSTGRES_DB: family_archive_db
|
|
MINIO_ROOT_USER: minio_admin
|
|
MINIO_ROOT_PASSWORD: ci_minio_password
|
|
MINIO_DEFAULT_BUCKETS: archive-documents
|
|
PORT_DB: 5433
|
|
PORT_MINIO_API: 9100
|
|
PORT_MINIO_CONSOLE: 9101
|
|
PORT_BACKEND: 8080
|
|
PORT_FRONTEND: 3000
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
# ── Infrastructure ──────────────────────────────────────────────────────
|
|
- name: Cleanup leftover containers from previous runs
|
|
run: docker compose -f docker-compose.yml -f docker-compose.ci.yml down --volumes --remove-orphans || true
|
|
|
|
- name: Start DB and MinIO
|
|
run: docker compose -f docker-compose.yml -f docker-compose.ci.yml up -d db minio create-buckets
|
|
|
|
- name: Wait for DB to be ready
|
|
run: |
|
|
timeout 30 bash -c \
|
|
'until docker compose -f docker-compose.yml -f docker-compose.ci.yml exec -T db pg_isready -U archive_user; do sleep 2; done'
|
|
|
|
- name: Connect job container to compose network
|
|
run: docker network connect familienarchiv_archive-net $(cat /etc/hostname)
|
|
|
|
# ── Backend ─────────────────────────────────────────────────────────────
|
|
- uses: actions/setup-java@v4
|
|
with:
|
|
java-version: '21'
|
|
distribution: temurin
|
|
|
|
- name: Cache Maven repository
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.m2/repository
|
|
key: maven-${{ hashFiles('backend/pom.xml') }}
|
|
restore-keys: maven-
|
|
|
|
- name: Build backend (skip tests — covered by separate Java test job)
|
|
run: |
|
|
chmod +x mvnw
|
|
./mvnw clean package -DskipTests
|
|
working-directory: backend
|
|
|
|
- name: Start backend
|
|
run: |
|
|
java -jar backend/target/*.jar \
|
|
--spring.profiles.active=e2e \
|
|
--SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/family_archive_db \
|
|
--SPRING_DATASOURCE_USERNAME=archive_user \
|
|
--SPRING_DATASOURCE_PASSWORD=ci_db_password \
|
|
--S3_ENDPOINT=http://minio:9000 \
|
|
--S3_ACCESS_KEY=minio_admin \
|
|
--S3_SECRET_KEY=ci_minio_password \
|
|
--S3_BUCKET_NAME=archive-documents \
|
|
--S3_REGION=us-east-1 \
|
|
--APP_ADMIN_USERNAME=admin \
|
|
--APP_ADMIN_PASSWORD=admin123 \
|
|
&
|
|
echo "Waiting for backend..."
|
|
timeout 90 bash -c \
|
|
'until curl -sf http://localhost:8080/actuator/health | grep -q "UP"; do sleep 3; done'
|
|
echo "Backend is up."
|
|
|
|
# ── Frontend ─────────────────────────────────────────────────────────────
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
|
|
- name: Cache node_modules
|
|
id: node-modules-cache
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: frontend/node_modules
|
|
key: node-modules-${{ hashFiles('frontend/package-lock.json') }}
|
|
|
|
- name: Install frontend dependencies
|
|
if: steps.node-modules-cache.outputs.cache-hit != 'true'
|
|
run: npm ci
|
|
working-directory: frontend
|
|
|
|
- name: Cache Playwright browsers
|
|
id: playwright-cache
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.cache/ms-playwright
|
|
key: playwright-chromium-${{ hashFiles('frontend/package-lock.json') }}
|
|
|
|
- name: Install Playwright Chromium + system deps
|
|
if: steps.playwright-cache.outputs.cache-hit != 'true'
|
|
run: npx playwright install chromium --with-deps
|
|
working-directory: frontend
|
|
|
|
- name: Install Playwright system deps (browser binary already cached)
|
|
if: steps.playwright-cache.outputs.cache-hit == 'true'
|
|
run: npx playwright install-deps chromium
|
|
working-directory: frontend
|
|
|
|
# ── Tests ────────────────────────────────────────────────────────────────
|
|
- name: Run E2E tests
|
|
run: npm run test:e2e
|
|
working-directory: frontend
|
|
env:
|
|
E2E_BASE_URL: http://localhost:3000
|
|
E2E_USERNAME: admin
|
|
E2E_PASSWORD: admin123
|
|
|
|
- name: Upload E2E results
|
|
if: always()
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: e2e-results
|
|
path: frontend/test-results/e2e/
|