mirror of
https://github.com/btouchard/ackify-ce.git
synced 2026-02-08 23:08:58 -06:00
Add complete Go application for cryptographic document signature validation with OAuth2 authentication, Ed25519 signatures, and PostgreSQL storage following clean architecture principles.
125 lines
4.8 KiB
Makefile
125 lines
4.8 KiB
Makefile
# Makefile for ackify project
|
|
|
|
.PHONY: build test test-unit test-integration test-short coverage lint fmt vet clean help
|
|
|
|
# Variables
|
|
BINARY_NAME=ackapp
|
|
BUILD_DIR=./cmd/ackapp
|
|
COVERAGE_DIR=coverage
|
|
|
|
# Default target
|
|
help: ## Display this help message
|
|
@echo "Available targets:"
|
|
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
|
|
|
|
# Build targets
|
|
build: ## Build the application
|
|
@echo "Building $(BINARY_NAME)..."
|
|
go build -o $(BINARY_NAME) $(BUILD_DIR)
|
|
|
|
# Test targets
|
|
test: test-unit test-integration ## Run all tests
|
|
|
|
test-unit: ## Run unit tests
|
|
@echo "Running unit tests with race detection..."
|
|
CGO_ENABLED=1 go test -short -race -v ./internal/... ./pkg/... ./cmd/...
|
|
|
|
test-integration: ## Run integration tests (requires PostgreSQL)
|
|
@echo "Running integration tests with race detection..."
|
|
@if [ -z "$(DB_DSN)" ]; then \
|
|
export DB_DSN="postgres://postgres:testpassword@localhost:5432/ackify_test?sslmode=disable"; \
|
|
fi; \
|
|
export INTEGRATION_TESTS=true; \
|
|
CGO_ENABLED=1 go test -v -race -tags=integration ./internal/infrastructure/database/...
|
|
|
|
test-integration-setup: ## Setup test database for integration tests
|
|
@echo "Setting up test database..."
|
|
@psql "postgres://postgres:testpassword@localhost:5432/postgres?sslmode=disable" -c "DROP DATABASE IF EXISTS ackify_test;" || true
|
|
@psql "postgres://postgres:testpassword@localhost:5432/postgres?sslmode=disable" -c "CREATE DATABASE ackify_test;"
|
|
@echo "Test database ready!"
|
|
|
|
test-short: ## Run only quick tests
|
|
@echo "Running short tests..."
|
|
go test -short ./...
|
|
|
|
|
|
# Coverage targets
|
|
coverage: ## Generate test coverage report
|
|
@echo "Generating coverage report..."
|
|
@mkdir -p $(COVERAGE_DIR)
|
|
go test -coverprofile=$(COVERAGE_DIR)/coverage.out ./...
|
|
go tool cover -html=$(COVERAGE_DIR)/coverage.out -o $(COVERAGE_DIR)/coverage.html
|
|
@echo "Coverage report generated: $(COVERAGE_DIR)/coverage.html"
|
|
|
|
coverage-integration: ## Generate integration test coverage report
|
|
@echo "Generating integration coverage report..."
|
|
@mkdir -p $(COVERAGE_DIR)
|
|
@export DB_DSN="postgres://postgres:testpassword@localhost:5432/ackify_test?sslmode=disable"; \
|
|
export INTEGRATION_TESTS=true; \
|
|
go test -v -race -tags=integration -coverprofile=$(COVERAGE_DIR)/coverage-integration.out ./internal/infrastructure/database/...
|
|
go tool cover -html=$(COVERAGE_DIR)/coverage-integration.out -o $(COVERAGE_DIR)/coverage-integration.html
|
|
@echo "Integration coverage report generated: $(COVERAGE_DIR)/coverage-integration.html"
|
|
|
|
coverage-all: ## Generate full coverage report (unit + integration)
|
|
@echo "Generating full coverage report..."
|
|
@mkdir -p $(COVERAGE_DIR)
|
|
@export DB_DSN="postgres://postgres:testpassword@localhost:5432/ackify_test?sslmode=disable"; \
|
|
export INTEGRATION_TESTS=true; \
|
|
go test -v -race -tags=integration -coverprofile=$(COVERAGE_DIR)/coverage-all.out ./...
|
|
go tool cover -html=$(COVERAGE_DIR)/coverage-all.out -o $(COVERAGE_DIR)/coverage-all.html
|
|
go tool cover -func=$(COVERAGE_DIR)/coverage-all.out
|
|
@echo "Full coverage report generated: $(COVERAGE_DIR)/coverage-all.html"
|
|
|
|
coverage-func: ## Show function-level coverage
|
|
go test -coverprofile=$(COVERAGE_DIR)/coverage.out ./...
|
|
go tool cover -func=$(COVERAGE_DIR)/coverage.out
|
|
|
|
# Code quality targets
|
|
fmt: ## Format Go code
|
|
@echo "Formatting code..."
|
|
go fmt ./...
|
|
|
|
vet: ## Run go vet
|
|
@echo "Running go vet..."
|
|
go vet ./...
|
|
|
|
lint: fmt vet ## Run all linting tools
|
|
|
|
# Development targets
|
|
clean: ## Clean build artifacts and test coverage
|
|
@echo "Cleaning..."
|
|
rm -f $(BINARY_NAME)
|
|
rm -rf $(COVERAGE_DIR)
|
|
go clean ./...
|
|
|
|
deps: ## Download and tidy dependencies
|
|
@echo "Downloading dependencies..."
|
|
go mod download
|
|
go mod tidy
|
|
|
|
# Mock generation
|
|
generate-mocks: ## Generate mocks for interfaces
|
|
@echo "Generating mocks..."
|
|
@command -v mockgen >/dev/null 2>&1 || { echo "Installing mockgen..."; go install go.uber.org/mock/mockgen@latest; }
|
|
@mkdir -p test/mocks
|
|
mockgen -source=internal/presentation/handlers/signature_handlers.go -destination=test/mocks/mock_signature_service.go -package=mocks SignatureService
|
|
mockgen -source=internal/presentation/handlers/auth_handlers.go -destination=test/mocks/mock_auth_service.go -package=mocks AuthService
|
|
mockgen -source=internal/domain/repositories/signature_repository.go -destination=test/mocks/mock_signature_repository.go -package=mocks SignatureRepository
|
|
|
|
# Docker targets
|
|
docker-build: ## Build Docker image
|
|
docker build -t ackify:latest .
|
|
|
|
docker-test: ## Run tests in Docker environment
|
|
docker compose -f docker-compose.local.yml up -d postgres
|
|
@sleep 5
|
|
$(MAKE) test
|
|
docker compose -f docker-compose.local.yml down
|
|
|
|
# CI targets
|
|
ci: deps lint test coverage ## Run all CI checks
|
|
|
|
# Install dev tools
|
|
dev-tools: ## Install development tools
|
|
@echo "Installing development tools..."
|
|
go install go.uber.org/mock/mockgen@latest
|