forgejo-runner-sizer/Makefile
Manuel Ganter bc9d0dd8ea
All checks were successful
ci / ci (push) Successful in 2m2s
feat: migrate receiver to Fuego framework with OpenAPI generation
Replace net/http handlers with Fuego framework for automatic OpenAPI 3.0
spec generation. Add generated Go client package, OpenAPI extraction
script, and update Makefile with separate build/run targets for both
binaries.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 11:16:02 +01:00

97 lines
2.6 KiB
Makefile

# ABOUTME: Makefile for forgejo-runner-sizer project.
# ABOUTME: Provides targets for building, formatting, linting, and testing.
GO := go
GOLANGCI_LINT := $(GO) run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.6.2
GITLEAKS := $(GO) run github.com/zricethezav/gitleaks/v8@v8.30.0
OAPI_CODEGEN := $(GO) run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@latest
# Build flags
LDFLAGS := -s -w
BUILD_FLAGS := -ldflags "$(LDFLAGS)"
default: run
.PHONY: all build build-collector build-receiver clean fmt format lint gitleaks test run-collector run-receiver help vet tidy install-hooks openapi generate-client
# Default target
all: fmt vet lint build
## Build targets
build: build-collector build-receiver ## Build both binaries
build-collector: ## Build the collector binary
$(GO) build $(BUILD_FLAGS) -o collector ./cmd/collector
build-receiver: ## Build the receiver binary
$(GO) build $(BUILD_FLAGS) -o receiver ./cmd/receiver
clean: ## Remove build artifacts
rm -f collector receiver coverage.out coverage.html
$(GO) clean
## Code quality targets
fmt: ## Format code using go fmt
$(GO) fmt ./...
format: fmt ## Alias for fmt
vet: ## Run go vet
$(GO) vet ./...
lint: ## Run golangci-lint
$(GOLANGCI_LINT) run ./...
gitleaks: ## Check for secrets in git history
$(GITLEAKS) git --staged
gitleaks-all: ## Check for secrets in git history
$(GITLEAKS) git .
## OpenAPI / Client Generation
openapi: ## Generate OpenAPI spec from Fuego routes
$(GO) run scripts/extract-openapi/main.go
generate-client: openapi ## Generate Go client from OpenAPI spec
rm -rf pkg/client
mkdir -p pkg/client
$(OAPI_CODEGEN) -generate types,client -package client docs/openapi.json > pkg/client/client.gen.go
## Dependency management
tidy: ## Tidy go modules
$(GO) mod tidy
## Testing targets
test: ## Run tests
$(GO) test -v ./...
test-coverage: ## Run tests with coverage
$(GO) test -v -coverprofile=coverage.out ./...
$(GO) tool cover -html=coverage.out -o coverage.html
## Run targets
run-collector: build-collector ## Build and run the collector
./collector
run-receiver: build-receiver ## Build and run the receiver
./receiver --read-token=secure-read-token --hmac-key=secure-hmac-key
## Git hooks
install-hooks: ## Install git hooks
cp scripts/hooks/pre-commit .git/hooks/pre-commit
cp scripts/hooks/commit-msg .git/hooks/commit-msg
chmod +x .git/hooks/pre-commit
chmod +x .git/hooks/commit-msg
@echo "Git hooks installed successfully"
## Help
help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'