Skip to content

Commit d359ea1

Browse files
committed
feat: add integration tests to pre-commit hook
Runs pnpm run test:integration when TypeScript files are staged. Skips gracefully with a warning if PostgreSQL is not running on port 5432, so developers without Docker running can still commit.
1 parent 5f65b08 commit d359ea1

3 files changed

Lines changed: 23 additions & 1 deletion

File tree

.pre-commit-config.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,17 @@ repos:
5959
exclude: '\.next/'
6060
pass_filenames: false
6161

62+
# Integration tests (requires Docker PostgreSQL on port 5432)
63+
- repo: local
64+
hooks:
65+
- id: integration-tests
66+
name: integration tests (requires Docker PostgreSQL)
67+
entry: ./scripts/run-integration-tests.sh
68+
language: script
69+
files: '\.(ts|tsx)$'
70+
exclude: '(node_modules|\.next|e2e)/'
71+
pass_filenames: false
72+
6273
# File cleanup (last, so it doesn't interfere with other tools)
6374
- repo: https://github.com/pre-commit/pre-commit-hooks
6475
rev: 'v5.0.0'

lib/element-compatibility.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Element parent-child compatibility rules.
33
*
4-
* Pure function module — no Prisma, importable by both client and server.
4+
* Pure function module — no Prisma dependency, importable by both client and server.
55
*
66
* Hierarchy:
77
* goal → strategy, property_claim

scripts/run-integration-tests.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
# Pre-commit hook: run integration tests if PostgreSQL is available.
3+
# Skips gracefully when Docker PostgreSQL is not running.
4+
5+
if ! pg_isready -h localhost -p 5432 -q 2>/dev/null; then
6+
echo "⚠ Skipping integration tests — PostgreSQL not running on port 5432"
7+
echo " Start it with: docker-compose -f docker-compose.local.yml up -d tea_postgres"
8+
exit 0
9+
fi
10+
11+
pnpm run test:integration

0 commit comments

Comments
 (0)