2021-11-10 00:59:10 +01:00
|
|
|
NAME := aredis_om
|
|
|
|
SYNC_NAME := redis_om
|
2021-10-20 22:01:46 +02:00
|
|
|
INSTALL_STAMP := .install.stamp
|
|
|
|
POETRY := $(shell command -v poetry 2> /dev/null)
|
2021-11-12 16:29:17 +01:00
|
|
|
REDIS_OM_URL ?= "redis://localhost:6380?decode_responses=True"
|
2021-10-20 22:01:46 +02:00
|
|
|
|
|
|
|
.DEFAULT_GOAL := help
|
|
|
|
|
|
|
|
.PHONY: help
|
|
|
|
help:
|
|
|
|
@echo "Please use 'make <target>' where <target> is one of"
|
|
|
|
@echo ""
|
|
|
|
@echo " install install packages and prepare environment"
|
|
|
|
@echo " clean remove all temporary files"
|
|
|
|
@echo " lint run the code linters"
|
|
|
|
@echo " format reformat code"
|
2022-05-02 22:14:23 +02:00
|
|
|
@echo " test run all the tests against redislabs/redisearch:edge"
|
|
|
|
@echo " test_oss run all the tests against redis:latest"
|
2021-10-20 22:01:46 +02:00
|
|
|
@echo " shell open a Poetry shell"
|
2021-10-20 23:29:31 +02:00
|
|
|
@echo " redis start a Redis instance with Docker"
|
2022-05-02 22:14:23 +02:00
|
|
|
@echo " sync generate modules redis_om, tests_sync from aredis_om, tests respectively"
|
|
|
|
@echo " dist build a redis-om package"
|
|
|
|
@echo " all equivalent to \"make lint format test\""
|
2021-10-20 22:01:46 +02:00
|
|
|
@echo ""
|
|
|
|
@echo "Check the Makefile to know exactly what each target is doing."
|
|
|
|
|
|
|
|
install: $(INSTALL_STAMP)
|
2021-11-10 00:59:10 +01:00
|
|
|
$(INSTALL_STAMP): pyproject.toml
|
2021-10-20 22:01:46 +02:00
|
|
|
@if [ -z $(POETRY) ]; then echo "Poetry could not be found. See https://python-poetry.org/docs/"; exit 2; fi
|
|
|
|
$(POETRY) install
|
|
|
|
touch $(INSTALL_STAMP)
|
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
|
|
find . -type d -name "__pycache__" | xargs rm -rf {};
|
|
|
|
rm -rf $(INSTALL_STAMP) .coverage .mypy_cache
|
2021-11-10 00:59:10 +01:00
|
|
|
rm -rf build
|
|
|
|
rm -rf dist
|
|
|
|
rm -rf redis_om
|
2022-05-01 16:03:05 +02:00
|
|
|
rm -rf tests_sync
|
2022-03-31 10:58:24 +02:00
|
|
|
docker-compose down
|
2021-11-10 00:59:10 +01:00
|
|
|
|
2021-10-22 15:53:39 +02:00
|
|
|
|
|
|
|
.PHONY: dist
|
2021-11-10 00:59:10 +01:00
|
|
|
dist: $(INSTALL_STAMP) clean sync
|
2021-10-22 15:53:39 +02:00
|
|
|
$(POETRY) build
|
2021-10-20 22:01:46 +02:00
|
|
|
|
2021-11-10 00:59:10 +01:00
|
|
|
.PHONY: sync
|
|
|
|
sync: $(INSTALL_STAMP)
|
|
|
|
$(POETRY) run python make_sync.py
|
|
|
|
|
2021-10-20 22:01:46 +02:00
|
|
|
.PHONY: lint
|
2021-10-22 15:53:39 +02:00
|
|
|
lint: $(INSTALL_STAMP) dist
|
2021-11-10 00:59:10 +01:00
|
|
|
$(POETRY) run isort --profile=black --lines-after-imports=2 ./tests/ $(NAME) $(SYNC_NAME)
|
2021-10-20 22:01:46 +02:00
|
|
|
$(POETRY) run black ./tests/ $(NAME)
|
2021-11-10 00:59:10 +01:00
|
|
|
$(POETRY) run flake8 --ignore=W503,E501,F401,E731 ./tests/ $(NAME) $(SYNC_NAME)
|
2023-07-12 10:48:08 +02:00
|
|
|
$(POETRY) run mypy ./tests/ $(NAME) $(SYNC_NAME) --ignore-missing-imports --exclude migrate.py --exclude _compat\.py$
|
2021-11-10 00:59:10 +01:00
|
|
|
$(POETRY) run bandit -r $(NAME) $(SYNC_NAME) -s B608
|
2021-10-20 22:01:46 +02:00
|
|
|
|
|
|
|
.PHONY: format
|
2021-11-12 16:56:47 +01:00
|
|
|
format: $(INSTALL_STAMP) sync
|
2021-11-10 00:59:10 +01:00
|
|
|
$(POETRY) run isort --profile=black --lines-after-imports=2 ./tests/ $(NAME) $(SYNC_NAME)
|
|
|
|
$(POETRY) run black ./tests/ $(NAME) $(SYNC_NAME)
|
2021-10-20 22:01:46 +02:00
|
|
|
|
|
|
|
.PHONY: test
|
2021-11-12 16:56:47 +01:00
|
|
|
test: $(INSTALL_STAMP) sync redis
|
2021-11-12 16:29:17 +01:00
|
|
|
REDIS_OM_URL="$(REDIS_OM_URL)" $(POETRY) run pytest -n auto -vv ./tests/ ./tests_sync/ --cov-report term-missing --cov $(NAME) $(SYNC_NAME)
|
2022-03-31 10:58:24 +02:00
|
|
|
docker-compose down
|
2021-10-20 22:01:46 +02:00
|
|
|
|
2021-11-03 20:37:09 +01:00
|
|
|
.PHONY: test_oss
|
2021-11-12 16:29:17 +01:00
|
|
|
test_oss: $(INSTALL_STAMP) sync redis
|
2021-11-03 20:37:09 +01:00
|
|
|
# Specifically tests against a local OSS Redis instance via
|
|
|
|
# docker-compose.yml. Do not use this for CI testing, where we should
|
|
|
|
# instead have a matrix of Docker images.
|
2021-11-11 01:43:31 +01:00
|
|
|
REDIS_OM_URL="redis://localhost:6381?decode_responses=True" $(POETRY) run pytest -n auto -vv ./tests/ ./tests_sync/ --cov-report term-missing --cov $(NAME)
|
2021-11-03 20:37:09 +01:00
|
|
|
|
2021-10-20 22:01:46 +02:00
|
|
|
|
|
|
|
.PHONY: shell
|
|
|
|
shell: $(INSTALL_STAMP)
|
|
|
|
$(POETRY) shell
|
|
|
|
|
|
|
|
.PHONY: redis
|
|
|
|
redis:
|
|
|
|
docker-compose up -d
|
2021-10-20 23:29:31 +02:00
|
|
|
|
|
|
|
.PHONY: all
|
2022-05-02 22:14:23 +02:00
|
|
|
all: lint format test
|