Some checks failed
V2 CI/CD Pipeline / Pre-Flight Checks (push) Has been cancelled
V2 CI/CD Pipeline / Build & Dependencies (push) Has been cancelled
V2 CI/CD Pipeline / Code Quality & Linting (push) Has been cancelled
V2 CI/CD Pipeline / Unit Tests (100% Coverage Required) (push) Has been cancelled
V2 CI/CD Pipeline / Integration Tests (push) Has been cancelled
V2 CI/CD Pipeline / Performance Benchmarks (push) Has been cancelled
V2 CI/CD Pipeline / Decimal Precision Validation (push) Has been cancelled
V2 CI/CD Pipeline / Modularity Validation (push) Has been cancelled
V2 CI/CD Pipeline / Final Validation Summary (push) Has been cancelled
Created complete CI/CD infrastructure for V2 development: GitHub Actions Pipeline (.github/workflows/v2-ci.yml): - Pre-flight checks (branch naming, commit messages) - Build & dependency validation - Code quality with 40+ linters (golangci-lint) - Unit tests with MANDATORY 100% coverage enforcement - Integration tests with timeout management - Performance benchmarks (parser < 5ms, detection < 10ms, e2e < 50ms) - Decimal precision validation - Modularity validation (component independence) - Final validation summary with PR comments Code Quality (.golangci.yml): - 40+ enabled linters for comprehensive checks - Cyclomatic complexity limits (max 15) - Magic number detection - Security scanning (gosec) - Style checking with MEV/DEX terminology - Test file exclusions for appropriate linters Build Automation (Makefile): - build, test, test-coverage with 100% enforcement - lint, fmt, vet, security targets - deps-download, deps-verify, deps-tidy, deps-check - validate (full CI/CD locally) - bench (performance benchmarks) - check-modularity, check-circular - Color-coded output for better UX Git Optimization (.gitattributes): - LF normalization for cross-platform consistency - Binary file handling - Diff settings for Go files - Merge strategies - Export-ignore for archives Git Hooks (.git-hooks/): - pre-commit: format, tests, vet, secret detection, go.mod tidy - commit-msg: message format validation - README with installation instructions - install-git-hooks.sh script for easy setup Documentation (docs/planning/05_CI_CD_SETUP.md): - Complete pipeline architecture diagram - Local development workflow - GitHub Actions job descriptions - Performance optimizations (caching, parallel execution) - Failure handling and debugging - Branch protection rules - Deployment process - Best practices and troubleshooting Performance Targets: - Pipeline duration: < 15 minutes - Test coverage: 100% (enforced, non-negotiable) - Parser latency: < 5ms - Arbitrage detection: < 10ms - End-to-end: < 50ms 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
154 lines
3.3 KiB
Markdown
154 lines
3.3 KiB
Markdown
# Git Hooks for MEV Bot V2
|
|
|
|
This directory contains Git hooks to ensure code quality and consistency.
|
|
|
|
## Installation
|
|
|
|
Run these commands from the repository root:
|
|
|
|
```bash
|
|
# Make hooks executable
|
|
chmod +x .git-hooks/*
|
|
|
|
# Install pre-commit hook
|
|
ln -sf ../../.git-hooks/pre-commit .git/hooks/pre-commit
|
|
|
|
# Install commit-msg hook
|
|
ln -sf ../../.git-hooks/commit-msg .git/hooks/commit-msg
|
|
```
|
|
|
|
Or use the provided installation script:
|
|
|
|
```bash
|
|
./scripts/install-git-hooks.sh
|
|
```
|
|
|
|
## Available Hooks
|
|
|
|
### pre-commit
|
|
|
|
Runs before each commit and performs:
|
|
|
|
1. **Branch Name Validation** - Ensures correct naming convention
|
|
2. **Merge Conflict Detection** - Prevents committing conflict markers
|
|
3. **Secret Detection** - Scans for passwords, API keys, tokens
|
|
4. **Dependency Management** - Auto-tidies go.mod and go.sum
|
|
5. **Code Formatting** - Auto-formats Go code with gofmt
|
|
6. **Quick Tests** - Runs tests on changed packages
|
|
7. **Go Vet** - Runs static analysis
|
|
8. **File Size Check** - Warns about large files
|
|
|
|
### commit-msg
|
|
|
|
Validates commit message format:
|
|
|
|
**Required Format:**
|
|
```
|
|
type(scope): description
|
|
|
|
Optional body explaining the change
|
|
|
|
🤖 Generated with [Claude Code](https://claude.com/claude-code)
|
|
Co-Authored-By: Claude <noreply@anthropic.com>
|
|
```
|
|
|
|
**Valid Types:**
|
|
- `feat` - New feature
|
|
- `fix` - Bug fix
|
|
- `perf` - Performance improvement
|
|
- `refactor` - Code refactoring
|
|
- `test` - Tests
|
|
- `docs` - Documentation
|
|
- `build` - Build system
|
|
- `ci` - CI/CD
|
|
|
|
**Example:**
|
|
```
|
|
feat(parsers): add UniswapV2 parser with event validation
|
|
|
|
- Implements ParseLog() for Swap events
|
|
- Adds token extraction from pool cache
|
|
- Includes comprehensive validation rules
|
|
- Achieves 100% test coverage
|
|
|
|
🤖 Generated with [Claude Code](https://claude.com/claude-code)
|
|
Co-Authored-By: Claude <noreply@anthropic.com>
|
|
```
|
|
|
|
## Bypassing Hooks (Emergency Only)
|
|
|
|
If you absolutely must bypass hooks:
|
|
|
|
```bash
|
|
git commit --no-verify -m "emergency fix"
|
|
```
|
|
|
|
**⚠️ Warning:** Only use in emergencies. CI/CD will still enforce all checks.
|
|
|
|
## Troubleshooting
|
|
|
|
### Hook not executing
|
|
|
|
1. Check if hook is executable:
|
|
```bash
|
|
ls -l .git/hooks/pre-commit
|
|
```
|
|
|
|
2. If not, make it executable:
|
|
```bash
|
|
chmod +x .git/hooks/pre-commit
|
|
```
|
|
|
|
### Hook failing unexpectedly
|
|
|
|
1. Run the hook manually to see errors:
|
|
```bash
|
|
.git/hooks/pre-commit
|
|
```
|
|
|
|
2. Check that all required tools are installed:
|
|
```bash
|
|
which gofmt
|
|
which go
|
|
```
|
|
|
|
### Disabling hooks temporarily
|
|
|
|
```bash
|
|
# Disable all hooks
|
|
git config core.hooksPath /dev/null
|
|
|
|
# Re-enable hooks
|
|
git config --unset core.hooksPath
|
|
```
|
|
|
|
## Best Practices
|
|
|
|
1. **Never bypass hooks** unless absolutely necessary
|
|
2. **Fix issues** instead of bypassing
|
|
3. **Keep hooks fast** - they run on every commit
|
|
4. **Test hooks locally** before committing to shared repository
|
|
5. **Document any new hooks** added to this directory
|
|
|
|
## Performance
|
|
|
|
Hooks are designed to be fast:
|
|
|
|
- **Pre-commit**: Typically < 5 seconds
|
|
- **Commit-msg**: < 1 second
|
|
|
|
If hooks are slow, consider:
|
|
|
|
1. Only testing changed packages (already implemented)
|
|
2. Using `--short` flag for tests (already implemented)
|
|
3. Running full tests in CI/CD instead
|
|
|
|
## Maintenance
|
|
|
|
Review and update hooks periodically:
|
|
|
|
1. Add new checks as project evolves
|
|
2. Remove obsolete checks
|
|
3. Optimize performance
|
|
4. Keep documentation up to date
|