feat: implement Epic 0 - Project Setup & Foundation
Implemented all 5 stories from Epic 0: Story 0.1: Project Initialization - Initialize Go module with path git.dcentral.systems/toolz/goplt - Create complete directory structure (cmd/, internal/, pkg/, modules/, config/, etc.) - Add comprehensive .gitignore for Go projects - Create README.md with project overview and setup instructions Story 0.2: Configuration Management System - Define ConfigProvider interface in pkg/config - Implement Viper-based configuration in internal/config - Create configuration loader with environment support - Add default, development, and production YAML config files Story 0.3: Structured Logging System - Define Logger interface in pkg/logger - Implement Zap-based logger in internal/logger - Add request ID middleware for Gin - Create global logger export with convenience functions - Support context-aware logging with request/user ID extraction Story 0.4: CI/CD Pipeline - Create GitHub Actions workflow for CI (test, lint, build, fmt) - Add comprehensive Makefile with development commands - Configure golangci-lint with reasonable defaults Story 0.5: Dependency Injection and Bootstrap - Create FX-based DI container in internal/di - Implement provider functions for Config and Logger - Create application entry point in cmd/platform/main.go - Add lifecycle management with graceful shutdown All acceptance criteria met: - go build ./cmd/platform succeeds - go test ./... runs successfully - go mod verify passes - Config loads from config/default.yaml - Logger can be injected and used - Application starts and shuts down gracefully
This commit is contained in:
91
Makefile
91
Makefile
@@ -1,11 +1,31 @@
|
||||
.PHONY: help docs-install docs-serve docs-build docs-deploy docs-clean docs-validate
|
||||
.PHONY: help test test-coverage lint fmt fmt-check build clean docker-build docker-run generate verify
|
||||
.PHONY: docs-install docs-serve docs-build docs-deploy docs-clean docs-validate
|
||||
.PHONY: docs-docker-build docs-docker-serve docs-docker-build-site docs-docker-clean docs-docker-compose-up docs-docker-compose-down
|
||||
|
||||
# Variables
|
||||
GO := go
|
||||
BINARY_NAME := platform
|
||||
BINARY_PATH := bin/$(BINARY_NAME)
|
||||
DOCKER_IMAGE := goplt:latest
|
||||
|
||||
# Default target
|
||||
help:
|
||||
@echo "Available targets:"
|
||||
@echo ""
|
||||
@echo "Local commands (require Python/pip):"
|
||||
@echo "Development commands:"
|
||||
@echo " make test - Run all tests"
|
||||
@echo " make test-coverage - Run tests with coverage report"
|
||||
@echo " make lint - Run linters"
|
||||
@echo " make fmt - Format code"
|
||||
@echo " make fmt-check - Check code formatting"
|
||||
@echo " make build - Build platform binary"
|
||||
@echo " make clean - Clean build artifacts"
|
||||
@echo " make docker-build - Build Docker image"
|
||||
@echo " make docker-run - Run Docker container"
|
||||
@echo " make generate - Run code generation"
|
||||
@echo " make verify - Verify code (fmt, lint, test)"
|
||||
@echo ""
|
||||
@echo "Documentation commands (require Python/pip):"
|
||||
@echo " make docs-install - Install MkDocs dependencies"
|
||||
@echo " make docs-serve - Serve documentation locally (http://127.0.0.1:8000)"
|
||||
@echo " make docs-build - Build static documentation site"
|
||||
@@ -26,6 +46,73 @@ help:
|
||||
@echo " make build-docs - Alias for docs-build"
|
||||
@echo " make docs-docker - Alias for docs-docker-serve"
|
||||
|
||||
# Development commands
|
||||
test:
|
||||
@echo "Running tests..."
|
||||
$(GO) test -v -race ./...
|
||||
|
||||
test-coverage:
|
||||
@echo "Running tests with coverage..."
|
||||
$(GO) test -v -race -coverprofile=coverage.out ./...
|
||||
$(GO) tool cover -html=coverage.out -o coverage.html
|
||||
@echo "Coverage report generated: coverage.html"
|
||||
|
||||
lint:
|
||||
@echo "Running linters..."
|
||||
@if command -v golangci-lint > /dev/null; then \
|
||||
golangci-lint run; \
|
||||
else \
|
||||
echo "golangci-lint not found. Install with: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest"; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
fmt:
|
||||
@echo "Formatting code..."
|
||||
$(GO) fmt ./...
|
||||
@if command -v goimports > /dev/null; then \
|
||||
goimports -w .; \
|
||||
else \
|
||||
echo "goimports not found. Install with: go install golang.org/x/tools/cmd/goimports@latest"; \
|
||||
fi
|
||||
|
||||
fmt-check:
|
||||
@echo "Checking code formatting..."
|
||||
@if [ "$(shell gofmt -s -l . | wc -l)" -gt 0 ]; then \
|
||||
echo "The following files need formatting:"; \
|
||||
gofmt -s -d .; \
|
||||
exit 1; \
|
||||
fi
|
||||
@echo "Code is properly formatted"
|
||||
|
||||
build:
|
||||
@echo "Building platform binary..."
|
||||
$(GO) build -v -o $(BINARY_PATH) ./cmd/platform
|
||||
@echo "Build complete: $(BINARY_PATH)"
|
||||
|
||||
clean:
|
||||
@echo "Cleaning build artifacts..."
|
||||
rm -rf bin/
|
||||
rm -f coverage.out coverage.html
|
||||
@echo "Clean complete"
|
||||
|
||||
docker-build:
|
||||
@echo "Building Docker image..."
|
||||
docker build -t $(DOCKER_IMAGE) .
|
||||
@echo "Docker image built: $(DOCKER_IMAGE)"
|
||||
|
||||
docker-run: docker-build
|
||||
@echo "Running Docker container..."
|
||||
docker run --rm -it \
|
||||
-p 8080:8080 \
|
||||
$(DOCKER_IMAGE)
|
||||
|
||||
generate:
|
||||
@echo "Running code generation..."
|
||||
$(GO) generate ./...
|
||||
|
||||
verify: fmt-check lint test
|
||||
@echo "Verification complete"
|
||||
|
||||
# Install MkDocs and dependencies
|
||||
docs-install:
|
||||
@echo "Installing MkDocs dependencies..."
|
||||
|
||||
Reference in New Issue
Block a user