|
| 1 | +NAME := redis_developer |
| 2 | +INSTALL_STAMP := .install.stamp |
| 3 | +POETRY := $(shell command -v poetry 2> /dev/null) |
| 4 | + |
| 5 | +.DEFAULT_GOAL := help |
| 6 | + |
| 7 | +.PHONY: help |
| 8 | +help: |
| 9 | + @echo "Please use 'make <target>' where <target> is one of" |
| 10 | + @echo "" |
| 11 | + @echo " install install packages and prepare environment" |
| 12 | + @echo " clean remove all temporary files" |
| 13 | + @echo " lint run the code linters" |
| 14 | + @echo " format reformat code" |
| 15 | + @echo " test run all the tests" |
| 16 | + @echo " shell open a Poetry shell" |
| 17 | + @echo "" |
| 18 | + @echo "Check the Makefile to know exactly what each target is doing." |
| 19 | + |
| 20 | +install: $(INSTALL_STAMP) |
| 21 | +$(INSTALL_STAMP): pyproject.toml poetry.lock |
| 22 | + @if [ -z $(POETRY) ]; then echo "Poetry could not be found. See https://python-poetry.org/docs/"; exit 2; fi |
| 23 | + $(POETRY) install |
| 24 | + touch $(INSTALL_STAMP) |
| 25 | + |
| 26 | +.PHONY: clean |
| 27 | +clean: |
| 28 | + find . -type d -name "__pycache__" | xargs rm -rf {}; |
| 29 | + rm -rf $(INSTALL_STAMP) .coverage .mypy_cache |
| 30 | + |
| 31 | +.PHONY: lint |
| 32 | +lint: $(INSTALL_STAMP) |
| 33 | + $(POETRY) run isort --profile=black --lines-after-imports=2 ./tests/ $(NAME) |
| 34 | + $(POETRY) run black ./tests/ $(NAME) |
| 35 | + $(POETRY) run flake8 --ignore=W503,E501,F401,E731 ./tests/ $(NAME) |
| 36 | + $(POETRY) run mypy ./tests/ $(NAME) --ignore-missing-imports |
| 37 | + $(POETRY) run bandit -r $(NAME) -s B608 |
| 38 | + |
| 39 | +.PHONY: format |
| 40 | +format: $(INSTALL_STAMP) |
| 41 | + $(POETRY) run isort --profile=black --lines-after-imports=2 ./tests/ $(NAME) |
| 42 | + $(POETRY) run black ./tests/ $(NAME) |
| 43 | + |
| 44 | +.PHONY: test |
| 45 | +test: $(INSTALL_STAMP) |
| 46 | + #$(POETRY) run pytest ./tests/ --cov-report term-missing --cov-fail-under 100 --cov $(NAME) |
| 47 | + $(POETRY) run pytest ./tests/ |
| 48 | + |
| 49 | +.PHONY: shell |
| 50 | +shell: $(INSTALL_STAMP) |
| 51 | + $(POETRY) shell |
| 52 | + |
| 53 | +.PHONY: redis |
| 54 | +redis: |
| 55 | + docker-compose up -d |
0 commit comments