-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
205 lines (171 loc) · 7.19 KB
/
Copy pathMakefile
File metadata and controls
205 lines (171 loc) · 7.19 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# TelemetryFlow PHP SDK - Makefile
#
# Build and development commands for the TelemetryFlow PHP SDK monorepo.
PRODUCT_NAME := TelemetryFlow PHP SDK
VERSION ?= 1.0.0
TFO_COLLECTOR_VERSION := 1.2.1
OTEL_PHP_SDK_VERSION := 1.0.0
COMPOSER := composer
PHPUNIT := ./vendor/bin/phpunit
PHPSTAN := ./vendor/bin/phpstan
CS_FIXER := ./vendor/bin/php-cs-fixer
INFECTION := ./vendor/bin/infection
GREEN := \033[0;32m
YELLOW := \033[0;33m
RED := \033[0;31m
BLUE := \033[0;34m
NC := \033[0m
.PHONY: help install update test test-core test-laravel test-generator test-coverage stan stan-fix cs-fix cs-check mutate clean build version ci release-check docker-build docker-push docker-gen docker-example docker-dev docker-up docker-down docker-full docker-e2e phar
# Default target
all: build
help:
@echo "$(GREEN)$(PRODUCT_NAME) - Build System$(NC)"
@echo ""
@echo "$(YELLOW)Setup:$(NC)"
@echo " make install - Install all monorepo dependencies"
@echo " make update - Update dependencies"
@echo ""
@echo "$(YELLOW)Testing:$(NC)"
@echo " make test - Run all package test suites"
@echo " make test-core - Run php-native tests"
@echo " make test-laravel - Run Laravel package tests"
@echo " make test-generator - Run generator tests"
@echo " make test-coverage - Run tests with coverage"
@echo " make mutate - Run mutation testing"
@echo ""
@echo "$(YELLOW)Code Quality:$(NC)"
@echo " make stan - Run PHPStan static analysis"
@echo " make cs-fix - Fix code style (PHP-CS-Fixer)"
@echo " make cs-check - Check code style (CI)"
@echo " make check - Run all checks (cs + stan + test)"
@echo ""
@echo "$(YELLOW)Build:$(NC)"
@echo " make build - Validate and prepare packages"
@echo " make phar - Build standalone telemetryflow-gen.phar"
@echo " make clean - Clean build artifacts"
@echo " make version - Show version information"
@echo " make ci - Run CI pipeline"
@echo ""
@echo "$(YELLOW)Docker:$(NC)"
@echo " make docker-build - Build the SDK Docker image"
@echo " make docker-push - Build and push the image to the registry"
@echo " make docker-gen - Run the generator CLI in Docker"
@echo " make docker-example - Generate a basic example in Docker"
@echo " make docker-dev - Start the dev container + collector"
@echo " make docker-up - Start collector (dev profile)"
@echo " make docker-full - Start collector + Prometheus"
@echo " make docker-down - Stop all Docker services"
@echo " make docker-e2e - Run end-to-end tests in Docker"
@echo ""
## Setup
install:
@echo "$(GREEN)Installing monorepo dependencies...$(NC)"
@$(COMPOSER) install --no-interaction
@echo "$(GREEN)Dependencies installed$(NC)"
update:
@echo "$(GREEN)Updating dependencies...$(NC)"
@$(COMPOSER) update --no-interaction
@echo "$(GREEN)Dependencies updated$(NC)"
## Testing
test: test-core test-laravel test-generator
@echo "$(GREEN)All tests completed$(NC)"
test-core:
@echo "$(GREEN)Running php-native tests...$(NC)"
@$(PHPUNIT) --configuration packages/php-native/phpunit.xml.dist
test-laravel:
@echo "$(GREEN)Running Laravel tests...$(NC)"
@$(PHPUNIT) --configuration packages/laravel/phpunit.xml.dist
test-generator:
@echo "$(GREEN)Running generator tests...$(NC)"
@$(PHPUNIT) --configuration packages/generator/phpunit.xml.dist
test-coverage:
@echo "$(GREEN)Running tests with coverage...$(NC)"
@mkdir -p build
@$(PHPUNIT) --configuration packages/php-native/phpunit.xml.dist --coverage-clover build/coverage-core.xml
@$(PHPUNIT) --configuration packages/laravel/phpunit.xml.dist --coverage-clover build/coverage-laravel.xml
@echo "$(GREEN)Coverage reports generated in build/$(NC)"
## Code quality
stan:
@echo "$(GREEN)Running PHPStan...$(NC)"
@$(PHPSTAN) analyse packages/php-native/src packages/laravel/src packages/generator/src --level=6
@echo "$(GREEN)PHPStan complete$(NC)"
cs-fix:
@echo "$(GREEN)Fixing code style...$(NC)"
@$(CS_FIXER) fix --allow-risky=yes
@echo "$(GREEN)Code style fixed$(NC)"
cs-check:
@echo "$(GREEN)Checking code style...$(NC)"
@$(CS_FIXER) check --allow-risky=yes
@echo "$(GREEN)Code style check complete$(NC)"
mutate:
@echo "$(GREEN)Running mutation testing...$(NC)"
@$(INFECTION) --threads=max
@echo "$(GREEN)Mutation testing complete$(NC)"
check: cs-check stan test
@echo "$(GREEN)All checks passed$(NC)"
## Build
build:
@echo "$(GREEN)Validating packages...$(NC)"
@$(COMPOSER) validate --strict --no-check-all
@$(COMPOSER) dump-autoload --optimize
@echo "$(GREEN)Build complete$(NC)"
clean:
@echo "$(GREEN)Cleaning build artifacts...$(NC)"
@rm -rf build/ dist/ _generated/ .phpunit.cache/ .phpunit.result.cache
@rm -f coverage*.xml coverage*.html clover.xml infection.log
@find . -type d -name vendor -prune -exec rm -rf {} +
@echo "$(GREEN)Clean complete$(NC)"
ci: install check
@echo "$(GREEN)CI pipeline completed$(NC)"
release-check: check
@echo "$(GREEN)Release checks passed$(NC)"
## Version info
version:
@echo "$(GREEN)$(PRODUCT_NAME)$(NC)"
@echo " Version: $(VERSION)"
@echo " TFO-Collector: $(TFO_COLLECTOR_VERSION)"
@echo " OpenTelemetry PHP: $(OTEL_PHP_SDK_VERSION)"
@echo ""
@echo "$(YELLOW)Packages:$(NC)"
@echo " - packages/php-native (framework-agnostic core)"
@echo " - packages/laravel (Laravel integration)"
@echo " - packages/generator (Symfony Console CLI)"
## Phar (standalone generator)
phar:
@echo "$(GREEN)Building telemetryflow-gen.phar...$(NC)"
@mkdir -p build
@php -d phar.readonly=0 packages/generator/bin/build-phar.php
@echo "$(GREEN)Phar built: build/telemetryflow-gen.phar$(NC)"
## Docker
docker-build:
@echo "$(GREEN)Building SDK Docker image...$(NC)"
@docker build --build-arg VERSION=$(VERSION) -t telemetryflow/telemetryflow-php-sdk:$(VERSION) -t telemetryflow/telemetryflow-php-sdk:latest .
@echo "$(GREEN)Docker image built$(NC)"
docker-push: docker-build
@echo "$(GREEN)Pushing Docker image...$(NC)"
@docker push telemetryflow/telemetryflow-php-sdk:$(VERSION)
@docker push telemetryflow/telemetryflow-php-sdk:latest
@echo "$(GREEN)Docker image pushed$(NC)"
docker-gen:
@echo "$(GREEN)Running telemetryflow-gen in Docker...$(NC)"
@docker run --rm -v $(PWD):/workspace telemetryflow/telemetryflow-php-sdk:$(VERSION) --help
docker-example:
@echo "$(GREEN)Generating basic example in Docker...$(NC)"
@mkdir -p workspace
@docker run --rm -v $(PWD)/workspace:/workspace telemetryflow/telemetryflow-php-sdk:$(VERSION) example basic --output /workspace/example
docker-dev:
@echo "$(GREEN)Starting dev container + OTLP collector...$(NC)"
@docker-compose --profile dev up -d
docker-up:
@echo "$(GREEN)Starting OTLP collector (dev profile)...$(NC)"
@docker-compose --profile dev up -d otel-collector
docker-full:
@echo "$(GREEN)Starting full observability stack (collector + Prometheus)...$(NC)"
@docker-compose --profile full up -d
docker-down:
@echo "$(GREEN)Stopping all Docker services...$(NC)"
@docker-compose --profile dev --profile full --profile example down
docker-e2e:
@echo "$(GREEN)Running end-to-end tests in Docker...$(NC)"
@docker-compose -f docker-compose.e2e.yml up --abort-on-container-exit --exit-code-from e2e --build
.DEFAULT_GOAL := help