.PHONY: all build clean clean-docs test test-unit test-integration test-e2e test-coverage lint install dev prod setup validate configlint ci-local docs # Default target all: build # Build all components build: go build -o bin/api-server cmd/api-server/main.go go build -o bin/worker cmd/worker/worker_server.go cmd/worker/worker_config.go go build -o bin/tui ./cmd/tui cd cli && zig build prod @echo "✓ All components built" # Build production-optimized binaries prod: go build -ldflags="-s -w" -o bin/api-server cmd/api-server/main.go go build -ldflags="-s -w" -o bin/worker cmd/worker/worker_server.go go build -ldflags="-s -w" -o bin/tui ./cmd/tui cd cli && zig build prod && strip zig-out/prod/ml @echo "✓ Production binaries built" # Development build (faster compilation) dev: go build -o bin/api-server cmd/api-server/main.go go build -o bin/worker cmd/worker/worker_server.go cmd/worker/worker_config.go go build -o bin/tui ./cmd/tui cd cli && zig build dev @echo "✓ Development binaries built" # Clean build artifacts clean: rm -rf bin/ coverage/ rm -rf cli/zig-out/ rm -rf cli/.zig-cache/ go clean @echo "✓ Cleaned" clean-docs: rm -rf docs/_site/ @echo "✓ Cleaned docs" # Run tests test: go test ./... cd cli && zig build test @echo "✓ All tests passed" # Lint Go and Zig code lint: gofmt -w ./cmd ./internal ./tests || true go vet ./... cd cli && zig fmt . @echo "✓ Lint completed" # Install to system (requires sudo) install: prod sudo cp bin/api-server /usr/local/bin/fetchml-api sudo cp bin/worker /usr/local/bin/fetchml-worker sudo cp bin/tui /usr/local/bin/fetchml-tui sudo cp cli/zig-out/prod/ml /usr/local/bin/ml @echo "✓ Installed" # Setup production environment setup: @if [ "$(shell uname)" = "Linux" ]; then \ sudo ./scripts/setup-prod.sh; \ else \ echo "Production setup is for Linux only. You're on $(shell uname)."; \ echo "Use docker-compose for local development."; \ fi # Validate production configuration validate: ./scripts/validate-prod-config.sh configs/config-prod.yaml configs/worker-prod.toml # Validate YAML configs against JSON schema configlint: go run ./cmd/configlint --schema configs/schema/config_schema.yaml \ configs/config-prod.yaml \ configs/config-no-tls.yaml \ configs/config-dev.yaml # Run a local approximation of the CI pipeline ci-local: make test make lint make configlint @echo "Running queue package tests with race detector..." go test -v -race -coverprofile=coverage/queue-coverage.out ./internal/queue/... @echo "Running coverage..." make test-coverage # Docker targets docker-build: docker build -f build/docker/simple.Dockerfile -t fetchml:latest . @echo "✓ Docker image built" docker-run: docker-compose up -d @echo "✓ Services started" docker-stop: docker-compose down @echo "✓ Services stopped" docker-logs: docker-compose logs -f # Monitoring setup (Linux only) setup-monitoring: @if [ "$(shell uname)" = "Linux" ]; then \ sudo ./scripts/setup-monitoring-prod.sh; \ else \ echo "Monitoring setup is for Linux production. Use docker-compose for local development."; \ fi # Enhanced test targets test-unit: go test -v -short ./... test-integration: go test -v ./... test-e2e: go test -v ./tests/e2e/... test-coverage: go test -coverprofile=coverage/coverage.out ./... go tool cover -html=coverage/coverage.out -o coverage/coverage.html @echo "✓ Coverage report: coverage/coverage.html" # Documentation setup docs-setup: @echo "Setting up MkDocs documentation..." @if ! command -v mkdocs >/dev/null 2>&1; then \ echo "MkDocs not found. Please install it manually:"; \ echo " macOS: brew install mkdocs mkdocs-material"; \ echo " Linux: pip install mkdocs mkdocs-material"; \ echo "Or visit: https://www.mkdocs.org/user-guide/installation/"; \ exit 1; \ fi @if ! python3 -c "import pymdownx.superfences" >/dev/null 2>&1; then \ echo "pymdown-extensions not found. Please install it manually:"; \ echo " pip3 install --user pymdown-extensions"; \ echo " Or use a virtual environment: python3 -m venv docs-env && source docs-env/bin/activate && pip install pymdown-extensions"; \ exit 1; \ fi @echo "Documentation setup complete!" # Documentation docs: docs-setup docs-build @echo "Starting MkDocs development server..." cd docs && mkdocs serve # Build documentation docs-build: @echo "Building static documentation..." cd docs && mkdocs build # Help help: @echo "FetchML Build System" @echo "" @echo "Build Targets:" @echo " make build - Build all components (default)" @echo " make prod - Build production-optimized binaries" @echo " make dev - Build development binaries (faster)" @echo " make clean - Remove build artifacts" @echo "" @echo "Docker Targets:" @echo " make docker-build - Build Docker image" @echo " make docker-run - Start services with docker-compose" @echo " make docker-stop - Stop docker-compose services" @echo " make docker-logs - View docker-compose logs" @echo "" @echo "Test Targets:" @echo " make test - Run all tests" @echo " make test-unit - Run unit tests only" @echo " make test-integration - Run integration tests" @echo " make test-coverage - Generate coverage report" @echo " make lint - Run formatters and linters" @echo " make ci-local - Run local CI dry-run (tests, lint, config validation, coverage)" @echo " make configlint - Validate YAML configs against schema" @echo "" @echo "Setup Targets:" @echo " make install - Install binaries to /usr/local/bin (requires sudo)" @echo " make setup - Run production setup (Linux only)" @echo " make setup-monitoring - Setup monitoring stack (Linux only)" @echo " make validate - Validate production configuration" @echo "" @echo "Documentation:" @echo " make docs-setup - Install MkDocs and dependencies" @echo " make docs - Start MkDocs development server with live reload" @echo " make docs-build - Build static documentation for deployment" @echo "" @echo "Utility:" @echo " make size - Show binary sizes" @echo " make help - Show this help"