Skip to content

Commit

Permalink
chore(Makefile): add install, check and help targets
Browse files Browse the repository at this point in the history
- add help target and description of all the targets
- add install target to install project dependencies and setup virtual environment
- add check target to quality check code using pre-commit hooks
- set help as default target
- remove lint and format targets as they are redundant
  • Loading branch information
Vyogami committed Apr 6, 2024
1 parent 3cc0490 commit f009afc
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
gen:
rm -f gen/*.py; cd proto; buf generate; cd ...

mongo:
docker run -d --name py-mongo -p 27017:27017 mongo

dev:
poetry run nodemon --no-colors --exec python main.py
install: ## Install dependencies and pre-commit hooks + setup virtual environment.
@echo "🚀 Creating virtual environment using pyenv and poetry"
@poetry install
@poetry run pre-commit install
@poetry shell

env:
poetry shell

docker:
docker build -t py-amibot .
gen: ## Generate proto buffs.
rm -f gen/*.py; cd proto; buf generate; cd ...

dockerRun:
docker run -d --name py-amibot -p 3333:3333 py-amibot
mongo: ## Run mongodb server in docker.
docker run -d --name py-mongo -p 27017:27017 mongo

lint:
poetry run ruff check **/*.py
dev: ## Run amibot server
poetry run nodemon --no-colors --exec python main.py

format:
poetry run ruff format **/*.py
docker: ## Builds the docker image for amibot server.
@docker build -t py-amibot .

.PHONY: gen, mongo, dev, env, docker, dockerRun
dockerRun: ## Runs the amibot server in docker.
@docker run -d --name py-amibot -p 3333:3333 py-amibot

check: ## Run code quality tools.
@echo "🚀 Checking Poetry lock file consistency with 'pyproject.toml': Running poetry lock --check"
@poetry check --lock
@echo "🚀 Linting code: Running pre-commit"
@poetry run pre-commit run -a

help: ## List available targets with respective description.
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'

.PHONY: gen, mongo, dev, env, docker, dockerRun, install, check, help
.DEFAULT_GOAL := help

0 comments on commit f009afc

Please sign in to comment.