97 lines
2.2 KiB
Makefile
97 lines
2.2 KiB
Makefile
# Makefile for MEV Bot
|
|
|
|
# Variables
|
|
BINARY=mev-bot
|
|
MAIN_FILE=cmd/mev-bot/main.go
|
|
BINARY_PATH=bin/$(BINARY)
|
|
|
|
# Default target
|
|
.PHONY: all
|
|
all: build
|
|
|
|
# Build the application
|
|
.PHONY: build
|
|
build:
|
|
@echo "Building $(BINARY)..."
|
|
@mkdir -p bin
|
|
@go build -o $(BINARY_PATH) $(MAIN_FILE)
|
|
@echo "Build successful!"
|
|
|
|
# Run the application
|
|
.PHONY: run
|
|
run: build
|
|
@echo "Running $(BINARY)..."
|
|
@$(BINARY_PATH)
|
|
|
|
# Run tests
|
|
.PHONY: test
|
|
test:
|
|
@echo "Running tests..."
|
|
@go test -v ./...
|
|
|
|
# Run tests with coverage
|
|
.PHONY: test-coverage
|
|
test-coverage:
|
|
@echo "Running tests with coverage..."
|
|
@go test -coverprofile=coverage.out ./...
|
|
@go tool cover -html=coverage.out -o coverage.html
|
|
@echo "Coverage report generated: coverage.html"
|
|
|
|
# Clean build artifacts
|
|
.PHONY: clean
|
|
clean:
|
|
@echo "Cleaning..."
|
|
@rm -rf bin/
|
|
@rm -f coverage.out coverage.html
|
|
@echo "Clean complete!"
|
|
|
|
# Install dependencies
|
|
.PHONY: deps
|
|
deps:
|
|
@echo "Installing dependencies..."
|
|
@go mod tidy
|
|
@echo "Dependencies installed!"
|
|
|
|
# Format code
|
|
.PHONY: fmt
|
|
fmt:
|
|
@echo "Formatting code..."
|
|
@go fmt ./...
|
|
|
|
# Vet code
|
|
.PHONY: vet
|
|
vet:
|
|
@echo "Vetting code..."
|
|
@go vet ./...
|
|
|
|
# Lint code (requires golangci-lint)
|
|
.PHONY: lint
|
|
lint:
|
|
@echo "Linting code..."
|
|
@which golangci-lint > /dev/null || (echo "golangci-lint not found, installing..." && go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest)
|
|
@golangci-lint run
|
|
|
|
# Update dependencies
|
|
.PHONY: update
|
|
update:
|
|
@echo "Updating dependencies..."
|
|
@go get -u ./...
|
|
@go mod tidy
|
|
@echo "Dependencies updated!"
|
|
|
|
# Help
|
|
.PHONY: help
|
|
help:
|
|
@echo "Available targets:"
|
|
@echo " all - Build the application (default)"
|
|
@echo " build - Build the application"
|
|
@echo " run - Build and run the application"
|
|
@echo " test - Run tests"
|
|
@echo " test-coverage - Run tests with coverage report"
|
|
@echo " clean - Clean build artifacts"
|
|
@echo " deps - Install dependencies"
|
|
@echo " fmt - Format code"
|
|
@echo " vet - Vet code"
|
|
@echo " lint - Lint code (requires golangci-lint)"
|
|
@echo " update - Update dependencies"
|
|
@echo " help - Show this help"
|