Improve project usage (#6)
All checks were successful
continuous-integration/drone/push Build is passing

1. Ignore unnecessary files, such as `pgcli` log/history, and extra `docker-compose` definitions.
2. Add `Makefile` with common tasks.
3. Add git pre-commit hook to ensure project is always properly formatted.
4. Add [`btree_gist`][0] extension to `postgres`.

Reviewed-on: #6

[0]: https://www.postgresql.org/docs/14/btree-gist.html
This commit is contained in:
2022-04-23 17:15:16 +00:00
parent b7200555a8
commit e7df0322d7
8 changed files with 253 additions and 2 deletions

41
Makefile Normal file
View File

@@ -0,0 +1,41 @@
.DEFAULT_GOAL := help
COMPOSE = docker-compose -f docker-compose.yml -f docker-compose.override.yml
.PHONY: setup
setup: ## setup project
@mkdir -p priv/plts
@mix do local.rebar --force, local.hex --force
@mix do deps.get, deps.compile
@mix dialyzer --plt
.PHONY: check_format
check_format: ## run format checker
@mix format --check-formatted
.PHONY: credo
credo: ## run credo
@mix credo suggest --strict --format=flycheck
.PHONY: dialyzer
dialyzer: ## run dialyzer
@mix dialyzer --no-check --quiet --ignore-exit-status --format short
.PHONY: static_code_analysis
static_code_analysis: check_format credo dialyzer ## run static code analysis
.PHONY: test
test: ## run tests
@mix test --cover --trace --slowest 10
.PHONY: compose_up
compose_up: ## start containers for this service
@$(COMPOSE) up -d
.PHONY: compose_test
compose_test: ## run tests in containers
@$(COMPOSE) run -e MIX_ENV=test --entrypoint make app test
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'