-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathMakefile
More file actions
151 lines (133 loc) · 5.14 KB
/
Makefile
File metadata and controls
151 lines (133 loc) · 5.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
.PHONY: help
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 all generated files are up to date"
@echo " fmt - Format Go code"
@echo " ci - Run all CI checks locally (fmt, lint, test, verify-generate)"
# Build variables
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
LDFLAGS := -s -w -X 'main.version=$(VERSION)' -X 'main.commit=$(COMMIT)' -X 'main.date=$(DATE)'
.PHONY: build
build:
@echo "Building CLI binary..."
@mkdir -p bin
@go build -ldflags "$(LDFLAGS)" -o bin/openfeature ./cmd/openfeature
@echo "CLI binary built successfully at bin/openfeature (version: $(VERSION))"
.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:
@echo "Running tests..."
@go test -v ./...
@echo "Tests passed successfully!"
# Dagger-based integration tests
.PHONY: test-integration-csharp
test-integration-csharp:
@echo "Running C# integration test with Dagger..."
@go run ./test/integration/cmd/csharp/run.go
.PHONY: test-integration-go
test-integration-go:
@echo "Running Go integration test with Dagger..."
@go run ./test/integration/cmd/go/run.go
.PHONY: test-integration-nodejs
test-integration-nodejs:
@echo "Running NodeJS integration test with Dagger..."
@go run ./test/integration/cmd/nodejs/run.go
.PHONY: test-integration-angular
test-integration-angular:
@echo "Running Angular integration test with Dagger..."
@go run ./test/integration/cmd/angular/run.go
.PHONY: test-integration
test-integration:
@echo "Running all integration tests with Dagger..."
@go run ./test/integration/cmd/run.go
generate-docs:
@echo "Generating documentation..."
@go run ./docs/generate-commands.go
@echo "Documentation generated successfully!"
generate-schema:
@echo "Generating 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 golangci-lint fmt..."
@golangci-lint fmt
@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/v2/cmd/golangci-lint@v2.7.1; \
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/v2/cmd/golangci-lint@v2.7.1; \
fi
@golangci-lint run --fix
@echo "Linting with auto-fix completed successfully!"
.PHONY: verify-generate
verify-generate:
@echo "Checking if all generated files are up-to-date..."
@make generate-api > /dev/null 2>&1
@if [ ! -z "$$(git diff --name-only internal/api/client/)" ]; then \
echo "❌ OpenAPI client needs regeneration"; \
echo " Run: make generate-api"; \
git diff --stat internal/api/client/; \
exit 1; \
fi
@make generate-docs > /dev/null 2>&1
@if [ ! -z "$$(git diff --name-only docs/)" ]; then \
echo "❌ Documentation needs regeneration"; \
echo " Run: make generate-docs"; \
git diff --stat docs/; \
exit 1; \
fi
@make generate-schema > /dev/null 2>&1
@if [ ! -z "$$(git diff --name-only schema/)" ]; then \
echo "❌ Schema needs regeneration"; \
echo " Run: make generate-schema"; \
git diff --stat schema/; \
exit 1; \
fi
@echo "✅ All generated files are up-to-date!"
.PHONY: ci
ci: fmt lint test verify-generate
@echo "✅ All CI checks passed successfully!"