This document describes the local CI/CD validation system designed to catch issues before they reach the CI/CD pipeline.
The validation system addresses the common problem where code works locally but fails in CI/CD due to:
- Different build environments (cached vs clean)
- Missing type imports masked by IDE type resolution
- ESLint caching hiding linting issues
- Different TypeScript configurations
- Incremental vs clean builds
# Complete validation (recommended before pushing)
npm run validate
# Or run directly
./scripts/validate-ci-local.sh# Install git hooks for automatic validation
npm run setup:hooks# Strict mode (zero warnings, matches CI exactly)
npm run validate:strict
# Fast mode (skip tests, for quick checks)
npm run validate:fast
# Validate specific package only
npm run validate:package agents
# With custom options
./scripts/validate-ci-local.sh --help- Clean Build Artifacts: Removes all
dist/,*.tsbuildinfo, caches - Fresh Dependencies: Simulates
npm cilike CI/CD - Clean ESLint Cache: Prevents cached lint results
- Clean Test Coverage: Ensures fresh test runs
- TypeScript Compilation: Strict mode without
skipLibCheck - ESLint: Configurable warning limits (default: 0 for strict mode)
- Import Validation: Catches missing type imports
- Build Dependencies: Ensures proper package build order
- Unit Tests: All package test suites
- Integration Tests: Cross-package functionality
- Type Checking: Validates TypeScript definitions
- TypeScript Config: Checks for CI/CD compatibility
- Package Versions: Validates dependency consistency
- Git Setup: Ensures proper git configuration
./scripts/validate-ci-local.sh [OPTIONS]
OPTIONS:
-h, --help Show help message
-v, --verbose Enable verbose output
-w, --max-warnings NUM Maximum ESLint warnings (default: 0)
-s, --skip-tests Skip running tests
-b, --skip-build Skip building packages
-p, --package FILTER Only validate packages matching FILTER
--no-clean Skip cleaning build artifacts
--no-deps Skip dependency installation# Set via environment variables
MAX_WARNINGS=5 npm run validate
SKIP_TESTS=true npm run validate
PACKAGE_FILTER=agents npm run validate
VERBOSE=true npm run validate# Quick validation of agents package only
./scripts/validate-ci-local.sh --package agents --skip-tests
# Allow 5 warnings, useful during development
./scripts/validate-ci-local.sh --max-warnings 5
# Verbose output for debugging
./scripts/validate-ci-local.sh --verbose
# Skip time-consuming steps
./scripts/validate-ci-local.sh --skip-tests --no-cleannpm run setup:hooksThis creates two git hooks:
- Trigger: Before each commit
- Validation Level: Moderate (allows 5 warnings)
- Purpose: Catch obvious issues early
- Bypass:
git commit --no-verify
- Trigger: Before pushing to remote
- Validation Level: Strict (0 warnings)
- Purpose: Ensure CI/CD compatibility
- Bypass:
git push --no-verify
# Check if hooks are installed
ls -la .git/hooks/
# Remove hooks
rm .git/hooks/pre-commit .git/hooks/pre-push
# Reinstall hooks
npm run setup:hooks- Command:
npm run validate - Warnings: Allows some warnings
- Speed: Balanced
- Use Case: Regular development validation
- Command:
npm run validate:fast - Warnings: Allows warnings
- Speed: Fast (skips tests)
- Use Case: Quick syntax/lint checks
- Command:
npm run validate:strict - Warnings: Zero warnings allowed
- Speed: Complete validation
- Use Case: Pre-push, matches CI/CD exactly
# Manual cleanup
find . -name "dist" -type d -not -path "./node_modules/*" -exec rm -rf {} +
find . -name "*.tsbuildinfo" -not -path "./node_modules/*" -delete# Run with clean build
./scripts/validate-ci-local.sh --no-cache# Clear ESLint cache
find . -name ".eslintcache" -delete
npm run validate:strict# Clean test environment
rm -rf coverage jest.cache
npm run validate# Skip tests for faster feedback
npm run validate:fast
# Validate specific package
npm run validate:package core
# Skip dependency installation
./scripts/validate-ci-local.sh --no-deps# Increase Node.js memory
NODE_OPTIONS="--max-old-space-size=4096" npm run validateAdd to .vscode/tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "Validate CI Local",
"type": "shell",
"command": "./scripts/validate-ci-local.sh",
"group": "build",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared"
},
"problemMatcher": []
}
]
}- Go to Run/Debug Configurations
- Add Shell Script configuration
- Set script path to
./scripts/validate-ci-local.sh - Set working directory to project root
- Run validation before committing:
npm run validate - Use fast mode during development:
npm run validate:fast - Run strict mode before pushing:
npm run validate:strict - Install git hooks:
npm run setup:hooks
- Mirror validation steps in CI/CD configuration
- Use same Node.js version as specified in
.nvmrc - Use same npm commands as validation script
- Match ESLint configuration exactly
- Document any validation bypasses
- Keep validation scripts updated
- Review validation failures in team meetings
- Share validation patterns across projects
- Test changes with various scenarios
- Update documentation when adding features
- Ensure backward compatibility
- Coordinate with CI/CD updates
# Check validation script health
./scripts/validate-ci-local.sh --verbose
# Verify git hooks are working
git commit --dry-run
# Test different validation modes
npm run validate:fast
npm run validate:strictWhen contributing to the validation system:
- Test thoroughly with different project states
- Add appropriate error handling
- Update documentation for new features
- Ensure cross-platform compatibility (macOS, Linux, Windows with WSL)
- Follow existing code style in scripts
If you encounter issues with the validation system:
- Check troubleshooting section above
- Run with verbose flag:
--verbose - Check git hooks:
ls -la .git/hooks/ - Verify file permissions:
ls -la scripts/ - Review recent changes to validation scripts
The validation system is working well when:
- ✅ CI/CD builds pass consistently
- ✅ Fewer "works on my machine" issues
- ✅ Developers catch issues before pushing
- ✅ Reduced CI/CD pipeline failures
- ✅ Faster development iteration cycles