SHELL := /bin/bash
PYTHON_VERSION := 3.10
VENV_NAME = frostfs-testcases-${PYTHON_VERSION}
VENV_DIR := venv.${VENV_NAME}

current_dir := $(shell pwd)
FROM_VENV := . ${VENV_DIR}/bin/activate &&

venv: create requirements paths precommit
	@echo Ready

precommit:
	@echo Isntalling pre-commit hooks
	${FROM_VENV} pre-commit install

paths:
	@echo Append paths for project
	@echo Virtual environment: ${VENV_DIR}
	@rm -rf ${VENV_DIR}/lib/python${PYTHON_VERSION}/site-packages/_paths.pth
	@touch ${VENV_DIR}/lib/python${PYTHON_VERSION}/site-packages/_paths.pth
	@echo ${current_dir} | tee ${VENV_DIR}/lib/python${PYTHON_VERSION}/site-packages/_paths.pth

create: ${VENV_DIR}

${VENV_DIR}:
	@echo Create virtual environment ${VENV_DIR}
	virtualenv --python=python${PYTHON_VERSION} --prompt=${VENV_NAME} ${VENV_DIR}

requirements:
	@echo Isntalling pip requirements
	${FROM_VENV} pip install -e ../frostfs-testlib
	${FROM_VENV} pip install -Ur requirements.txt
	${FROM_VENV} pip install -Ur requirements_dev.txt


#### VALIDATION SECTION ####
lint: create requirements
	${FROM_VENV} pip install -e ../frostfs-testlib;
	${FROM_VENV} pylint --disable R,C,W pytest_tests

validation: lint
	${FROM_VENV} pytest --collect-only