feat: implement gRPC Greeter service with example proto and enhance makefile
Some checks failed
🧪✨ Tests Workflow / 🧪 ✨ Database Migrations (push) Failing after 18s
🧪✨ Tests Workflow / 🛡️ 🔒 Library Audit (push) Failing after 30s
🧪✨ Tests Workflow / 📝 ✨ Code Lint (push) Failing after 19s
🧪✨ Tests Workflow / 🐙 🔍 Code Sniffer (push) Failing after 13s
🧪✨ Tests Workflow / 🧪 ✅ Unit Tests (push) Failing after 3s
🧪✨ Tests Workflow / 🛡️ 🔒 License Check (push) Failing after 23s

This commit is contained in:
2025-12-04 00:04:57 -05:00
parent 373035d2cc
commit 18a182f3cd
10 changed files with 333 additions and 51 deletions

151
makefile
View File

@@ -1,59 +1,120 @@
help:
# Makefile (enhanced)
SHELL := /bin/sh
.DEFAULT_GOAL := help
# Reusable vars
DOCKER := docker compose
COMPOSER_RUNTIME := composer-runtime
DEV_RUNTIME := dev-runtime
MIGRATION_CONTAINER := migration-container
PROTOC_GEN_DIR := ./protoc-gen-php-grpc-2025.1.5-darwin-arm64
PROTOC_GEN := $(PROTOC_GEN_DIR)/protoc-gen-php-grpc
PROTOC_URL := https://github.com/roadrunner-server/roadrunner/releases/download/v2025.1.5/protoc-gen-php-grpc-2025.1.5-darwin-arm64.tar.gz
COMPOSER := $(DOCKER) exec $(COMPOSER_RUNTIME) sh -c
DEV := $(DOCKER) exec $(DEV_RUNTIME) sh -c
# Colors
GREEN := \033[32m
YELLOW := \033[33m
RESET := \033[0m
# Align width for help display
HELP_COL_WIDTH := 26
# Help: auto-generate from targets with "##" comments
help: ## Show this help
@echo "Available commands:"
@echo " start - Start the development runtime container"
@echo " sh - Open a shell in the development runtime container"
@echo " run - Run the application server in the development runtime container"
@echo " stop - Stop and remove the development runtime container"
@echo " migrate - Run database migrations in the migration container"
@echo " composer-install - Install PHP dependencies in the composer runtime container"
@echo " composer-require - Require a PHP package in the composer runtime container (usage: make composer-require package=vendor/package)"
@echo " composer-require-dev - Require a PHP package as dev in the composer runtime container (usage: make composer-require-dev package=vendor/package)"
@echo " composer-update - Update PHP dependencies in the composer runtime container"
@echo " enable-debug - Enable Xdebug in the development runtime container"
@echo " enable-coverage - Enable PCOV code coverage in the composer runtime container"
@echo " protoc - Generate PHP gRPC code from .proto files"
@awk -F':|##' '/^[a-zA-Z0-9._-]+:.*##/ {printf " %-$(HELP_COL_WIDTH)s - %s\n", $$1, $$3}' $(MAKEFILE_LIST) | sort
composer-install:
docker compose exec composer-runtime sh -c "composer install --no-interaction --prefer-dist --optimize-autoloader --ignore-platform-reqs"
start: ## Start the development runtime container
@printf "$(GREEN)Starting $(DEV_RUNTIME)$(RESET)\n"
$(DOCKER) up $(DEV_RUNTIME) -d --no-recreate
composer-require:
docker compose exec composer-runtime sh -c "composer require $(package) --ignore-platform-reqs"
sh: ## Open a shell in the development runtime container
@$(MAKE) start
$(DOCKER) exec $(DEV_RUNTIME) sh
composer-require-dev:
docker compose exec composer-runtime sh -c "composer require --dev $(package) --ignore-platform-reqs"
run: ## Run the application server in the development runtime container
@$(MAKE) start
$(DEV) "rr serve"
composer-update:
docker compose exec composer-runtime sh -c "composer update --no-interaction --prefer-dist --optimize-autoloader --ignore-platform-reqs"
stop: ## Stop and remove the development runtime container
@printf "$(YELLOW)Stopping all containers$(RESET)\n"
$(DOCKER) down
migrate:
docker compose up migration-container
restart: ## Restart dev container (stop + start)
@$(MAKE) stop
@$(MAKE) start
enable-coverage:
${MAKE} start
docker compose exec composer-runtime sh -c "bin/pcov.sh"
rebuild: ## Rebuild containers (useful after Dockerfile changes)
@printf "$(YELLOW)Rebuilding containers$(RESET)\n"
$(DOCKER) build
$(DOCKER) up --force-recreate --build -d
start:
docker compose up dev-runtime -d --no-recreate
ps: ## Show docker compose ps
$(DOCKER) ps
sh:
${MAKE} start
docker compose exec dev-runtime sh
migrate: ## Run database migrations in the migration container
$(DOCKER) up $(MIGRATION_CONTAINER)
run:
${MAKE} start
docker compose exec dev-runtime sh -c "rr serve"
# Composer helpers
composer-install: ## Install PHP dependencies in the composer runtime container
$(COMPOSER) "composer install --no-interaction --prefer-dist --optimize-autoloader --ignore-platform-reqs"
enable-debug:
${MAKE} start
docker compose exec dev-runtime sh -c "bin/xdebug.sh"
composer-require: ## Require a PHP package in the composer runtime container (usage: make composer-require package=vendor/package)
ifndef package
$(error package variable is required: make composer-require package=vendor/package)
endif
$(COMPOSER) "composer require $(package) --ignore-platform-reqs"
stop:
docker compose down
composer-require-dev: ## Require a PHP package as dev in the composer runtime container (usage: make composer-require-dev package=vendor/package)
ifndef package
$(error package variable is required: make composer-require-dev package=vendor/package)
endif
$(COMPOSER) "composer require --dev $(package) --ignore-platform-reqs"
protoc:
protoc --plugin=protoc-gen-php-grpc \
--php_out=./generated \
--php-grpc_out=./generated \
protos/example.proto
composer-update: ## Update PHP dependencies in the composer runtime container
$(COMPOSER) "composer update --no-interaction --prefer-dist --optimize-autoloader --ignore-platform-reqs"
.PHONY: help enable-coverage start sh run enable-debug stop protoc
enable-debug: ## Enable Xdebug in the development runtime container
@$(MAKE) start
$(DEV) "bin/xdebug.sh"
enable-coverage: ## Enable PCOV code coverage in the composer runtime container
@$(MAKE) start
$(COMPOSER) "bin/pcov.sh"
protoc: ## Generate PHP gRPC code from .proto files
@printf "$(GREEN)Setting up protoc-gen-php-grpc plugin$(RESET)\n"
@curl -LOs $(PROTOC_URL)
@tar -xzf protoc-gen-php-grpc-2025.1.5-darwin-arm64.tar.gz
@printf "$(GREEN)Generating PHP gRPC code from .proto files$(RESET)\n"
@protoc --plugin=./protoc-gen-php-grpc-2025.1.5-darwin-arm64/protoc-gen-php-grpc \
--php_out=./generated \
--php-grpc_out=./generated \
protos/example.proto
@printf "$(GREEN)Cleaning up protoc-gen-php-grpc plugin files$(RESET)\n"
@rm -rf $(PROTOC_GEN_DIR) protoc-gen-php-grpc-2025.1.5-darwin-arm64.tar.gz
# Developer tasks
lint: ## Run linting (phpcs/phpstan) in composer runtime
@$(DOCKER) up $(COMPOSER_RUNTIME) -d --no-recreate
$(COMPOSER) "composer run-script tests:lint || true"
$(COMPOSER) "composer run-script tests:phpstan || true"
fmt: ## Format code (php-cs-fixer)
@$(DOCKER) up $(COMPOSER_RUNTIME) -d --no-recreate
$(COMPOSER) "composer run-script tests:lint:fix"
test: ## Run test suite (phpunit)
$(COMPOSER) "composer run-script tests:unit || true"
# Convenience aliases
dev: run ## Alias for start
ci: composer-install test ## CI-like local flow
down: stop ## Alias for stop
up: start ## Alias for start
.PHONY: help start sh run stop restart rebuild ps logs migrate composer-install composer-require composer-require-dev composer-update enable-debug enable-coverage protoc lint fmt test check-lock dev ci