Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
100 lines (78 loc) · 3.47 KB
/
Copy pathMakefile
File metadata and controls
100 lines (78 loc) · 3.47 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
PACKAGE_DIR := $(notdir $(CURDIR))
DOCKER := docker run --rm -v "$(CURDIR)/..":/workspace -w /workspace/$(PACKAGE_DIR) composer:2
DOCKER_HOST := docker run --rm --network host -v "$(CURDIR)/..":/workspace -w /workspace/$(PACKAGE_DIR)
PCOV_IMAGE := composer-pcov:local
DOCKER_PCOV := docker run --rm -v "$(CURDIR)/..":/workspace -w /workspace/$(PACKAGE_DIR) --entrypoint sh $(PCOV_IMAGE) -lc
.PHONY: bench build cs cs-fix psalm test mutation rector rector-fix install normalize require-checker \
test-coverage test-coverage-ci update-deps release-check bc-check audit-package help pcov-image pcov-image-refresh
install:
$(DOCKER) composer install --no-interaction --no-progress --prefer-dist
bench:
$(DOCKER) composer bench
build:
$(DOCKER) composer build
cs:
$(DOCKER) composer cs
cs-fix:
$(DOCKER) composer cs:fix
psalm:
$(DOCKER) composer psalm
test:
$(DOCKER) composer test
pcov-image:
@docker image inspect $(PCOV_IMAGE) >/dev/null 2>&1 || $(MAKE) pcov-image-refresh
pcov-image-refresh:
@printf 'FROM composer:2\nRUN apk add --no-cache $$PHPIZE_DEPS >/dev/null \\\n+ && pecl install pcov >/dev/null \\\n+ && docker-php-ext-enable pcov\n' | docker build -t $(PCOV_IMAGE) -
test-coverage: pcov-image
$(DOCKER_PCOV) 'composer test:coverage'
test-coverage-ci: pcov-image
$(DOCKER_PCOV) 'composer test:coverage:ci'
mutation: pcov-image
$(DOCKER_PCOV) 'composer mutation'
rector:
$(DOCKER) composer rector
rector-fix:
$(DOCKER) composer rector:fix
normalize:
$(DOCKER) sh -c 'git config --global --add safe.directory /app; composer normalize'
require-checker:
$(DOCKER) composer require-checker
update-deps:
$(DOCKER) sh -c 'git config --global --add safe.directory /app; composer update -q; composer normalize'
# composer's release-check chain ends in bc-check, which shells out to git —
# without safe.directory the container's git refuses the bind-mounted repo
# ("dubious ownership") and the whole target dies with exit 128
release-check:
$(DOCKER) sh -c 'git config --global --add safe.directory "*"; composer release-check'
$(MAKE) mutation
bc-check:
$(DOCKER) sh -c 'git config --global --add safe.directory "*"; \
LATEST=$$(git describe --tags --abbrev=0 2>/dev/null || true); \
if [ -n "$$LATEST" ]; then \
composer bc-check -- --from=$$LATEST; \
else \
echo "No previous tag - skipping BC check"; \
fi'
help:
@echo "Usage: make <target>"
@echo ""
@echo "Targets:"
@echo " install composer install"
@echo " bench run benchmarks (Benchmarks suite)"
@echo " build full gate (validate + normalize + cs + psalm + test)"
@echo " cs check code style (dry-run)"
@echo " cs-fix fix code style"
@echo " psalm static analysis"
@echo " test run testo (Unit suite)"
@echo " test-coverage run testo with coverage"
@echo " test-coverage-ci run testo coverage for CI artifacts"
@echo " mutation mutation testing"
@echo " rector check rector (dry-run)"
@echo " rector-fix apply rector fixes"
@echo " normalize normalize composer.json"
@echo " require-checker check composer dependencies"
@echo " update-deps composer update + normalize"
@echo " bc-check check backward compatibility against latest tag"
@echo " release-check build + rector + bc-check + mutation"
audit-package:
@if [ -f ../bin/package-audit ]; then bash ../bin/package-audit "$(CURDIR)"; else echo "package-audit: available only inside the monorepo"; fi