-
-
Notifications
You must be signed in to change notification settings - Fork 225
/
Makefile
87 lines (75 loc) · 3.93 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
DOCKER_PHP_EXEC := docker compose run --rm php
SRCS := $(shell find ./src ./test -type f -not -path "*/tmp/*")
LOCAL_BASE_BRANCH ?= $(shell git show-branch | sed "s/].*//" | grep "\*" | grep -v "$$(git rev-parse --abbrev-ref HEAD)" | head -n1 | sed "s/^.*\[//")
ifeq ($(strip $(LOCAL_BASE_BRANCH)),)
LOCAL_BASE_BRANCH := HEAD^
endif
BASE_BRANCH ?= $(LOCAL_BASE_BRANCH)
all: csfix static-analysis code-coverage
@echo "Done."
.env: /etc/passwd /etc/group Makefile
printf "USER_ID=%s\nGROUP_ID=%s\n" `id --user "${USER}"` `id --group "${USER}"` > .env
vendor: .env docker-compose.yml Dockerfile composer.json
docker compose build --pull
$(DOCKER_PHP_EXEC) composer update
$(DOCKER_PHP_EXEC) composer bump
touch --no-create $@
mkdir --parents .build-cache
.PHONY: csfix
csfix: vendor
$(DOCKER_PHP_EXEC) vendor/bin/phpcbf || true
$(DOCKER_PHP_EXEC) vendor/bin/phpcs --cache=.build-cache/phpcs
.PHONY: static-analysis
static-analysis: vendor
$(DOCKER_PHP_EXEC) php -d zend.assertions=1 vendor/bin/phpstan --memory-limit=512M $(PHPSTAN_ARGS)
coverage/junit.xml: vendor $(SRCS)
$(DOCKER_PHP_EXEC) php -d zend.assertions=1 \
-d pcov.enabled=1 \
vendor/bin/phpunit \
--coverage-clover=coverage/clover.xml \
--coverage-xml=coverage/xml \
--coverage-html=coverage/html \
--log-junit=$@ \
$(PHPUNIT_ARGS) \
|| (rm $@ && exit 1)
.PHONY: test
test: coverage/junit.xml
.PHONY: code-coverage
code-coverage: coverage/junit.xml
echo "Base branch: $(BASE_BRANCH)"
$(DOCKER_PHP_EXEC) php -d zend.assertions=1 \
-d pcov.enabled=1 \
vendor/bin/infection run \
--threads=$(shell nproc) \
--git-diff-lines \
--git-diff-base=$(BASE_BRANCH) \
--skip-initial-tests \
--initial-tests-php-options="'-d' 'pcov.enabled=1'" \
--coverage=coverage \
--show-mutations \
--verbose \
--ignore-msi-with-no-mutations \
--min-msi=100 \
$(INFECTION_ARGS)
.PHONY: clean
clean:
git clean -dfX
docker compose down --remove-orphans
.PHONY: regenerate-fixture-results
regenerate-fixture-results: vendor
$(DOCKER_PHP_EXEC) vendor/bin/phpunit \
--log-junit test/fixtures/special_chars/data-provider-with-special-chars.xml \
--no-configuration \
test/fixtures/special_chars/UnitTestWithDataProviderSpecialCharsTest.php \
> /dev/null || true
$(DOCKER_PHP_EXEC) vendor/bin/phpunit --no-configuration test/fixtures/common_results/ErrorTest.php --log-junit test/fixtures/common_results/junit/ErrorTest.xml > /dev/null || true
$(DOCKER_PHP_EXEC) vendor/bin/phpunit --no-configuration test/fixtures/common_results/FailureTest.php --log-junit test/fixtures/common_results/junit/FailureTest.xml > /dev/null || true
$(DOCKER_PHP_EXEC) vendor/bin/phpunit --no-configuration test/fixtures/common_results/IncompleteTest.php --log-junit test/fixtures/common_results/junit/IncompleteTest.xml > /dev/null || true
$(DOCKER_PHP_EXEC) vendor/bin/phpunit --no-configuration test/fixtures/common_results/RiskyTest.php --log-junit test/fixtures/common_results/junit/RiskyTest.xml > /dev/null || true
$(DOCKER_PHP_EXEC) vendor/bin/phpunit --no-configuration test/fixtures/common_results/SkippedTest.php --log-junit test/fixtures/common_results/junit/SkippedTest.xml > /dev/null || true
$(DOCKER_PHP_EXEC) vendor/bin/phpunit --no-configuration test/fixtures/common_results/SuccessTest.php --log-junit test/fixtures/common_results/junit/SuccessTest.xml > /dev/null || true
$(DOCKER_PHP_EXEC) vendor/bin/phpunit --no-configuration test/fixtures/common_results/WarningTest.php --log-junit test/fixtures/common_results/junit/WarningTest.xml > /dev/null || true
$(DOCKER_PHP_EXEC) vendor/bin/phpunit --no-configuration test/fixtures/common_results/ --log-junit test/fixtures/common_results/combined.xml > /dev/null || true
find test/fixtures/ -type f -name "*.xml" -print0 | xargs -0 sed -i 's#$(PWD)#.#g'
find test/fixtures/ -type f -name "*.xml" -print0 | xargs -0 sed -i 's#time="........"#time="1.234567"#g'
sed -i 's#name="./test/fixtures/common_results"#name=""#g' test/fixtures/common_results/combined.xml