Skip to content

Instantly share code, notes, and snippets.

@vikbert

vikbert/Makefile Secret

Last active March 22, 2023 05:14
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vikbert/54e27c7a304fe96def50ef76b96b04a6 to your computer and use it in GitHub Desktop.
Save vikbert/54e27c7a304fe96def50ef76b96b04a6 to your computer and use it in GitHub Desktop.
Makefile.dist
SHELL := /bin/bash
help:
@grep -E '^[1-9a-zA-Z_-]+:.*?## .*$$|(^#--)' $(MAKEFILE_LIST) \
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m %-43s\033[0m %s\n", $$1, $$2}' \
| sed -e 's/\[32m #-- /[33m/'
#-- Docker
start: ## start the necessary containers for stores
docker-compose up -d
clean: ## clean up all docker resources
docker-compose stop
docker container prune -f
docker volume prune -f
docker network prune -f
#-- Database
db: ## reset the local database with migrations
docker-compose run --rm php bin/console doctrine:database:drop --if-exists -n --force
docker-compose run --rm php bin/console doctrine:database:create --if-not-exists -n
docker-compose run --rm php bin/console doctrine:migrations:migrate -vvv -n
#-- Testing
test: ## execute all phpunit tests
docker-compose run --rm php composer test
#-- Static Code Analyse
phpstan: ## apply the code static analyze for all services
docker-compose run --rm php composer phpstan
fixer: ## apply php-cs-fixer for all services
docker-compose run --rm php composer fixer
@Mgldvd
Copy link

Mgldvd commented Jun 26, 2022

Love this,
Maybe, I'm not sure .. I'm like a noob, you should add .PHONY: directive?

https://www.gnu.org/software/make/manual/make.html#Phony-Targets

.PHONY: help start clean db test test fixer

also you can add

.SILENT: start clean db

Suppress echo of command invocation in makefile

I already implemented this file in my projects that I used to run with something like bash init.

Thank you 🥳

@vikbert
Copy link
Author

vikbert commented Jun 27, 2022

due to this thread I read phony in a makefile I do not use actually really the definition ".PHONY" in my daily work. I am minimalist, and I made the decision to remove all unused or optional definitions from my makefile, which are noise code for ME.

Sure you are absolute right. For 100% stable code, we need define the .PHONY like you suggested here. Thx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment