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>
This commit is contained in:
parent
479c13f596
commit
bc9d0dd8ea
11 changed files with 2245 additions and 252 deletions
34
Makefile
34
Makefile
|
|
@ -1,11 +1,10 @@
|
|||
# ABOUTME: Makefile for forgejo-runner-sizer project.
|
||||
# ABOUTME: Provides targets for building, formatting, linting, and testing.
|
||||
|
||||
BINARY_NAME := sizer
|
||||
CMD_PATH := ./cmd/collector
|
||||
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
|
||||
|
|
@ -13,18 +12,23 @@ BUILD_FLAGS := -ldflags "$(LDFLAGS)"
|
|||
|
||||
default: run
|
||||
|
||||
.PHONY: all build clean fmt format lint gitleaks test run help vet tidy install-hooks
|
||||
.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 the binary
|
||||
$(GO) build $(BUILD_FLAGS) -o $(BINARY_NAME) $(CMD_PATH)
|
||||
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 $(BINARY_NAME) coverage.out coverage.html
|
||||
rm -f collector receiver coverage.out coverage.html
|
||||
$(GO) clean
|
||||
|
||||
## Code quality targets
|
||||
|
|
@ -46,6 +50,16 @@ gitleaks: ## Check for secrets in git history
|
|||
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
|
||||
|
|
@ -62,11 +76,11 @@ test-coverage: ## Run tests with coverage
|
|||
|
||||
## Run targets
|
||||
|
||||
run: build ## Build and run with default settings
|
||||
./$(BINARY_NAME)
|
||||
run-collector: build-collector ## Build and run the collector
|
||||
./collector
|
||||
|
||||
run-text: build ## Build and run with text output format
|
||||
./$(BINARY_NAME) --log-format text --interval 2s
|
||||
run-receiver: build-receiver ## Build and run the receiver
|
||||
./receiver --read-token=secure-read-token --hmac-key=secure-hmac-key
|
||||
|
||||
## Git hooks
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue