Files
goplt/Makefile
0x1d 5fdbb729bd
Some checks failed
CI / Test (pull_request) Failing after 17s
CI / Lint (pull_request) Failing after 18s
CI / Build (pull_request) Successful in 12s
CI / Format Check (pull_request) Successful in 2s
test: add comprehensive tests for all Epic 1 stories
Story 1.2: Database Layer
- Test database client creation, connection, ping, and close
- Test connection pooling configuration
- Tests skip if database is not available (short mode)

Story 1.3: Health Monitoring and Metrics
- Test health registry registration and checking
- Test database health checker
- Test liveness and readiness checks
- Test metrics creation, middleware, and handler
- Test Prometheus metrics endpoint

Story 1.4: Error Handling and Error Bus
- Test channel-based error bus creation
- Test error publishing with context
- Test nil error handling
- Test channel full scenario
- Test graceful shutdown
- Fix Close() method to handle multiple calls safely

Story 1.5: HTTP Server and Middleware
- Test server creation with all middleware
- Test request ID middleware
- Test logging middleware
- Test panic recovery middleware
- Test CORS middleware
- Test timeout middleware
- Test health and metrics endpoints
- Test server shutdown

Story 1.6: OpenTelemetry Tracing
- Test tracer initialization (enabled/disabled)
- Test development and production modes
- Test OTLP exporter configuration
- Test graceful shutdown
- Test no-op tracer provider

All tests follow Go testing best practices:
- Table-driven tests where appropriate
- Parallel execution
- Proper mocking of interfaces
- Skip tests requiring external dependencies in short mode
2025-11-05 21:05:36 +01:00

194 lines
6.1 KiB
Makefile

.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 "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"
@echo " make docs-deploy - Deploy documentation to GitHub Pages"
@echo " make docs-clean - Clean build artifacts"
@echo " make docs-validate - Validate MkDocs configuration"
@echo ""
@echo "Docker commands (no Python installation required):"
@echo " make docs-docker-build - Build Docker image for MkDocs"
@echo " make docs-docker-serve - Serve documentation using Docker"
@echo " make docs-docker-build-site - Build static site in Docker container"
@echo " make docs-docker-clean - Clean Docker images and containers"
@echo " make docs-docker-compose-up - Start docs server with docker-compose"
@echo " make docs-docker-compose-down - Stop docs server with docker-compose"
@echo ""
@echo "Documentation shortcuts:"
@echo " make docs - Alias for docs-serve"
@echo " make build-docs - Alias for docs-build"
@echo " make docs-docker - Alias for docs-docker-serve"
# Development commands
test:
@echo "Running tests..."
CGO_ENABLED=1 $(GO) test -v ./...
test-coverage:
@echo "Running tests with coverage..."
CGO_ENABLED=1 $(GO) test -v -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..."
cd docs && pip install -r requirements.txt
# Serve documentation locally with auto-reload
docs-serve:
@echo "Starting MkDocs development server..."
@echo "Documentation will be available at http://127.0.0.1:8000"
cd docs && mkdocs serve
# Build static documentation site
docs-build:
@echo "Building static documentation site..."
cd docs && mkdocs build
@echo "Build complete! Output is in the 'docs/site/' directory"
# Deploy documentation to GitHub Pages
docs-deploy:
@echo "Deploying documentation to GitHub Pages..."
cd docs && mkdocs gh-deploy
# Clean build artifacts
docs-clean:
@echo "Cleaning MkDocs build artifacts..."
rm -rf docs/site/
rm -rf docs/.mkdocs_cache/
@echo "Clean complete!"
# Validate MkDocs configuration
docs-validate:
@echo "Validating MkDocs configuration..."
cd docs && mkdocs build --strict
@echo "Configuration is valid!"
# Docker commands
docs-docker-build:
@echo "Building Docker image for MkDocs..."
cd docs && docker build -f Dockerfile -t goplt-docs:latest .
docs-docker-serve: docs-docker-build
@echo "Starting MkDocs development server in Docker..."
@echo "Documentation will be available at http://127.0.0.1:8000"
cd docs && docker run --rm -it \
-p 8000:8000 \
-v "$$(pwd):/docs:ro" \
goplt-docs:latest
docs-docker-build-site: docs-docker-build
@echo "Building static documentation site in Docker..."
cd docs && docker run --rm \
-v "$$(pwd):/docs:ro" \
-v "$$(pwd)/site:/docs/site" \
goplt-docs:latest mkdocs build
@echo "Build complete! Output is in the 'docs/site/' directory"
docs-docker-clean:
@echo "Cleaning Docker images and containers..."
-docker stop goplt-docs 2>/dev/null || true
-docker rm goplt-docs 2>/dev/null || true
-docker rmi goplt-docs:latest 2>/dev/null || true
@echo "Clean complete!"
docs-docker-compose-up:
@echo "Starting MkDocs server with docker-compose..."
@echo "Documentation will be available at http://127.0.0.1:8000"
cd docs && docker-compose -f docker-compose.yml up --build
docs-docker-compose-down:
@echo "Stopping MkDocs server..."
cd docs && docker-compose -f docker-compose.yml down
# Convenience aliases
docs: docs-serve
build-docs: docs-build
clean-docs: docs-clean
docs-docker: docs-docker-serve