|
1 | | -ifeq ($(OS),Windows_NT) |
2 | | - PWD := $(shell cd) |
3 | | -else |
4 | | - PWD := $(shell pwd -L) |
5 | | -endif |
6 | | - |
| 1 | +PWD := $(CURDIR) |
7 | 2 | ARCH := $(shell uname -m) |
8 | 3 | PLATFORM := |
9 | 4 |
|
10 | 5 | ifeq ($(ARCH),arm64) |
11 | 6 | PLATFORM := --platform=linux/amd64 |
12 | 7 | endif |
13 | 8 |
|
14 | | -DOCKER_RUN = docker run ${PLATFORM} --rm -it --net=host -v ${PWD}:/app -w /app gustavofreze/php:8.3 |
| 9 | +DOCKER_RUN = docker run ${PLATFORM} --rm -it --net=host -v ${PWD}:/app -w /app gustavofreze/php:8.5-alpine |
15 | 10 |
|
16 | | -.PHONY: configure test test-file test-no-coverage review show-reports clean |
| 11 | +RESET := \033[0m |
| 12 | +GREEN := \033[0;32m |
| 13 | +YELLOW := \033[0;33m |
17 | 14 |
|
18 | | -configure: |
| 15 | +.DEFAULT_GOAL := help |
| 16 | + |
| 17 | +.PHONY: configure |
| 18 | +configure: ## Configure development environment |
19 | 19 | @${DOCKER_RUN} composer update --optimize-autoloader |
20 | 20 |
|
21 | | -test: |
| 21 | +.PHONY: test |
| 22 | +test: ## Run all tests with coverage |
22 | 23 | @${DOCKER_RUN} composer tests |
23 | 24 |
|
24 | | -test-file: |
| 25 | +.PHONY: test-file |
| 26 | +test-file: ## Run tests for a specific file (usage: make test-file FILE=path/to/file) |
25 | 27 | @${DOCKER_RUN} composer test-file ${FILE} |
26 | 28 |
|
27 | | -test-no-coverage: |
| 29 | +.PHONY: test-no-coverage |
| 30 | +test-no-coverage: ## Run all tests without coverage |
28 | 31 | @${DOCKER_RUN} composer tests-no-coverage |
29 | 32 |
|
30 | | -review: |
| 33 | +.PHONY: review |
| 34 | +review: ## Run static code analysis |
31 | 35 | @${DOCKER_RUN} composer review |
32 | 36 |
|
33 | | -show-reports: |
| 37 | +.PHONY: show-reports |
| 38 | +show-reports: ## Open static analysis reports (e.g., coverage, lints) in the browser |
34 | 39 | @sensible-browser report/coverage/coverage-html/index.html report/coverage/mutation-report.html |
35 | 40 |
|
36 | | -clean: |
| 41 | +.PHONY: clean |
| 42 | +clean: ## Remove dependencies and generated artifacts |
37 | 43 | @sudo chown -R ${USER}:${USER} ${PWD} |
38 | 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