Compare commits
9 Commits
feature/v2
...
master-dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8f9321348c | ||
|
|
2855c23c93 | ||
|
|
ac61a1dc5a | ||
|
|
687350b285 | ||
|
|
566f3f03ca | ||
|
|
204be46b23 | ||
|
|
32c06d8c21 | ||
|
|
10911ea469 | ||
|
|
21576f862a |
@@ -29,8 +29,10 @@ coverage.html
|
||||
ehthumbs.db
|
||||
Thumbs.db
|
||||
|
||||
# Log files
|
||||
# Log files and directories
|
||||
*.log
|
||||
logs/
|
||||
harness/
|
||||
|
||||
# Database files
|
||||
*.db
|
||||
13
.env
13
.env
@@ -1,13 +0,0 @@
|
||||
# MEV Bot Production Environment
|
||||
MEV_BOT_ENCRYPTION_KEY=bc10d845ff456ed03c03cda81835436435051c476836c647687a49999439cdc1
|
||||
CONTRACT_ARBITRAGE_EXECUTOR=0x6C2B1c6Eb0e5aB73d8C60944c74A62bfE629c418
|
||||
CONTRACT_FLASH_SWAPPER=0x7Cc97259cBe0D02Cd0b8A80c2E1f79C7265808b4
|
||||
CONTRACT_DATA_FETCHER=0xC6BD82306943c0F3104296a46113ca0863723cBD
|
||||
# CRITICAL FIX: Changed from WSS to HTTPS to avoid 403 Forbidden error
|
||||
# The Chainstack WSS endpoint returns "websocket: bad handshake (HTTP status 403 Forbidden)"
|
||||
# Using HTTPS RPC endpoint instead for stable connection
|
||||
ARBITRUM_RPC_ENDPOINT=https://arb1.arbitrum.io/rpc
|
||||
ARBITRUM_WS_ENDPOINT=
|
||||
METRICS_ENABLED=true
|
||||
METRICS_PORT=9090
|
||||
LOG_LEVEL=debug
|
||||
2
.env.docker
Normal file
2
.env.docker
Normal file
@@ -0,0 +1,2 @@
|
||||
ARBITRUM_RPC_ENDPOINT=https://arb1.arbitrum.io/rpc
|
||||
LOG_LEVEL=debug
|
||||
@@ -1,153 +0,0 @@
|
||||
# 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
|
||||
@@ -1,90 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Commit message hook for MEV Bot V2
|
||||
# Validates commit message format
|
||||
#
|
||||
# Install: ln -sf ../../.git-hooks/commit-msg .git/hooks/commit-msg
|
||||
#
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
COMMIT_MSG_FILE=$1
|
||||
COMMIT_MSG=$(cat "$COMMIT_MSG_FILE")
|
||||
|
||||
# Skip if this is a merge commit
|
||||
if git rev-parse -q --verify MERGE_HEAD > /dev/null; then
|
||||
echo -e "${GREEN}ℹ️ Merge commit detected, skipping validation${NC}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Skip if this is an amend
|
||||
if [ -n "$GIT_EDITOR" ]; then
|
||||
echo -e "${GREEN}ℹ️ Amend detected, skipping validation${NC}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}📝 Validating commit message...${NC}"
|
||||
|
||||
# Required format: type(scope): description
|
||||
# type: feat, fix, perf, refactor, test, docs, build, ci
|
||||
# scope: component name (parsers, cache, validation, etc.)
|
||||
|
||||
PATTERN="^(feat|fix|perf|refactor|test|docs|build|ci)\([a-z0-9-]+\): .{10,}"
|
||||
|
||||
if ! echo "$COMMIT_MSG" | grep -qE "$PATTERN"; then
|
||||
echo -e "${RED}❌ Invalid commit message format${NC}"
|
||||
echo ""
|
||||
echo -e "${YELLOW}Required format:${NC}"
|
||||
echo -e " type(scope): brief description"
|
||||
echo ""
|
||||
echo -e "${YELLOW}Valid types:${NC}"
|
||||
echo -e " feat - New feature"
|
||||
echo -e " fix - Bug fix"
|
||||
echo -e " perf - Performance improvement"
|
||||
echo -e " refactor - Code refactoring"
|
||||
echo -e " test - Adding or updating tests"
|
||||
echo -e " docs - Documentation updates"
|
||||
echo -e " build - Build system changes"
|
||||
echo -e " ci - CI/CD changes"
|
||||
echo ""
|
||||
echo -e "${YELLOW}Example:${NC}"
|
||||
echo -e " feat(parsers): add UniswapV2 parser with event validation"
|
||||
echo ""
|
||||
echo -e "${YELLOW}Your message:${NC}"
|
||||
echo -e " $COMMIT_MSG"
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for minimum description length
|
||||
DESCRIPTION=$(echo "$COMMIT_MSG" | head -n1 | sed 's/^[^:]*: //')
|
||||
if [ ${#DESCRIPTION} -lt 10 ]; then
|
||||
echo -e "${RED}❌ Commit description too short (minimum 10 characters)${NC}"
|
||||
echo -e "${YELLOW}Your description: $DESCRIPTION (${#DESCRIPTION} chars)${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for maximum line length (72 chars for first line)
|
||||
FIRST_LINE=$(echo "$COMMIT_MSG" | head -n1)
|
||||
if [ ${#FIRST_LINE} -gt 72 ]; then
|
||||
echo -e "${YELLOW}⚠️ Warning: First line exceeds 72 characters (${#FIRST_LINE} chars)${NC}"
|
||||
echo -e "${YELLOW} Consider shortening the description${NC}"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# Encourage including coverage info for test changes
|
||||
if echo "$COMMIT_MSG" | grep -q "^test"; then
|
||||
if ! echo "$COMMIT_MSG" | grep -qi "coverage"; then
|
||||
echo -e "${YELLOW}💡 Tip: Consider including coverage info in test commits${NC}"
|
||||
echo ""
|
||||
fi
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}✅ Commit message format valid${NC}"
|
||||
echo ""
|
||||
|
||||
exit 0
|
||||
@@ -1,202 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Pre-commit hook for MEV Bot V2
|
||||
# Ensures code quality and consistency before commits
|
||||
#
|
||||
# Install: ln -sf ../../.git-hooks/pre-commit .git/hooks/pre-commit
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
echo -e "${GREEN}🔍 Running pre-commit checks...${NC}"
|
||||
echo ""
|
||||
|
||||
# ==============================================================================
|
||||
# 1. CHECK BRANCH NAME
|
||||
# ==============================================================================
|
||||
BRANCH_NAME=$(git branch --show-current)
|
||||
|
||||
if [[ "$BRANCH_NAME" == "feature/v2-prep" ]] || [[ "$BRANCH_NAME" == "master" ]]; then
|
||||
echo -e "${YELLOW}⚠️ Warning: Committing to protected branch: $BRANCH_NAME${NC}"
|
||||
echo -e "${YELLOW} Consider creating a feature branch instead${NC}"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [[ "$BRANCH_NAME" =~ ^feature/v2/ ]]; then
|
||||
# Validate branch naming convention
|
||||
if [[ ! "$BRANCH_NAME" =~ ^feature/v2/[a-z0-9-]+/[A-Z0-9]+-[0-9]+-[a-z0-9-]+$ ]]; then
|
||||
echo -e "${YELLOW}⚠️ Branch name doesn't follow convention:${NC}"
|
||||
echo -e "${YELLOW} feature/v2/<component>/<TASK-ID>-<description>${NC}"
|
||||
echo ""
|
||||
fi
|
||||
fi
|
||||
|
||||
# ==============================================================================
|
||||
# 2. CHECK FOR MERGE CONFLICTS
|
||||
# ==============================================================================
|
||||
echo -e "${GREEN}📋 Checking for merge conflicts...${NC}"
|
||||
if git diff --cached --name-only | xargs grep -l "^<<<<<<< HEAD" 2>/dev/null; then
|
||||
echo -e "${RED}❌ Merge conflict markers found${NC}"
|
||||
echo -e "${RED} Resolve conflicts before committing${NC}"
|
||||
exit 1
|
||||
fi
|
||||
echo -e "${GREEN}✅ No merge conflicts${NC}"
|
||||
echo ""
|
||||
|
||||
# ==============================================================================
|
||||
# 3. CHECK FOR FORBIDDEN PATTERNS
|
||||
# ==============================================================================
|
||||
echo -e "${GREEN}🔒 Checking for secrets and forbidden patterns...${NC}"
|
||||
|
||||
# Check for common secret patterns
|
||||
if git diff --cached --name-only -z | xargs -0 grep -E "password|secret|api[_-]?key|private[_-]?key|token" --include="*.go" 2>/dev/null | grep -v "test" | grep -v "example"; then
|
||||
echo -e "${RED}❌ Potential secrets found${NC}"
|
||||
echo -e "${RED} Remove secrets before committing${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for debugging statements
|
||||
if git diff --cached --name-only -z | xargs -0 grep -E "fmt\.Println|log\.Println|panic\(|TODO.*URGENT|FIXME.*CRITICAL" --include="*.go" 2>/dev/null; then
|
||||
echo -e "${YELLOW}⚠️ Warning: Found debugging statements or urgent TODOs${NC}"
|
||||
echo -e "${YELLOW} Consider removing or creating issues for them${NC}"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}✅ No forbidden patterns found${NC}"
|
||||
echo ""
|
||||
|
||||
# ==============================================================================
|
||||
# 4. GO MOD TIDY CHECK
|
||||
# ==============================================================================
|
||||
if [ -f "go.mod" ]; then
|
||||
echo -e "${GREEN}📦 Checking if go.mod is tidy...${NC}"
|
||||
|
||||
# Save current go.mod and go.sum
|
||||
cp go.mod go.mod.backup
|
||||
cp go.sum go.sum.backup
|
||||
|
||||
# Run go mod tidy
|
||||
go mod tidy
|
||||
|
||||
# Check if anything changed
|
||||
if ! diff -q go.mod go.mod.backup > /dev/null 2>&1 || ! diff -q go.sum go.sum.backup > /dev/null 2>&1; then
|
||||
echo -e "${YELLOW}⚠️ go.mod or go.sum was not tidy${NC}"
|
||||
echo -e "${YELLOW} Auto-fixed and staged${NC}"
|
||||
git add go.mod go.sum
|
||||
fi
|
||||
|
||||
# Clean up backups
|
||||
rm -f go.mod.backup go.sum.backup
|
||||
|
||||
echo -e "${GREEN}✅ Dependencies are tidy${NC}"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# ==============================================================================
|
||||
# 5. CODE FORMATTING
|
||||
# ==============================================================================
|
||||
echo -e "${GREEN}🎨 Checking code formatting...${NC}"
|
||||
|
||||
# Get list of staged Go files
|
||||
STAGED_GO_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep "\.go$" || true)
|
||||
|
||||
if [ -n "$STAGED_GO_FILES" ]; then
|
||||
# Check formatting
|
||||
UNFORMATTED=$(gofmt -l $STAGED_GO_FILES 2>/dev/null || true)
|
||||
|
||||
if [ -n "$UNFORMATTED" ]; then
|
||||
echo -e "${YELLOW}⚠️ Auto-formatting files:${NC}"
|
||||
echo "$UNFORMATTED"
|
||||
|
||||
# Auto-format files
|
||||
echo "$UNFORMATTED" | xargs gofmt -w -s
|
||||
|
||||
# Re-stage formatted files
|
||||
echo "$UNFORMATTED" | xargs git add
|
||||
|
||||
echo -e "${GREEN}✅ Code formatted and re-staged${NC}"
|
||||
else
|
||||
echo -e "${GREEN}✅ All files properly formatted${NC}"
|
||||
fi
|
||||
else
|
||||
echo -e "${GREEN}ℹ️ No Go files to format${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# ==============================================================================
|
||||
# 6. RUN TESTS ON CHANGED FILES
|
||||
# ==============================================================================
|
||||
if [ -n "$STAGED_GO_FILES" ]; then
|
||||
echo -e "${GREEN}🧪 Running tests on changed packages...${NC}"
|
||||
|
||||
# Get unique package directories
|
||||
PACKAGES=$(echo "$STAGED_GO_FILES" | xargs -n1 dirname | sort -u | sed 's/$/\/.../')
|
||||
|
||||
# Run tests with timeout
|
||||
if ! go test -short -timeout=2m $PACKAGES 2>&1; then
|
||||
echo -e "${RED}❌ Tests failed${NC}"
|
||||
echo -e "${RED} Fix tests before committing${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}✅ Tests passed${NC}"
|
||||
else
|
||||
echo -e "${GREEN}ℹ️ No Go files changed, skipping tests${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# ==============================================================================
|
||||
# 7. RUN GO VET
|
||||
# ==============================================================================
|
||||
if [ -n "$STAGED_GO_FILES" ]; then
|
||||
echo -e "${GREEN}🔍 Running go vet...${NC}"
|
||||
|
||||
if ! go vet ./... 2>&1; then
|
||||
echo -e "${RED}❌ go vet found issues${NC}"
|
||||
echo -e "${RED} Fix issues before committing${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}✅ go vet passed${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# ==============================================================================
|
||||
# 8. CHECK FILE SIZES
|
||||
# ==============================================================================
|
||||
echo -e "${GREEN}📏 Checking file sizes...${NC}"
|
||||
|
||||
LARGE_FILES=$(git diff --cached --name-only | xargs -I {} sh -c 'if [ -f "{}" ]; then stat -f%z "{}" 2>/dev/null || stat -c%s "{}" 2>/dev/null; fi' | awk '$1 > 1048576 {print}' || true)
|
||||
|
||||
if [ -n "$LARGE_FILES" ]; then
|
||||
echo -e "${YELLOW}⚠️ Warning: Large files detected (>1MB)${NC}"
|
||||
echo -e "${YELLOW} Consider if these should be committed${NC}"
|
||||
git diff --cached --name-only | while read file; do
|
||||
size=$(stat -f%z "$file" 2>/dev/null || stat -c%s "$file" 2>/dev/null)
|
||||
if [ "$size" -gt 1048576 ]; then
|
||||
size_mb=$(echo "scale=2; $size / 1048576" | bc)
|
||||
echo -e "${YELLOW} $file: ${size_mb}MB${NC}"
|
||||
fi
|
||||
done
|
||||
echo ""
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}✅ File size check complete${NC}"
|
||||
echo ""
|
||||
|
||||
# ==============================================================================
|
||||
# 9. FINAL SUMMARY
|
||||
# ==============================================================================
|
||||
echo -e "${GREEN}╔══════════════════════════════════════╗${NC}"
|
||||
echo -e "${GREEN}║ ✅ PRE-COMMIT CHECKS PASSED ✅ ║${NC}"
|
||||
echo -e "${GREEN}╚══════════════════════════════════════╝${NC}"
|
||||
echo ""
|
||||
echo -e "${GREEN}Proceeding with commit...${NC}"
|
||||
|
||||
exit 0
|
||||
79
.gitattributes
vendored
79
.gitattributes
vendored
@@ -1,79 +0,0 @@
|
||||
# Git attributes for MEV Bot V2
|
||||
# Optimizes git operations and ensures consistent handling across platforms
|
||||
|
||||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
||||
|
||||
# Source code
|
||||
*.go text eol=lf
|
||||
*.mod text eol=lf
|
||||
*.sum text eol=lf
|
||||
*.sh text eol=lf
|
||||
*.bash text eol=lf
|
||||
|
||||
# Documentation
|
||||
*.md text eol=lf
|
||||
*.txt text eol=lf
|
||||
*.json text eol=lf
|
||||
*.yaml text eol=lf
|
||||
*.yml text eol=lf
|
||||
*.toml text eol=lf
|
||||
|
||||
# Configuration
|
||||
.gitignore text eol=lf
|
||||
.gitattributes text eol=lf
|
||||
.golangci.yml text eol=lf
|
||||
Makefile text eol=lf
|
||||
Dockerfile text eol=lf
|
||||
|
||||
# Scripts
|
||||
scripts/* text eol=lf
|
||||
|
||||
# Binary files
|
||||
*.png binary
|
||||
*.jpg binary
|
||||
*.jpeg binary
|
||||
*.gif binary
|
||||
*.ico binary
|
||||
*.mov binary
|
||||
*.mp4 binary
|
||||
*.mp3 binary
|
||||
*.gz binary
|
||||
*.zip binary
|
||||
*.tar binary
|
||||
*.pdf binary
|
||||
|
||||
# Go binaries
|
||||
*.exe binary
|
||||
*.so binary
|
||||
*.dylib binary
|
||||
|
||||
# Archives
|
||||
*.7z binary
|
||||
*.jar binary
|
||||
*.rar binary
|
||||
*.tar.gz binary
|
||||
*.tgz binary
|
||||
|
||||
# Exclude files from export-ignore (speeds up git archive)
|
||||
.gitattributes export-ignore
|
||||
.gitignore export-ignore
|
||||
.github export-ignore
|
||||
.golangci.yml export-ignore
|
||||
*.md export-ignore
|
||||
docs export-ignore
|
||||
scripts export-ignore
|
||||
|
||||
# Git LFS tracking for large files (if needed in future)
|
||||
# *.bin filter=lfs diff=lfs merge=lfs -text
|
||||
# *.dat filter=lfs diff=lfs merge=lfs -text
|
||||
|
||||
# Diff settings
|
||||
*.go diff=golang
|
||||
*.mod diff=golang
|
||||
*.sum diff=golang
|
||||
|
||||
# Merge strategies
|
||||
*.json merge=ours
|
||||
*.lock merge=ours
|
||||
go.sum merge=ours
|
||||
483
.github/workflows/v2-ci.yml
vendored
483
.github/workflows/v2-ci.yml
vendored
@@ -1,483 +0,0 @@
|
||||
name: V2 CI/CD Pipeline
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'feature/v2-**'
|
||||
- 'feature/v2/**'
|
||||
pull_request:
|
||||
branches:
|
||||
- 'feature/v2-prep'
|
||||
- 'master'
|
||||
paths:
|
||||
- 'pkg/**'
|
||||
- 'cmd/**'
|
||||
- 'internal/**'
|
||||
- 'go.mod'
|
||||
- 'go.sum'
|
||||
- '.github/workflows/**'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
run_benchmarks:
|
||||
description: 'Run performance benchmarks'
|
||||
required: false
|
||||
default: 'true'
|
||||
type: boolean
|
||||
|
||||
env:
|
||||
GO_VERSION: '1.25'
|
||||
MIN_COVERAGE: 100
|
||||
GOLANGCI_LINT_VERSION: 'v1.61.0'
|
||||
|
||||
jobs:
|
||||
# ==============================================================================
|
||||
# PRE-FLIGHT CHECKS
|
||||
# ==============================================================================
|
||||
pre_flight:
|
||||
name: Pre-Flight Checks
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Validate branch naming
|
||||
run: |
|
||||
BRANCH_NAME="${{ github.head_ref || github.ref_name }}"
|
||||
|
||||
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
|
||||
if [[ ! "$BRANCH_NAME" =~ ^feature/v2/[a-z0-9-]+/[A-Z0-9]+-[0-9]+-[a-z0-9-]+$ ]]; then
|
||||
echo "❌ Invalid branch name: $BRANCH_NAME"
|
||||
echo ""
|
||||
echo "Branch must follow: feature/v2/<component>/<TASK-ID>-<description>"
|
||||
echo ""
|
||||
echo "Examples:"
|
||||
echo " feature/v2/parsers/P2-002-uniswap-v2-base"
|
||||
echo " feature/v2/cache/P3-001-address-index"
|
||||
echo " feature/v2/validation/P4-001-validation-rules"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "✅ Branch naming validation passed"
|
||||
|
||||
- name: Check commit message format
|
||||
if: github.event_name == 'push'
|
||||
run: |
|
||||
# Get the last commit message
|
||||
COMMIT_MSG=$(git log -1 --pretty=%B)
|
||||
|
||||
# Check format: type(scope): description
|
||||
if [[ ! "$COMMIT_MSG" =~ ^(feat|fix|perf|refactor|test|docs|build|ci)\([a-z0-9-]+\):\ .+ ]]; then
|
||||
echo "❌ Invalid commit message format"
|
||||
echo ""
|
||||
echo "Format: type(scope): brief description"
|
||||
echo ""
|
||||
echo "Types: feat, fix, perf, refactor, test, docs, build, ci"
|
||||
echo ""
|
||||
echo "Example:"
|
||||
echo " feat(parsers): add UniswapV2 parser with event validation"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ Commit message format valid"
|
||||
|
||||
# ==============================================================================
|
||||
# BUILD & DEPENDENCIES
|
||||
# ==============================================================================
|
||||
build:
|
||||
name: Build & Dependencies
|
||||
runs-on: ubuntu-latest
|
||||
needs: pre_flight
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Go ${{ env.GO_VERSION }}
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
cache: true
|
||||
|
||||
- name: Cache Go modules
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cache/go-build
|
||||
~/go/pkg/mod
|
||||
key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-${{ env.GO_VERSION }}-
|
||||
|
||||
- name: Download dependencies
|
||||
run: go mod download
|
||||
|
||||
- name: Verify dependencies
|
||||
run: go mod verify
|
||||
|
||||
- name: Check for tidy modules
|
||||
run: |
|
||||
go mod tidy
|
||||
if [ -n "$(git status --porcelain go.mod go.sum)" ]; then
|
||||
echo "❌ go.mod or go.sum is not tidy"
|
||||
echo "Run: go mod tidy"
|
||||
git diff go.mod go.sum
|
||||
exit 1
|
||||
fi
|
||||
echo "✅ Dependencies are tidy"
|
||||
|
||||
- name: Build all packages
|
||||
run: go build -v ./...
|
||||
|
||||
- name: Build main binary (if exists)
|
||||
run: |
|
||||
if [ -d "cmd/mev-bot" ]; then
|
||||
go build -v -o bin/mev-bot ./cmd/mev-bot
|
||||
echo "✅ Binary built successfully"
|
||||
else
|
||||
echo "ℹ️ No main application yet (planning phase)"
|
||||
fi
|
||||
|
||||
# ==============================================================================
|
||||
# CODE QUALITY
|
||||
# ==============================================================================
|
||||
code_quality:
|
||||
name: Code Quality & Linting
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
|
||||
- name: Run gofmt
|
||||
run: |
|
||||
if [ -n "$(gofmt -l .)" ]; then
|
||||
echo "❌ Code is not formatted"
|
||||
echo "Files needing formatting:"
|
||||
gofmt -l .
|
||||
echo ""
|
||||
echo "Run: gofmt -w ."
|
||||
exit 1
|
||||
fi
|
||||
echo "✅ Code formatting passed"
|
||||
|
||||
- name: Run go vet
|
||||
run: go vet ./...
|
||||
|
||||
- name: Run golangci-lint
|
||||
uses: golangci/golangci-lint-action@v6
|
||||
with:
|
||||
version: ${{ env.GOLANGCI_LINT_VERSION }}
|
||||
args: --timeout=10m --config=.golangci.yml
|
||||
|
||||
- name: Run gosec security scanner
|
||||
run: |
|
||||
go install github.com/securecodewarrior/gosec/v2/cmd/gosec@latest
|
||||
gosec -fmt sarif -out gosec.sarif ./... || true
|
||||
|
||||
- name: Upload SARIF file
|
||||
uses: github/codeql-action/upload-sarif@v3
|
||||
if: always()
|
||||
with:
|
||||
sarif_file: gosec.sarif
|
||||
|
||||
- name: Check for TODO/FIXME comments
|
||||
run: |
|
||||
if grep -r "TODO\|FIXME" --include="*.go" pkg/ cmd/ internal/ | grep -v "_test.go"; then
|
||||
echo "⚠️ TODO/FIXME comments found - ensure they're tracked in issues"
|
||||
fi
|
||||
|
||||
# ==============================================================================
|
||||
# UNIT TESTS WITH 100% COVERAGE ENFORCEMENT
|
||||
# ==============================================================================
|
||||
unit_tests:
|
||||
name: Unit Tests (100% Coverage Required)
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
|
||||
- name: Cache Go modules
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cache/go-build
|
||||
~/go/pkg/mod
|
||||
key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ hashFiles('**/go.sum') }}
|
||||
|
||||
- name: Run tests with race detector
|
||||
run: |
|
||||
go test -v -race -timeout=30m ./...
|
||||
|
||||
- name: Generate coverage report
|
||||
run: |
|
||||
go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
|
||||
|
||||
- name: Calculate coverage percentage
|
||||
id: coverage
|
||||
run: |
|
||||
COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | sed 's/%//')
|
||||
echo "coverage=$COVERAGE" >> $GITHUB_OUTPUT
|
||||
echo "Coverage: $COVERAGE%"
|
||||
|
||||
- name: Enforce 100% coverage requirement
|
||||
run: |
|
||||
COVERAGE=${{ steps.coverage.outputs.coverage }}
|
||||
MIN_COVERAGE=${{ env.MIN_COVERAGE }}
|
||||
|
||||
echo "Coverage: $COVERAGE%"
|
||||
echo "Minimum Required: $MIN_COVERAGE%"
|
||||
|
||||
# Use bc for floating point comparison
|
||||
if (( $(echo "$COVERAGE < $MIN_COVERAGE" | bc -l) )); then
|
||||
echo ""
|
||||
echo "❌ COVERAGE FAILURE"
|
||||
echo "Coverage $COVERAGE% is below required $MIN_COVERAGE%"
|
||||
echo ""
|
||||
echo "Uncovered lines:"
|
||||
go tool cover -func=coverage.out | grep -v "100.0%"
|
||||
echo ""
|
||||
echo "See docs/planning/03_TESTING_REQUIREMENTS.md for details"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ Coverage requirement met: $COVERAGE%"
|
||||
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@v4
|
||||
with:
|
||||
file: ./coverage.out
|
||||
flags: unittests
|
||||
name: v2-coverage
|
||||
|
||||
- name: Generate HTML coverage report
|
||||
run: |
|
||||
go tool cover -html=coverage.out -o coverage.html
|
||||
|
||||
- name: Upload coverage artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: coverage-report
|
||||
path: |
|
||||
coverage.out
|
||||
coverage.html
|
||||
retention-days: 30
|
||||
|
||||
# ==============================================================================
|
||||
# INTEGRATION TESTS
|
||||
# ==============================================================================
|
||||
integration_tests:
|
||||
name: Integration Tests
|
||||
runs-on: ubuntu-latest
|
||||
needs: unit_tests
|
||||
if: contains(github.event.head_commit.message, '[integration]') || github.event_name == 'pull_request'
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
|
||||
- name: Cache Go modules
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cache/go-build
|
||||
~/go/pkg/mod
|
||||
key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ hashFiles('**/go.sum') }}
|
||||
|
||||
- name: Run integration tests
|
||||
run: |
|
||||
go test -v -timeout=30m -tags=integration ./...
|
||||
|
||||
- name: Run end-to-end tests
|
||||
run: |
|
||||
if [ -d "tests/e2e" ]; then
|
||||
go test -v -timeout=30m ./tests/e2e/...
|
||||
fi
|
||||
|
||||
# ==============================================================================
|
||||
# PERFORMANCE BENCHMARKS
|
||||
# ==============================================================================
|
||||
benchmarks:
|
||||
name: Performance Benchmarks
|
||||
runs-on: ubuntu-latest
|
||||
needs: unit_tests
|
||||
if: github.event.inputs.run_benchmarks == 'true' || contains(github.event.head_commit.message, '[bench]')
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
|
||||
- name: Run benchmarks
|
||||
run: |
|
||||
go test -bench=. -benchmem -benchtime=10s ./... > benchmark.txt
|
||||
cat benchmark.txt
|
||||
|
||||
- name: Check performance thresholds
|
||||
run: |
|
||||
echo "Checking parser performance targets..."
|
||||
|
||||
# Parser should be < 5ms per transaction
|
||||
# Arbitrage detection should be < 10ms
|
||||
# End-to-end should be < 50ms
|
||||
|
||||
echo "✅ Performance benchmarks completed"
|
||||
echo "Review benchmark.txt for detailed results"
|
||||
|
||||
- name: Upload benchmark results
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: benchmarks
|
||||
path: benchmark.txt
|
||||
retention-days: 90
|
||||
|
||||
# ==============================================================================
|
||||
# DECIMAL PRECISION TESTS
|
||||
# ==============================================================================
|
||||
decimal_tests:
|
||||
name: Decimal Precision Validation
|
||||
runs-on: ubuntu-latest
|
||||
needs: unit_tests
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
|
||||
- name: Run decimal precision tests
|
||||
run: |
|
||||
# Run tests that specifically test decimal handling
|
||||
go test -v -run TestDecimal ./...
|
||||
|
||||
echo "✅ Decimal precision tests passed"
|
||||
|
||||
# ==============================================================================
|
||||
# MODULARITY VALIDATION
|
||||
# ==============================================================================
|
||||
modularity_check:
|
||||
name: Modularity Validation
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
|
||||
- name: Check component independence
|
||||
run: |
|
||||
echo "Validating component modularity..."
|
||||
|
||||
# Each pkg/* should compile independently
|
||||
for dir in pkg/*/; do
|
||||
if [ -d "$dir" ]; then
|
||||
echo "Testing $dir..."
|
||||
(cd "$dir" && go build .) || exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
echo "✅ All components compile independently"
|
||||
|
||||
- name: Check for circular dependencies
|
||||
run: |
|
||||
go install golang.org/x/tools/cmd/godepgraph@latest
|
||||
godepgraph ./... | grep -i cycle && exit 1 || echo "✅ No circular dependencies"
|
||||
|
||||
# ==============================================================================
|
||||
# FINAL VALIDATION
|
||||
# ==============================================================================
|
||||
final_check:
|
||||
name: Final Validation Summary
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- pre_flight
|
||||
- build
|
||||
- code_quality
|
||||
- unit_tests
|
||||
- modularity_check
|
||||
- decimal_tests
|
||||
if: always()
|
||||
steps:
|
||||
- name: Check all jobs status
|
||||
run: |
|
||||
echo "# 🤖 MEV Bot V2 CI/CD Summary" > summary.md
|
||||
echo "" >> summary.md
|
||||
echo "**Commit**: ${{ github.sha }}" >> summary.md
|
||||
echo "**Branch**: ${{ github.ref_name }}" >> summary.md
|
||||
echo "**Timestamp**: $(date -u)" >> summary.md
|
||||
echo "" >> summary.md
|
||||
|
||||
echo "## Test Results" >> summary.md
|
||||
echo "| Check | Status |" >> summary.md
|
||||
echo "|-------|--------|" >> summary.md
|
||||
echo "| Pre-Flight | ${{ needs.pre_flight.result == 'success' && '✅' || '❌' }} |" >> summary.md
|
||||
echo "| Build | ${{ needs.build.result == 'success' && '✅' || '❌' }} |" >> summary.md
|
||||
echo "| Code Quality | ${{ needs.code_quality.result == 'success' && '✅' || '❌' }} |" >> summary.md
|
||||
echo "| Unit Tests (100% Coverage) | ${{ needs.unit_tests.result == 'success' && '✅' || '❌' }} |" >> summary.md
|
||||
echo "| Modularity | ${{ needs.modularity_check.result == 'success' && '✅' || '❌' }} |" >> summary.md
|
||||
echo "| Decimal Precision | ${{ needs.decimal_tests.result == 'success' && '✅' || '❌' }} |" >> summary.md
|
||||
|
||||
cat summary.md
|
||||
|
||||
# Check if all required jobs passed
|
||||
if [[ "${{ needs.pre_flight.result }}" == "success" &&
|
||||
"${{ needs.build.result }}" == "success" &&
|
||||
"${{ needs.code_quality.result }}" == "success" &&
|
||||
"${{ needs.unit_tests.result }}" == "success" &&
|
||||
"${{ needs.modularity_check.result }}" == "success" &&
|
||||
"${{ needs.decimal_tests.result }}" == "success" ]]; then
|
||||
echo "" >> summary.md
|
||||
echo "## ✅ ALL CHECKS PASSED" >> summary.md
|
||||
echo "Ready for merge to v2-prep branch" >> summary.md
|
||||
exit 0
|
||||
else
|
||||
echo "" >> summary.md
|
||||
echo "## ❌ CHECKS FAILED" >> summary.md
|
||||
echo "Fix failing checks before merging" >> summary.md
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Upload summary
|
||||
uses: actions/upload-artifact@v4
|
||||
if: always()
|
||||
with:
|
||||
name: ci-summary
|
||||
path: summary.md
|
||||
|
||||
- name: Comment on PR
|
||||
uses: actions/github-script@v7
|
||||
if: github.event_name == 'pull_request' && always()
|
||||
with:
|
||||
script: |
|
||||
const fs = require('fs');
|
||||
const summary = fs.readFileSync('summary.md', 'utf8');
|
||||
|
||||
github.rest.issues.createComment({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: summary
|
||||
});
|
||||
0
orig/.gitignore → .gitignore
vendored
0
orig/.gitignore → .gitignore
vendored
0
orig/.gitmodules → .gitmodules
vendored
0
orig/.gitmodules → .gitmodules
vendored
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user