2026-02-17 17:25:08 +01:00
|
|
|
# ABOUTME: Makefile for forgejo-runner-sizer project.
|
2026-02-04 14:13:24 +01:00
|
|
|
# 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
|
2026-02-18 11:12:14 +01:00
|
|
|
OAPI_CODEGEN := $(GO) run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@latest
|
2026-02-04 14:13:24 +01:00
|
|
|
|
|
|
|
|
# Build flags
|
|
|
|
|
LDFLAGS := -s -w
|
|
|
|
|
BUILD_FLAGS := -ldflags "$(LDFLAGS)"
|
|
|
|
|
|
|
|
|
|
default: run
|
|
|
|
|
|
2026-02-18 11:12:14 +01:00
|
|
|
.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
|
2026-02-04 14:13:24 +01:00
|
|
|
|
|
|
|
|
# Default target
|
|
|
|
|
all: fmt vet lint build
|
|
|
|
|
|
|
|
|
|
## Build targets
|
|
|
|
|
|
2026-02-18 11:12:14 +01:00
|
|
|
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
|
2026-02-04 14:13:24 +01:00
|
|
|
|
|
|
|
|
clean: ## Remove build artifacts
|
2026-02-18 11:12:14 +01:00
|
|
|
rm -f collector receiver coverage.out coverage.html
|
2026-02-04 14:13:24 +01:00
|
|
|
$(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 .
|
|
|
|
|
|
2026-02-18 11:12:14 +01:00
|
|
|
## 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
|
|
|
|
|
|
2026-02-04 14:13:24 +01:00
|
|
|
## 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
|
|
|
|
|
|
2026-02-18 11:12:14 +01:00
|
|
|
run-collector: build-collector ## Build and run the collector
|
|
|
|
|
./collector
|
2026-02-04 14:13:24 +01:00
|
|
|
|
2026-02-18 11:12:14 +01:00
|
|
|
run-receiver: build-receiver ## Build and run the receiver
|
|
|
|
|
./receiver --read-token=secure-read-token --hmac-key=secure-hmac-key
|
2026-02-04 14:13:24 +01:00
|
|
|
|
|
|
|
|
## 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}'
|