Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,8 @@ generated/
# generated files from running the CLI
flags.json
generated/

openfeature

# Build output directory
/bin
71 changes: 70 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,37 @@
help:
@echo "Available commands:"
@echo " help - Show this help message"
@echo " build - Build the CLI binary to bin/openfeature"
@echo " install - Install the CLI binary to system path"
@echo " lint - Run golangci-lint"
@echo " lint-fix - Run golangci-lint with auto-fix"
@echo " test - Run unit tests"
@echo " test-integration - Run all integration tests"
@echo " test-integration-csharp - Run C# integration tests"
@echo " test-integration-go - Run Go integration tests"
@echo " test-integration-nodejs - Run NodeJS integration tests"
@echo " generate - Generate all code (API clients, docs, schema)"
@echo " generate-api - Generate API clients from OpenAPI specs"
@echo " generate-docs - Generate documentation"
@echo " generate-schema - Generate schema"
@echo " verify-generate - Check if generated files are up to date"
@echo " fmt - Format Go code"
@echo " ci - Run all CI checks locally (lint, test, verify-generate)"

.PHONY: build
build:
@echo "Building CLI binary..."
@mkdir -p bin
@go build -o bin/openfeature ./cmd/openfeature
@echo "CLI binary built successfully at bin/openfeature"

.PHONY: install
install: build
@echo "Installing CLI binary..."
@GOPATH=$${GOPATH:-$$(go env GOPATH)}; \
mkdir -p $$GOPATH/bin; \
cp bin/openfeature $$GOPATH/bin/openfeature; \
echo "CLI installed successfully to $$GOPATH/bin/openfeature"

.PHONY: test
test:
Expand Down Expand Up @@ -48,8 +71,54 @@ generate-schema:
@go run ./schema/generate-schema.go
@echo "Schema generated successfully!"

.PHONY: generate-api
generate-api:
@echo "Generating API clients from OpenAPI specs..."
@go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@latest \
--config api/v0/sync-codegen.yaml \
api/v0/sync.yaml > internal/api/client/sync_client.gen.go
@echo "API clients generated successfully!"

.PHONY: generate
generate: generate-api generate-docs generate-schema
@echo "All code generation completed successfully!"

.PHONY: fmt
fmt:
@echo "Running go fmt..."
@go fmt ./...
@echo "Code formatted successfully!"
@echo "Code formatted successfully!"

.PHONY: lint
lint:
@echo "Running golangci-lint..."
@if ! command -v golangci-lint &> /dev/null; then \
echo "Installing golangci-lint..."; \
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.0; \
fi
@golangci-lint run ./...
@echo "Linting completed successfully!"

.PHONY: lint-fix
lint-fix:
@echo "Running golangci-lint with auto-fix..."
@if ! command -v golangci-lint &> /dev/null; then \
echo "Installing golangci-lint..."; \
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.0; \
fi
@golangci-lint run --fix ./...
@echo "Linting with auto-fix completed successfully!"

.PHONY: verify-generate
verify-generate: generate
@echo "Checking for uncommitted changes after generation..."
@if [ ! -z "$$(git status --porcelain)" ]; then \
echo "Error: Generation produced diff. Please run 'make generate' and commit the results."; \
git diff; \
exit 1; \
fi
@echo "All generated files are up to date!"

.PHONY: ci
ci: lint test verify-generate
@echo "All CI checks passed successfully!"
6 changes: 6 additions & 0 deletions api/v0/sync-codegen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# oapi-codegen configuration for sync API client generation
package: syncclient
generate:
- client
- models
output: internal/api/client/sync_client.gen.go
Loading
Loading