This project includes automated git hooks to ensure code quality and consistency.
The git hooks system includes:
- pre-push: Runs comprehensive validations before pushing code
- commit-msg: Validates commit message format
- Copyright Management: Scripts to add and verify copyright headers
Run the setup script to install all git hooks:
./git-hooks/scripts/setup-git-hooks.shThis will:
- Install pre-push and commit-msg hooks
- Set proper permissions
- Test all dependencies
- Verify scripts are working
Runs the following validations before allowing a push:
- Copyright Header Check: Ensures all Go files have proper copyright headers
- Go Format Check: Runs
go fmt ./...to format code - Go Vet Check: Runs
go vet ./...to check for potential issues - Go Build Check: Runs
go build ./...to ensure code compiles - Go Test Suite: Runs
go test ./test/... -vto execute all tests
Validates commit messages follow the conventional commit format:
<type>(<scope>): <subject>
Valid types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changesrefactor: Code refactoringperf: Performance improvementstest: Adding or updating testschore: Maintenance taskscleanup: Code cleanuprevert: Reverting changestracking: Tracking changes
Examples:
- ✅
feat: add new API endpoint - ✅
fix(api): resolve authentication issue - ✅
docs: update README with setup instructions - ❌
invalid commit message - ❌
WIP: work in progress(ignored)
To add copyright headers to all Go files:
# Using Node.js script
node git-hooks/scripts/add-copyright.js
# Using shell script (if available)
./git-hooks/scripts/add-copyright.sh
# Add to specific directory
node git-hooks/scripts/add-copyright.js pkg/To verify all files have proper copyright headers:
node git-hooks/scripts/check-license.jsgit config core.hooksPath /dev/nullgit config --unset core.hooksPath# Test pre-push hook
node .git/hooks/pre-push
# Test commit-msg hook
echo "feat: test commit" | node .git/hooks/commit-msg- Node.js: Required for running the git hooks
- Go: Required for Go-specific validations
- Git: Required for git hook functionality
- "Cannot find module" errors: Make sure you're running from the project root
- Permission denied: Run
chmod +xon script files - Go vet errors: Fix formatting issues in Go code
- Commit message rejected: Use proper conventional commit format
To see detailed output from hooks, you can modify the scripts to include more verbose logging.
git-hooks/
├── pre-push # Pre-push validation hook
├── commit-msg # Commit message validation hook
├── scripts/
│ ├── add-copyright.js # Add copyright headers script
│ ├── check-license.js # Verify copyright headers script
│ ├── setup-git-hooks.sh # Installation script
│ ├── run-tests.sh # Test runner script
│ ├── start.sh # Quick start script
│ ├── utils/
│ │ ├── run.js # Task runner utility
│ │ └── CheckLicenseUtil.js # License checking utility
│ └── enums/
│ └── AnsiColorEnum.js # Color output utilities
To run the complete test suite:
# Using the test runner script
./git-hooks/scripts/run-tests.sh
# Using Go directly
go test ./test/... -v
# Run specific test categories
go test ./test/e2e/... -v # E2E tests only
go test ./test/unit/... -v # Unit tests only
# Run with additional options
go test ./test/... -cover # With coverage
go test ./test/... -race # With race detection
go test ./test/... -short # Skip long-running testsThe test suite includes:
- E2E Tests (
test/e2e/): End-to-end feature flag functionality tests - Unit Tests (
test/unit/): Individual component tests including:- Segmentation evaluators
- Operators (AND, OR, NOT, etc.)
- Data type validations
- Decision maker logic
- Client validation
Test data is organized in test/data/:
- Settings: Various campaign configurations
- Test Cases: Structured test scenarios
- Storage: Storage-related test utilities
When contributing to this project:
- Ensure your commit messages follow the conventional commit format
- All Go files should have proper copyright headers
- Code should pass all pre-push validations including tests
- Test your changes with the git hooks before pushing
- Run the test suite to ensure no regressions:
./git-hooks/scripts/run-tests.sh