bilhej/build.gradle
Joakim Mörling 764a620689 Enforce coverage thresholds in pre-commit via gradlew check.
Wire frontendCoverage (Vitest 70%/60%/70%) into the check task chain
instead of plain unit tests so commits fail when line or branch coverage
drops. Document thresholds in AGENTS.md and improve pre-commit failure hints.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-01 12:14:13 +02:00

68 lines
2.4 KiB
Groovy

plugins {
id 'base'
}
tasks.register('frontendLint', Exec) {
description = 'Run ESLint in the frontend directory'
workingDir = file("${rootProject.projectDir}/frontend")
commandLine 'npm', 'run', 'lint'
}
tasks.register('frontendTest', Exec) {
description = 'Run Vitest in the frontend directory'
dependsOn frontendLint
workingDir = file("${rootProject.projectDir}/frontend")
commandLine 'npm', 'run', 'test'
}
tasks.register('frontendCoverage', Exec) {
description = 'Run Vitest with coverage thresholds (70% lines, 60% branches, 70% functions)'
dependsOn frontendLint
workingDir = file("${rootProject.projectDir}/frontend")
commandLine 'npm', 'run', 'test:coverage'
}
tasks.register('coverage') {
group = 'verification'
description = 'Run backend + frontend tests with coverage thresholds'
dependsOn(':backend:jacocoTestReport', 'frontendCoverage')
}
tasks.register('frontendE2E', Exec) {
group = 'verification'
description = 'Run Playwright E2E tests in Docker (same stack as Forgejo CI)'
dependsOn frontendCoverage
workingDir = rootProject.projectDir
environment 'POSTGRES_DB', 'bilhej'
environment 'POSTGRES_USER', 'bilhej'
environment 'POSTGRES_PASSWORD', 'test_pw_ci_123'
environment 'JWT_SECRET', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
environment 'STRIPE_SECRET_KEY', 'sk_test_fake'
environment 'STRIPE_WEBHOOK_SECRET', 'whsec_fake'
environment 'STRIPE_PRICE_ID', 'price_fake'
commandLine 'docker', 'compose', '-f', 'docker-compose.e2e.yml',
'up', '--build', '--abort-on-container-exit', '--exit-code-from', 'playwright'
}
tasks.named('check').configure {
description = 'Full verification: lint, unit tests with line/branch coverage thresholds, E2E'
dependsOn ':backend:check', frontendE2E
}
tasks.register('up', Exec) {
description = 'Start all services via Docker Compose'
workingDir = rootProject.projectDir
commandLine 'docker', 'compose', 'up', '-d'
}
tasks.register('down', Exec) {
description = 'Stop all Docker Compose services'
workingDir = rootProject.projectDir
commandLine 'docker', 'compose', 'down'
}
tasks.register('reset', Exec) {
description = 'Wipe database and restart all services'
workingDir = rootProject.projectDir
commandLine 'bash', '-c', 'docker compose down -v && docker compose up -d'
}