Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
137 lines (101 loc) · 4.01 KB
/
Copy pathMakefile
File metadata and controls
137 lines (101 loc) · 4.01 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
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
137
.PHONY: all build check test security phpcpd phploc phpmd phpstan php-cs-fixer php-code-sniffer yaml-lint doctrine twig phpmetrics phpunit int-test infection composer-audit bun-audit behat version hooks
export COMPOSER_MEMORY_LIMIT := -1
SRC_DIR=src tests
SRC_DIR_NO_TESTS=src
null :=
SPACE := $(null) $(null)
COMMA := ,
SRC_DIR_COMMA := $(subst $(SPACE),$(COMMA),$(SRC_DIR))
TIME_STAMP := $(shell git log -n 1 --format=%aI)
INFECTION_THREADS ?= $(shell nproc)
all: phpci
# The same checks as CI (.github/workflows/ci.yml calls these targets).
phpci: check test security phploc
# Fast checks, run by the pre-push hook.
check: php-cs-fixer php-code-sniffer phpstan phpcpd yaml-lint doctrine
# int-test needs the bewelcome_test database (bin/console test:database:create --env=test).
test: phpunit infection int-test
security: composer-audit bun-audit
hooks:
git config core.hooksPath .githooks
install:
git rev-parse --short HEAD > VERSION
test -f docker-compose.override.yml || cp docker-compose.override.yml.dist docker-compose.override.yml
bzip2 -ckd docker/languages.sql.bz2 > docker/db/languages.sql
bzip2 -ckd docker/words.sql.bz2 > docker/db/words.sql
ifdef root
sudo docker compose up -d
else
docker compose up -d
endif
install-geonames:
curl http://download.geonames.org/export/dump/allCountries.zip > docker/db/allCountries.zip
curl http://download.geonames.org/export/dump/alternateNames.zip > docker/db/alternateNames.zip
curl http://download.geonames.org/export/dump/countryInfo.txt > docker/db/countryInfo.txt
unzip docker/db/allCountries.zip -d docker/db/
unzip docker/db/alternateNames.zip -d docker/db/
rm docker/db/*.zip
ifdef root
sudo docker compose exec php sh -c "mysql bewelcome -u bewelcome -pbewelcome -h db < import.sql"
else
docker compose exec php sh -c "mysql bewelcome -u bewelcome -pbewelcome -h db < import.sql"
endif
phpcsfix:
"./vendor/bin/phpcbf" $(SRC_DIR)
"./vendor/bin/php-cs-fixer" fix -v
deploy: composer bun encore assets
composer:
composer install --prefer-dist --no-progress --no-suggest --no-interaction --no-scripts
bun:
bun i
encore:
bun encore production
assets:
php bin/console assets:install --env=prod
build:
bun encore dev
php bin/console assets:install
phpdox: phploc phpmd php-code-sniffer phpunit
"./vendor/bin/phpdox"
mkdocs:
mkdocs build
phpcpd:
"./vendor/bin/phpcpd" $(SRC_DIR_NO_TESTS) --exclude=src/Entity --exclude=src/Repository
phploc:
"./vendor/bin/phploc" --log-xml=phploc.xml $(SRC_DIR)
phpmd:
"./vendor/bin/phpmd" $(SRC_DIR_COMMA) text phpmd.xml
phpstan:
"./vendor/bin/phpstan" analyze
php-cs-fixer:
"./vendor/bin/php-cs-fixer" fix -v --diff --dry-run
php-code-sniffer:
"./vendor/bin/phpcs" --colors --warning-severity=Error
phpunit:
XDEBUG_MODE=coverage "./bin/phpunit" --coverage-text --coverage-xml=build/logs/phpunit/coverage-xml --coverage-clover=build/logs/phpunit/clover.xml --log-junit=build/logs/phpunit/junit.xml --colors=never --order-by=random --exclude-group=integration
int-test:
"./bin/phpunit" --log-junit=build/logs/phpunit/integration.xml --colors=never --order-by=random --group=integration
# Uses the coverage of the last `make phpunit`.
infection:
"./vendor/bin/infection" --skip-initial-tests --coverage=build/logs/phpunit --min-covered-msi=80 --threads=$(INFECTION_THREADS)
# Fails on security advisories only; abandoned packages are reported but don't fail.
composer-audit:
composer audit --locked --abandoned=ignore --no-interaction
bun-audit:
bun run audit
#behat: encore
# bin/console doctrine:database:create --env=test --if-not-exists
# bin/console doctrine:schema:create --env=test
# bin/console hautelook:fixtures:load --env=test --no-interaction
# vendor/bin/behat --colors --tags='~@wip'
phpmetrics:
"./vendor/bin/phpmetrics" --exclude=src/App/Entity --report-violations=phpmetrics.xml $(SRC_DIR_COMMA)
version:
git rev-parse --short HEAD > VERSION
touch -d $(TIME_STAMP) VERSION
yaml-lint:
bin/console lint:yaml --parse-tags config fixtures
doctrine:
bin/console doctrine:schema:validate --skip-sync
twig:
bin/console lint:twig