Skip to content

Commit 99df6cb

Browse files
jonphippsclaude
andcommitted
Complete automated testing infrastructure and fix lockfile
- Fix legacy TypeScript errors across test files and configs - Resolve ESLint warnings in production code - Fix StandardSiteFactory configuration isolation bug - Create comprehensive automated testing with Husky hooks - Add pre-commit/pre-push testing automation - Enhance GitHub Actions with unit test job - Create testing documentation (TESTING.md, build-regression-testing.md) - Complete README.md with full project documentation - Update lockfile to resolve CI deployment issues 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 7e73a63 commit 99df6cb

File tree

33 files changed

+1236
-313
lines changed

33 files changed

+1236
-313
lines changed

.github/workflows/test-site-builds.yml

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ name: Test Site Builds
33
on:
44
push:
55
branches: [main, dev]
6+
paths:
7+
- 'packages/**'
8+
- 'standards/**'
9+
- 'portal/**'
10+
- 'scripts/**'
11+
- '.github/workflows/**'
12+
- 'package.json'
13+
- 'pnpm-lock.yaml'
14+
- 'tsconfig.json'
615
pull_request:
716
branches: [main, dev]
817
workflow_dispatch:
@@ -22,9 +31,51 @@ on:
2231
- production
2332

2433
jobs:
34+
test-unit-and-types:
35+
name: Unit Tests & Type Safety
36+
runs-on: ubuntu-latest
37+
38+
steps:
39+
- name: Checkout code
40+
uses: actions/checkout@v4
41+
42+
- name: Setup pnpm
43+
uses: pnpm/action-setup@v2
44+
with:
45+
version: 8
46+
47+
- name: Setup Node.js
48+
uses: actions/setup-node@v4
49+
with:
50+
node-version: '20'
51+
cache: 'pnpm'
52+
53+
- name: Install dependencies
54+
run: pnpm install --frozen-lockfile
55+
56+
- name: Build theme package
57+
run: pnpm --filter @ifla/theme build
58+
59+
- name: TypeScript type checking
60+
run: pnpm typecheck
61+
62+
- name: ESLint code quality
63+
run: pnpm lint --quiet
64+
65+
- name: Unit and integration tests
66+
run: pnpm test --run
67+
68+
- name: Upload test results
69+
if: failure()
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: test-results
73+
path: coverage/
74+
2575
test-configurations:
2676
name: Test Site Configurations
2777
runs-on: ubuntu-latest
78+
needs: test-unit-and-types
2879

2980
steps:
3081
- name: Checkout code
@@ -143,14 +194,21 @@ jobs:
143194
summary:
144195
name: Test Summary
145196
runs-on: ubuntu-latest
146-
needs: [test-configurations, test-site-builds, test-url-validation]
197+
needs: [test-unit-and-types, test-configurations, test-site-builds, test-url-validation]
147198
if: always()
148199

149200
steps:
150201
- name: Check test results
151202
run: |
152203
echo "## Regression Test Summary"
153204
echo ""
205+
echo "### Unit Tests & Type Safety"
206+
if [ "${{ needs.test-unit-and-types.result }}" == "success" ]; then
207+
echo "✅ All unit tests and type checking passed"
208+
else
209+
echo "❌ Unit tests or type checking failed"
210+
fi
211+
echo ""
154212
echo "### Configuration Tests"
155213
if [ "${{ needs.test-configurations.result }}" == "success" ]; then
156214
echo "✅ All site configurations passed"
@@ -176,6 +234,7 @@ jobs:
176234
177235
- name: Set job status
178236
if: |
237+
needs.test-unit-and-types.result != 'success' ||
179238
needs.test-configurations.result != 'success' ||
180239
needs.test-site-builds.result != 'success' ||
181240
(needs.test-url-validation.result != 'success' && needs.test-url-validation.result != 'skipped')

.husky/pre-commit

100644100755
Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,39 @@
1-
pnpm exec lint-staged
1+
#!/usr/bin/env sh
2+
# Pre-commit hook for IFLA Standards project
3+
# Runs essential checks before allowing commits
4+
5+
echo "🔍 Running pre-commit checks..."
6+
7+
# 1. Run TypeScript type checking (fast, catches major issues)
8+
echo "📝 Checking TypeScript..."
9+
pnpm typecheck
10+
if [ $? -ne 0 ]; then
11+
echo "❌ TypeScript errors found. Please fix before committing."
12+
exit 1
13+
fi
14+
15+
# 2. Run ESLint (code quality)
16+
echo "🔧 Running ESLint..."
17+
pnpm lint --quiet
18+
if [ $? -ne 0 ]; then
19+
echo "❌ ESLint errors found. Please fix before committing."
20+
exit 1
21+
fi
22+
23+
# 3. Run unit tests (fast feedback on component changes)
24+
echo "🧪 Running unit tests..."
25+
pnpm test --run
26+
if [ $? -ne 0 ]; then
27+
echo "❌ Unit tests failed. Please fix before committing."
28+
exit 1
29+
fi
30+
31+
# 4. Quick configuration validation (for config changes)
32+
echo "⚙️ Validating site configurations..."
33+
node scripts/test-site-builds.js --site all --env localhost --skip-build
34+
if [ $? -ne 0 ]; then
35+
echo "❌ Site configuration validation failed."
36+
exit 1
37+
fi
38+
39+
echo "✅ All pre-commit checks passed!"

.husky/pre-push

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/env sh
2+
# Pre-push hook for IFLA Standards project
3+
# Runs comprehensive build regression tests before pushing
4+
5+
echo "🚀 Running pre-push regression tests..."
6+
7+
# Get the current branch name
8+
BRANCH=$(git branch --show-current)
9+
echo "📋 Testing branch: $BRANCH"
10+
11+
# Check if we're pushing to main or dev (stricter testing)
12+
if [ "$BRANCH" = "main" ] || [ "$BRANCH" = "dev" ]; then
13+
echo "🔒 Detected push to protected branch ($BRANCH) - running full test suite"
14+
15+
# 1. Full build regression test for critical sites
16+
echo "🏗️ Testing critical site builds..."
17+
node scripts/test-site-builds.js --site portal --env production
18+
if [ $? -ne 0 ]; then
19+
echo "❌ Portal build test failed."
20+
exit 1
21+
fi
22+
23+
node scripts/test-site-builds.js --site ISBDM --env production
24+
if [ $? -ne 0 ]; then
25+
echo "❌ ISBDM build test failed."
26+
exit 1
27+
fi
28+
29+
# 2. Portal end-to-end validation
30+
echo "🌐 Running portal E2E tests..."
31+
./scripts/test-portal-builds.sh
32+
if [ $? -ne 0 ]; then
33+
echo "❌ Portal E2E tests failed."
34+
exit 1
35+
fi
36+
37+
else
38+
echo "📝 Feature branch detected - running abbreviated tests"
39+
40+
# 1. Quick build test for all configurations
41+
echo "⚙️ Testing all site configurations..."
42+
node scripts/test-site-builds.js --site all --env localhost --skip-build
43+
if [ $? -ne 0 ]; then
44+
echo "❌ Site configuration tests failed."
45+
exit 1
46+
fi
47+
48+
# 2. Test one representative site build
49+
echo "🏗️ Testing representative site build..."
50+
node scripts/test-site-builds.js --site portal --env localhost
51+
if [ $? -ne 0 ]; then
52+
echo "❌ Representative build test failed."
53+
exit 1
54+
fi
55+
fi
56+
57+
echo "✅ All pre-push tests passed! Safe to push to $BRANCH."

0 commit comments

Comments
 (0)