-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
73 lines (59 loc) · 2.1 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
VENDOR ?= "../../../../vendor"
export PATH := $(HOME)/.composer/vendor/bin:$(PATH)
## As an alternative for linting PHP we can also setup `friendsofphp/php-cs-fixer` which is popular package
## More info: https://github.com/FriendsOfPHP/PHP-CS-Fixer
COLOR_RESET = \033[0m
COLOR_INFO = \033[32m
COLOR_COMMENT = \033[33m
## Help
help:
@printf "${COLOR_COMMENT}Usage:${COLOR_RESET}\n"
@printf " make [target]\n\n"
@printf "${COLOR_COMMENT}Available targets:${COLOR_RESET}\n"
@awk '/^[a-zA-Z\-\_0-9\.@]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")); \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
printf " ${COLOR_INFO}%-16s${COLOR_RESET} %s\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)
#######################
# Package installation
#######################
install:
@echo " $(P) Installing dependencies"
composer global require "squizlabs/php_codesniffer=*"
sudo apt update; sudo apt install make inotify-tools -y
#######################
# LINTING TASKS
# * PHP Code Sniffer
# * PHP Code Beautifier and Fixer
#######################
## Display formatting issues in detail
lint:
phpcs
## Display a summary of formatting issues
lint-summary:
phpcs --report=summary
## Automatically fix code formatting issues
lint-fix:
phpcbf
#######################
# PHPUnit
#######################
## Launch PHPUnit
unit:
@echo " $(P) Start unit tests"
@$(VENDOR)/bin/phpunit -c $(VENDOR)/typo3/testing-framework/Resources/Core/Build/UnitTests.xml Tests/Unit
## Launch PHPUnit with code coverage
unit-coverage:
@echo " $(P) Start unit tests with code coverage"
@echo
@$(VENDOR)/bin/phpunit -c $(VENDOR)/typo3/testing-framework/Resources/Core/Build/UnitTests.xml --whitelist $(PWD)/Classes/ --coverage-html .build Tests/Unit
## Watch unit tests or classes files and launch tests when anything changed
watch-unit:
@echo " $(P) Start unit tests"
@while inotifywait -e close_write Tests/Unit/* -e close_write Classes/*; do make unit; done
.PHONY: help clean build unit unit-coverage watch-unit install