-
Notifications
You must be signed in to change notification settings - Fork 7
/
makefile
137 lines (108 loc) · 5.69 KB
/
makefile
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
.PHONY: help
.DEFAULT_GOAL := help
# -------------------------------------------------------
# minimum php version to use PHPUnuhi
PHP_MIN_VERSION := $(shell php -f php_min_version.php -- --echo)
# minimum code coverage for unit tests in PHPUnit
PHPUNIT_MIN_COVERAGE := 38
# This is the main score indicator across the whole source code.
MUTANTS_MIN_MSI := 90
# This is the score for code that is actually covered by tests. This shows you how effective the tests really are.
MUTANTS_MIN_COVERED_MSI := 90
# -------------------------------------------------------
#------------------------------------------------------------------------------------------------
help:
@echo ""
@echo ""
@echo "PHPUNUHI PROJECT"
@echo "--------------------------------------------------------------------------------------------"
@echo " * PHP_MIN_VERSION: $(PHP_MIN_VERSION)"
@echo ""
@echo ""
@echo "PROJECT COMMANDS"
@echo "--------------------------------------------------------------------------------------------"
@printf "\033[33mInstallation:%-30s\033[0m %s\n"
@grep -E '^[a-zA-Z_-]+:.*?##1 .*$$' $(firstword $(MAKEFILE_LIST)) | awk 'BEGIN {FS = ":.*?##1 "}; {printf "\033[33m - %-30s\033[0m %s\n", $$1, $$2}'
@echo "--------------------------------------------------------------------------------------------"
@printf "\033[36mDevelopment:%-30s\033[0m %s\n"
@grep -E '^[a-zA-Z_-]+:.*?##2 .*$$' $(firstword $(MAKEFILE_LIST)) | awk 'BEGIN {FS = ":.*?##2 "}; {printf "\033[36m - %-30s\033[0m %s\n", $$1, $$2}'
@echo "--------------------------------------------------------------------------------------------"
@printf "\033[32mTests:%-30s\033[0m %s\n"
@grep -E '^[a-zA-Z_-]+:.*?##3 .*$$' $(firstword $(MAKEFILE_LIST)) | awk 'BEGIN {FS = ":.*?##3 "}; {printf "\033[32m - %-30s\033[0m %s\n", $$1, $$2}'
@echo "--------------------------------------------------------------------------------------------"
@printf "\033[35mDevOps:%-30s\033[0m %s\n"
@grep -E '^[a-zA-Z_-]+:.*?##4 .*$$' $(firstword $(MAKEFILE_LIST)) | awk 'BEGIN {FS = ":.*?##4 "}; {printf "\033[35m - %-30s\033[0m %s\n", $$1, $$2}'
#------------------------------------------------------------------------------------------------
prod: ##1 Installs all prod dependencies
composer validate
composer install --no-dev
dev: ##1 Installs all dev dependencies
composer validate
composer install --ignore-platform-req=ext-intl
clean: ##1 Clears all dependencies
rm -rf vendor/*
rm -rf .reports
rm -rf .svrunit
rm -rf .build
build: ##1 Builds PHPUnuhi and creates phpunuhi.phar
@echo "===================================================================="
@echo "verifying if phar files can be created....phar.readonly has to be OFF"
@php -i | grep phar.readonly
@php -i | grep "Loaded Configuration"
@cd devops/scripts && php build.php
#------------------------------------------------------------------------------------------------
pr: ##2 Runs and prepares everything for a pull request
php vendor/bin/rector process
PHP_CS_FIXER_IGNORE_ENV=1 php ./vendor/bin/php-cs-fixer fix --config=./.php_cs.php
@make phpcheck -B
@make phpmin -B
@make stan -B
@make phpmnd -B
@make phpunit -B
@make infection -B
phpunit-debug: ##2 Debug the unit test with group "debug"
XDEBUG_MODE=coverage php ./vendor/bin/phpunit -v --group debug
#------------------------------------------------------------------------------------------------
phpcheck: ##3 Starts the PHP syntax checks
@find ./src -name '*.php' | xargs -n 1 -P4 php -l
phpmin: ##3 Starts the PHP compatibility checks
@php vendor/bin/phpcs -p --standard=PHPCompatibility --extensions=php --runtime-set testVersion $(PHP_MIN_VERSION) ./src
csfix: ##3 Starts the PHP CS Fixer
PHP_CS_FIXER_IGNORE_ENV=1 php ./vendor/bin/php-cs-fixer fix --config=./.php_cs.php --dry-run
stan: ##3 Starts the PHPStan Analyser
php ./vendor/bin/phpstan analyse --memory-limit 1G -c ./.phpstan.neon
phpmnd: ##3 Runs the checks for magic numbers
php ./vendor/bin/phpmnd ./src
rector: ##3 Runs the Rector checks in dry run
php vendor/bin/rector process --dry-run
arkitect: ##3 Starts the PHPArkitect Analyser
php ./vendor/bin/phparkitect check
phpunit: ##3 Runs all tests
XDEBUG_MODE=coverage php ./vendor/bin/phpunit -v --coverage-html ./.reports/phpunit/coverage --coverage-clover ./.reports/phpunit/clover/index.xml
php vendor/bin/coverage-check ./.reports/phpunit/clover/index.xml $(PHPUNIT_MIN_COVERAGE)
infection: ##3 Starts all Infection/Mutation tests
rm -rf ./.reports/infection
@XDEBUG_MODE=coverage php vendor/bin/infection --configuration=./infection.json --min-msi=$(MUTANTS_MIN_MSI) --min-covered-msi=$(MUTANTS_MIN_COVERED_MSI) --threads=4 --log-verbosity=all --debug
svrunit: ##3 Runs all SVRUnit tests
php vendor/bin/svrunit test --configuration=./svrunit.xml --debug --report-junit --report-html
#------------------------------------------------------------------------------------------------
check-release: ##4 Checks if everything is valid to release the provided version
ifndef version
$(error version is not set)
endif
@echo ""
@echo "Checking release for version $(version)"
@echo "--------------------------------------------------------"
@php tests/scripts/check_composer_version.php $(version)
@composer validate
@php tests/scripts/check_xsd.php $(version)
artifact: ##4 Create a ZIP file in the build folder
cd .build && zip phpunuhi.zip phpunuhi.phar
docker: ##4 Builds the Docker image
ifndef version
$(error version is not set)
endif
rm -f ./devops/docker_release/phpunuhi.phar || true
docker rmi -f $(shell docker images boxblinkracer/phpunuhi -q) || true
cp ./.build/phpunuhi.phar ./devops/docker_release/phpunuhi.phar
cd ./devops/docker_release && DOCKER_BUILDKIT=1 docker build --no-cache -t boxblinkracer/phpunuhi:$(version) .