-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
103 lines (92 loc) · 4.18 KB
/
Makefile
File metadata and controls
103 lines (92 loc) · 4.18 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
.DEFAULT_GOAL := help
XDEBUG_CLIENT_HOST ?= docker.for.mac.localhost
# ENV_XDEBUG_MODE controls xdebug.mode (develop|profile|debug|off|coverage|...) of the image to run.
ENV_XDEBUG_MODE ?= off
# magic help command
# https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
makefile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
makefile_dir := $(dir $(makefile_path))
docker_image_php_version := 8.1.31-cli-alpine3.21
docker_image_composer_version := 2.7.6
docker_image_version := v1.2.1
docker_image_name_tester := darealfive/bitfield/tester:$(docker_image_version)
docker_image_working_dir := /php_library
## -- DOCKER TESTING
.PHONY: docker-tester-build
docker-tester-build: ## Builds the testing docker image
@printf "\e[1;35m"
@echo "┌──────────────────────────────────────┐"
@echo "│ Building docker image for testing... │"
@echo "└──────────────────────────────────────┘"
@printf "\e[0m"
@DOCKER_BUILDKIT=1 docker build \
--build-arg COMPOSER_VERSION=$(docker_image_composer_version) \
--build-arg PHP_VERSION=$(docker_image_php_version) \
--build-arg WORKING_DIR=$(docker_image_working_dir) \
--build-arg XDEBUG_CLIENT_HOST=$(XDEBUG_CLIENT_HOST) \
-t $(docker_image_name_tester) \
-f test.Dockerfile \
--target tester \
.
.PHONY: docker-tester-run
docker-tester-run: composer-install-dev ## Runs PHP-UNIT tests within a docker container
@printf "\e[1;35m"
@echo "┌───────────────────────────┐"
@echo "│ Running PHP-UNIT tests... │"
@echo "└───────────────────────────┘"
@printf "\e[0m"
@docker run \
--env ENV_XDEBUG_MODE=$(ENV_XDEBUG_MODE) \
--rm \
--volume "$(makefile_dir)":"$(docker_image_working_dir)" \
$(docker_image_name_tester) \
vendor/bin/phpunit tests \
--display-all-issues \
--order-by random
.PHONY: docker-tester-run-coverage
docker-tester-run-coverage: composer-install-dev ## Runs PHP-UNIT tests with code-coverage within a docker container
@printf "\e[1;35m"
@echo "┌───────────────────────────────────────────┐"
@echo "│ Running PHP-UNIT tests + code-coverage... │"
@echo "└───────────────────────────────────────────┘"
@printf "\e[0m"
@docker run \
--env ENV_XDEBUG_MODE=coverage \
--rm \
--volume "$(makefile_dir)":"$(docker_image_working_dir)" \
$(docker_image_name_tester) \
vendor/bin/phpunit tests \
--display-all-issues \
--order-by random \
--coverage-html=$(docker_image_working_dir)/xdebug/coverage \
--coverage-filter=$(docker_image_working_dir)/src
.PHONY: docker-tester-build-run
docker-tester-build-run: docker-tester-build docker-tester-run ## Build and runs PHP-UNIT tests within a docker container
.PHONY: docker-tester-run-shell
docker-tester-run-shell: ## Runs a shell within the testing docker container
@printf "\e[1;35m"
@echo "┌────────────────────┐"
@echo "│ Executing shell... │"
@echo "└────────────────────┘"
@printf "\e[0m"
@docker run \
--env ENV_XDEBUG_MODE=$(ENV_XDEBUG_MODE) \
-it \
--rm \
--volume "$(makefile_dir)":"$(docker_image_working_dir)" \
$(docker_image_name_tester)
.PHONY: composer-install-dev
composer-install-dev: docker-tester-build ## Installs PHP dev dependencies
@printf "\e[1;35m"
@echo "┌────────────────────────────────┐"
@echo "│ Installing DEV dependencies... │"
@echo "└────────────────────────────────┘"
@printf "\e[0m"
@docker run \
--rm \
--volume "$(makefile_dir)":"$(docker_image_working_dir)" \
$(docker_image_name_tester) \
composer install