-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
152 lines (102 loc) · 4.61 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# Silence output slightly
# .SILENT:
PHP ?= $(shell which php)
CONSOLE := $(PHP) bin/console
SYMFONY ?= $(shell which symfony)
PHPUNIT := ./vendor/bin/phpunit
PHPCSF := ./vendor/bin/php-cs-fixer
PHPSTAN := ./vendor/bin/phpstan
TWIGCS := ./vendor/bin/twigcs
CODE_DIRS := bin config migrations src templates tests
## -- Help
help: ## Outputs this help screen
@grep -E '(^[a-zA-Z0-9._-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | sed -e 's/^.*Makefile[^:]*://' | awk 'BEGIN {FS = ":.*?## "}{printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/'
## -- Tests
test.reset: ## Create a test database and load the fixtures in it
rm -rf var/cache/test/* data/test/*
rm -f var/log/test-*.log
$(CONSOLE) --env=test doctrine:database:create --quiet --if-not-exists
$(CONSOLE) --env=test doctrine:schema:drop --quiet --force
$(CONSOLE) --env=test doctrine:schema:create --quiet
$(CONSOLE) --env=test doctrine:schema:validate --quiet
$(CONSOLE) --env=test doctrine:cache:clear-metadata --quiet
$(CONSOLE) --env=test doctrine:fixtures:load --quiet --no-interaction --group=dev
$(CONSOLE) --env=test meili:delete --quiet --no-debug
$(CONSOLE) --env=test meili:import --quiet --no-debug
test.clean: ## Clean Meilisearch
$(CONSOLE) --env=test meili:delete --quiet --no-debug
test.run: ## Directly run tests. Use optional path=/path/to/tests to limit target
$(PHPUNIT) $(path)
test: test.reset test.run test.clean ## Run all tests. Use optional path=/path/to/tests to limit target
test.cover: test.reset ## Generate a test cover report
$(PHP) -dpcov.enabled=1 -dpcov.directory=. -dpcov.exclude="~vendor~" $(PHPUNIT) $(path) --coverage-html=coverage
test.cover.view: ## Open the test coverage html file
open coverage/index.html
## -- Cache targets
cc: ## Clear the symfony cache
$(CONSOLE) cache:clear
$(CONSOLE) cache:warmup
cc.purge: ## Remove cache and log files
rm -rf var/cache/*/*
rm -f var/log/*
## -- Assets
assets: ## Link assets into /public
$(CONSOLE) assets:install --symlink
## Database migrations
migrate: ## Run any migrations as required
$(CONSOLE) doctrine:migrations:migrate --no-interaction --allow-no-migration
migrate.down: ## Undo one migration
# This is arcane nonsense and only works in GNU Make
$(eval CURRENT=$(shell $(CONSOLE) doctrine:migrations:current))
$(CONSOLE) doctrine:migrations:execute '$(CURRENT)' --down
migrate.diff: ## Generate a migration by diffing the db and entities
$(CONSOLE) doctrine:migrations:diff --no-interaction --quiet
migrate.status: ## Status of database migrations
$(CONSOLE) doctrine:migrations:status
migrate.rollup: ## Roll up all migrations in to a schema definition
rm -rf migrations/*
$(CONSOLE) doctrine:migrations:dump-schema --no-interaction --quiet
$(CONSOLE) doctrine:migrations:rollup --no-interaction --quiet
$(PHPCSF) fix migrations
migrate.reset: ## Reset all migrations metadata
$(CONSOLE) doctrine:migrations:version --delete --all --no-interaction --quiet
$(CONSOLE) doctrine:migrations:version --add --all --no-interaction --quiet
## -- Container debug targets
dump.autowire: ## Show autowireable services
$(CONSOLE) debug:autowiring --all
dump.container: ## Show container information
$(CONSOLE) debug:container
dump.env: ## Show all environment variables in the container
$(CONSOLE) debug:container --env-vars
dump.params: ## List all of the nines container parameters
$(CONSOLE) debug:container --parameters
dump.router: ## Display rounting information
$(CONSOLE) debug:router
dump.twig: ## Show all twig configuration
$(CONSOLE) debug:twig
## -- Coding standards fixing
fix: ## Fix the code with the CS rules
$(PHPCSF) fix $(path)
fix.cc: ## Remove the PHP CS Cache file
rm -f var/cache/php_cs.cache
fix.all: fix.cc fix ## Ignore the CS cache and fix the code with the CS rules
fix.list: ## Check the code against the CS rules
$(PHPCSF) fix --dry-run -v $(path)
## -- Coding standards checking
lint-all: stan.cc stan twiglint twigcs yamllint
symlint: yamllint twiglint ## Run the symfony linting checks
$(SYMFONY) security:check --quiet
$(CONSOLE) lint:container --quiet
$(CONSOLE) doctrine:schema:validate --quiet --skip-sync -vvv --no-interaction
twiglint: ## Check the twig templates for syntax errors
$(CONSOLE) lint:twig templates
twigcs: ## Check the twig templates against the coding standards
$(TWIGCS) templates
yamllint:
$(CONSOLE) lint:yaml templates
stan: ## Run static analysis
$(PHPSTAN) --memory-limit=1G analyze $(CODE_DIRS)
stan.cc: ## Clear the static analysis cache
$(PHPSTAN) clear-result-cache
stan.baseline: ## Generate a new phpstan baseline file
$(PHPSTAN) --memory-limit=1G analyze --generate-baseline $(CODE_DIRS)