|
| 1 | +# Makefile |
| 2 | +# |
| 3 | +# This file contains the commands most used in DEV, plus the ones used in CI and PRD environments. |
| 4 | +# |
| 5 | +# The commands are to be organized semantically and alphabetically, so that similar commands are nex to each other |
| 6 | +# and we can compare them and update them easily. |
| 7 | +# |
| 8 | +# For example in a format like `subject-action-environment`, ie: |
| 9 | +# |
| 10 | +# cs-fix: # here we don't use the env because we only do it in dev |
| 11 | +# dep-install: # again, by default the env is dev |
| 12 | +# dep-install-prd: |
| 13 | +# dep-update: |
| 14 | +# test: # here we don't even have a subject because it is the app itself, and by default the env is dev |
| 15 | +# |
| 16 | + |
| 17 | +# Mute all `make` specific output. Comment this out to get some debug information. |
| 18 | +.SILENT: |
| 19 | + |
| 20 | +# .DEFAULT: If the command does not exist in this makefile |
| 21 | +# default: If no command was specified |
| 22 | +.DEFAULT default: |
| 23 | + if [ -f ./Makefile.custom ]; then \ |
| 24 | + $(MAKE) -f Makefile.custom "$@"; \ |
| 25 | + else \ |
| 26 | + if [ "$@" != "" ]; then echo "Command '$@' not found."; fi; \ |
| 27 | + $(MAKE) help; \ |
| 28 | + if [ "$@" != "" ]; then exit 2; fi; \ |
| 29 | + fi |
| 30 | + |
| 31 | +help: |
| 32 | + @echo "Usage:" |
| 33 | + @echo " make [command]" |
| 34 | + @echo |
| 35 | + @echo "Available commands:" |
| 36 | + @grep '^[^#[:space:]].*:' Makefile | grep -v '^default' | grep -v '^\.' | grep -v '=' | grep -v '^_' | sed 's/://' | xargs -n 1 echo ' -' |
| 37 | + |
| 38 | +######################################################################################################################## |
| 39 | + |
| 40 | +COVERAGE_REPORT_PATH="var/coverage.clover.xml" |
| 41 | +DB_PATH='var/data/blog.sqlite' |
| 42 | + |
| 43 | +# We run this in tst ENV so that we never run it with xdebug on |
| 44 | +cs-fix: |
| 45 | + php vendor/bin/php-cs-fixer fix --verbose |
| 46 | + |
| 47 | +db-setup: |
| 48 | + mkdir -p var/data |
| 49 | + php bin/console doctrine:database:drop -n --force |
| 50 | + php bin/console doctrine:database:create -n |
| 51 | + php bin/console doctrine:schema:create -n |
| 52 | + php bin/console doctrine:fixtures:load -n |
| 53 | + |
| 54 | +dep-clearcache: |
| 55 | + composer clearcache |
| 56 | + |
| 57 | +dep-install: |
| 58 | + composer install |
| 59 | + |
| 60 | +dep-install-prd: |
| 61 | + composer install --no-dev --optimize-autoloader --no-ansi --no-interaction --no-progress --no-scripts |
| 62 | + |
| 63 | +dep-update: |
| 64 | + composer update |
| 65 | + |
| 66 | +test: |
| 67 | + $(MAKE) db-setup |
| 68 | + php vendor/bin/phpunit |
| 69 | + $(MAKE) cs-fix |
| 70 | + |
| 71 | +# We use phpdbg because is part of the core and so that we don't need to install xdebug just to get the coverage. |
| 72 | +# Furthermore, phpdbg gives us more info in certain conditions, ie if the memory_limit has been reached. |
| 73 | +test_cov: |
| 74 | + phpdbg -qrr vendor/bin/phpunit --coverage-text --coverage-clover=${COVERAGE_REPORT_PATH} |
| 75 | + |
| 76 | +up: |
| 77 | + if [ ! -f ${DB_PATH} ]; then $(MAKE) db-setup; fi |
| 78 | + php bin/console server:run 0.0.0.0:8000 |
0 commit comments