|
| 1 | +PWD := $(CURDIR) |
| 2 | +ARCH := $(shell uname -m) |
| 3 | +PLATFORM := |
| 4 | + |
| 5 | +ifeq ($(ARCH),arm64) |
| 6 | + PLATFORM := --platform=linux/amd64 |
| 7 | +endif |
| 8 | + |
| 9 | +DOCKER_RUN = docker run ${PLATFORM} --rm -it --net=host -v ${PWD}:/app -w /app gustavofreze/php:8.5-alpine |
| 10 | + |
| 11 | +RESET := \033[0m |
| 12 | +GREEN := \033[0;32m |
| 13 | +YELLOW := \033[0;33m |
| 14 | + |
| 15 | +.DEFAULT_GOAL := help |
| 16 | + |
| 17 | +.PHONY: configure |
| 18 | +configure: ## Configure development environment |
| 19 | + @${DOCKER_RUN} composer update --optimize-autoloader |
| 20 | + |
| 21 | +.PHONY: test |
| 22 | +test: ## Run all tests with coverage |
| 23 | + @${DOCKER_RUN} composer tests |
| 24 | + |
| 25 | +.PHONY: test-file |
| 26 | +test-file: ## Run tests for a specific file (usage: make test-file FILE=path/to/file) |
| 27 | + @${DOCKER_RUN} composer test-file ${FILE} |
| 28 | + |
| 29 | +.PHONY: test-no-coverage |
| 30 | +test-no-coverage: ## Run all tests without coverage |
| 31 | + @${DOCKER_RUN} composer tests-no-coverage |
| 32 | + |
| 33 | +.PHONY: review |
| 34 | +review: ## Run static code analysis |
| 35 | + @${DOCKER_RUN} composer review |
| 36 | + |
| 37 | +.PHONY: show-reports |
| 38 | +show-reports: ## Open static analysis reports (e.g., coverage, lints) in the browser |
| 39 | + @sensible-browser report/coverage/coverage-html/index.html report/coverage/mutation-report.html |
| 40 | + |
| 41 | +.PHONY: clean |
| 42 | +clean: ## Remove dependencies and generated artifacts |
| 43 | + @sudo chown -R ${USER}:${USER} ${PWD} |
| 44 | + @rm -rf report vendor .phpunit.cache *.lock |
| 45 | + |
| 46 | +.PHONY: help |
| 47 | +help: ## Display this help message |
| 48 | + @echo "Usage: make [target]" |
| 49 | + @echo "" |
| 50 | + @echo "$$(printf '$(GREEN)')Setup$$(printf '$(RESET)')" |
| 51 | + @grep -E '^(configure):.*?## .*$$' $(MAKEFILE_LIST) \ |
| 52 | + | awk 'BEGIN {FS = ":.*? ## "}; {printf "$(YELLOW)%-25s$(RESET) %s\n", $$1, $$2}' |
| 53 | + @echo "" |
| 54 | + @echo "$$(printf '$(GREEN)')Testing$$(printf '$(RESET)')" |
| 55 | + @grep -E '^(test|test-file|test-no-coverage):.*?## .*$$' $(MAKEFILE_LIST) \ |
| 56 | + | awk 'BEGIN {FS = ":.*?## "}; {printf "$(YELLOW)%-25s$(RESET) %s\n", $$1, $$2}' |
| 57 | + @echo "" |
| 58 | + @echo "$$(printf '$(GREEN)')Quality$$(printf '$(RESET)')" |
| 59 | + @grep -E '^(review):.*?## .*$$' $(MAKEFILE_LIST) \ |
| 60 | + | awk 'BEGIN {FS = ":.*?## "}; {printf "$(YELLOW)%-25s$(RESET) %s\n", $$1, $$2}' |
| 61 | + @echo "" |
| 62 | + @echo "$$(printf '$(GREEN)')Reports$$(printf '$(RESET)')" |
| 63 | + @grep -E '^(show-reports):.*?## .*$$' $(MAKEFILE_LIST) \ |
| 64 | + | awk 'BEGIN {FS = ":.*?## "}; {printf "$(YELLOW)%-25s$(RESET) %s\n", $$1, $$2}' |
| 65 | + @echo "" |
| 66 | + @echo "$$(printf '$(GREEN)')Cleanup$$(printf '$(RESET)')" |
| 67 | + @grep -E '^(clean):.*?## .*$$' $(MAKEFILE_LIST) \ |
| 68 | + | awk 'BEGIN {FS = ":.*?## "}; {printf "$(YELLOW)%-25s$(RESET) %s\n", $$1, $$2}' |
0 commit comments