Files
zeekay fae0efeb1b chore: normalize naming to LX across codebase
Apply consistent naming conventions throughout:
- Standardize product name to "LX" in documentation
- Update README files and API documentation
- Apply linter fixes to all source files
- Update Hummingbot connector documentation
2025-12-11 21:04:37 -08:00

134 lines
3.3 KiB
Bash
Executable File

#!/bin/bash
# LX CI Test Script
# Simulates GitHub Actions CI pipeline locally
set -e
echo "========================================="
echo " LX CI Test (Local Simulation)"
echo "========================================="
echo ""
# Colors
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m'
# Change to project root
cd "$(dirname "$0")/.."
# Step 1: Install dependencies
echo "๐Ÿ“ฆ Installing dependencies..."
cd backend
go mod download
go mod verify
cd ..
echo -e "${GREEN}โœ… Dependencies installed${NC}"
echo ""
# Step 2: Run tests
echo "๐Ÿงช Running tests..."
cd backend
if go test -v ./pkg/...; then
echo -e "${GREEN}โœ… Tests passed${NC}"
else
echo -e "${RED}โŒ Tests failed${NC}"
exit 1
fi
cd ..
echo ""
# Step 3: Run tests with race detector
echo "๐Ÿ” Running tests with race detector..."
cd backend
if go test -race -short ./pkg/...; then
echo -e "${GREEN}โœ… Race tests passed${NC}"
else
echo -e "${RED}โŒ Race tests failed${NC}"
exit 1
fi
cd ..
echo ""
# Step 4: Generate coverage
echo "๐Ÿ“Š Generating coverage..."
cd backend
go test -coverprofile=coverage.out ./pkg/... > /dev/null 2>&1
coverage=$(go tool cover -func=coverage.out | grep total | awk '{print $3}')
echo "Coverage: $coverage"
cd ..
echo -e "${GREEN}โœ… Coverage generated${NC}"
echo ""
# Step 5: Build binaries
echo "๐Ÿ”จ Building binaries..."
make build
echo -e "${GREEN}โœ… Binaries built${NC}"
echo ""
# Step 6: Run benchmarks
echo "โšก Running benchmarks..."
cd backend
if go test -bench=. -benchtime=1s ./pkg/orderbook | grep -E "Benchmark|ns/op"; then
echo -e "${GREEN}โœ… Benchmarks completed${NC}"
else
echo -e "${RED}โŒ Benchmarks failed${NC}"
exit 1
fi
cd ..
echo ""
# Step 7: Check for compilation of all cmd tools
echo "๐Ÿ› ๏ธ Checking cmd tools compilation..."
cd backend
failed_cmds=""
for cmd_dir in cmd/*/; do
cmd_name=$(basename "$cmd_dir")
# Skip ZMQ-based commands that require CGO
if [[ "$cmd_name" == *"zmq"* ]] || [[ "$cmd_name" == "hybrid-auto" ]] || [[ "$cmd_name" == "multi-node"* ]]; then
continue
fi
if ! CGO_ENABLED=0 go build -o /tmp/test-binary "./$cmd_dir" 2>/dev/null; then
failed_cmds="$failed_cmds $cmd_name"
fi
rm -f /tmp/test-binary
done
if [ -n "$failed_cmds" ]; then
echo -e "${RED}โŒ Failed to compile:$failed_cmds${NC}"
else
echo -e "${GREEN}โœ… All cmd tools compile${NC}"
fi
cd ..
echo ""
# Step 8: Lint check (if golangci-lint is installed)
echo "๐Ÿ” Running lint checks..."
if command -v golangci-lint &> /dev/null; then
cd backend
if golangci-lint run --timeout=5m ./...; then
echo -e "${GREEN}โœ… Lint checks passed${NC}"
else
echo -e "${RED}โš ๏ธ Lint issues found (non-blocking)${NC}"
fi
cd ..
else
echo "golangci-lint not installed, skipping..."
fi
echo ""
# Summary
echo "========================================="
echo " CI Test Summary"
echo "========================================="
echo -e "${GREEN}โœ… Dependencies installed${NC}"
echo -e "${GREEN}โœ… Tests passed${NC}"
echo -e "${GREEN}โœ… Race detector passed${NC}"
echo -e "${GREEN}โœ… Coverage: $coverage${NC}"
echo -e "${GREEN}โœ… Binaries built${NC}"
echo -e "${GREEN}โœ… Benchmarks completed${NC}"
echo -e "${GREEN}โœ… CI tests completed successfully!${NC}"
echo ""
echo "Your code is ready for CI/CD!"