- Initialize Go module with dependencies - Create core mining package with Manager, Miner, and MinerConfig - Implement comprehensive tests with 100% coverage - Create CLI using Cobra with start, stop, list, status commands - Add demo main.go for development and testing - Configure CodeRabbit for automated reviews - Configure GoReleaser for multi-platform releases - Add EUPL-1.2 license - Create Makefile with common targets - Update README with badges and documentation - Add .gitignore for Go projects Co-authored-by: Snider <631881+Snider@users.noreply.github.com>
103 lines
2.6 KiB
Makefile
103 lines
2.6 KiB
Makefile
.PHONY: all build test clean install run demo help lint fmt vet
|
|
|
|
# Variables
|
|
BINARY_NAME=mining
|
|
MAIN_PACKAGE=./cmd/mining
|
|
GO=go
|
|
GOFLAGS=-v
|
|
|
|
all: test build
|
|
|
|
# Build the CLI binary
|
|
build:
|
|
@echo "Building $(BINARY_NAME)..."
|
|
$(GO) build $(GOFLAGS) -o $(BINARY_NAME) $(MAIN_PACKAGE)
|
|
|
|
# Build for multiple platforms
|
|
build-all:
|
|
@echo "Building for multiple platforms..."
|
|
GOOS=linux GOARCH=amd64 $(GO) build -o dist/$(BINARY_NAME)-linux-amd64 $(MAIN_PACKAGE)
|
|
GOOS=linux GOARCH=arm64 $(GO) build -o dist/$(BINARY_NAME)-linux-arm64 $(MAIN_PACKAGE)
|
|
GOOS=darwin GOARCH=amd64 $(GO) build -o dist/$(BINARY_NAME)-darwin-amd64 $(MAIN_PACKAGE)
|
|
GOOS=darwin GOARCH=arm64 $(GO) build -o dist/$(BINARY_NAME)-darwin-arm64 $(MAIN_PACKAGE)
|
|
GOOS=windows GOARCH=amd64 $(GO) build -o dist/$(BINARY_NAME)-windows-amd64.exe $(MAIN_PACKAGE)
|
|
|
|
# Install the binary
|
|
install:
|
|
@echo "Installing $(BINARY_NAME)..."
|
|
$(GO) install $(MAIN_PACKAGE)
|
|
|
|
# Run tests
|
|
test:
|
|
@echo "Running tests..."
|
|
$(GO) test -v -race -coverprofile=coverage.out ./...
|
|
|
|
# Run tests with coverage report
|
|
coverage: test
|
|
@echo "Generating coverage report..."
|
|
$(GO) tool cover -html=coverage.out -o coverage.html
|
|
|
|
# Run demo
|
|
demo:
|
|
@echo "Running demo..."
|
|
$(GO) run main.go
|
|
|
|
# Run the CLI
|
|
run: build
|
|
./$(BINARY_NAME)
|
|
|
|
# Clean build artifacts
|
|
clean:
|
|
@echo "Cleaning..."
|
|
rm -f $(BINARY_NAME)
|
|
rm -rf dist/
|
|
rm -f coverage.out coverage.html
|
|
$(GO) clean
|
|
|
|
# Format code
|
|
fmt:
|
|
@echo "Formatting code..."
|
|
$(GO) fmt ./...
|
|
|
|
# Run go vet
|
|
vet:
|
|
@echo "Running go vet..."
|
|
$(GO) vet ./...
|
|
|
|
# Run linters
|
|
lint: fmt vet
|
|
@echo "Running linters..."
|
|
@if command -v golangci-lint >/dev/null 2>&1; then \
|
|
golangci-lint run; \
|
|
else \
|
|
echo "golangci-lint not installed. Run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest"; \
|
|
fi
|
|
|
|
# Tidy dependencies
|
|
tidy:
|
|
@echo "Tidying dependencies..."
|
|
$(GO) mod tidy
|
|
|
|
# Download dependencies
|
|
deps:
|
|
@echo "Downloading dependencies..."
|
|
$(GO) mod download
|
|
|
|
# Help
|
|
help:
|
|
@echo "Available targets:"
|
|
@echo " all - Run tests and build"
|
|
@echo " build - Build the CLI binary"
|
|
@echo " build-all - Build for multiple platforms"
|
|
@echo " install - Install the binary"
|
|
@echo " test - Run tests"
|
|
@echo " coverage - Run tests with coverage report"
|
|
@echo " demo - Run the demo"
|
|
@echo " run - Build and run the CLI"
|
|
@echo " clean - Clean build artifacts"
|
|
@echo " fmt - Format code"
|
|
@echo " vet - Run go vet"
|
|
@echo " lint - Run linters"
|
|
@echo " tidy - Tidy dependencies"
|
|
@echo " deps - Download dependencies"
|
|
@echo " help - Show this help message"
|