1+ .PHONY : all prep-dev venv clean lint test docker-test
2+
3+ # virtual environment for development
4+ VENV_NAME? =venv
5+ VENV_ACTIVATE =. $(VENV_NAME ) /bin/activate
6+ PYTHON =${VENV_NAME}/bin/python3
7+ # help messages for make, it runs in `make` or `make all`
8+ all :
9+ @echo " \033[92m make prep-dev \033[0m"
10+ @echo " ---> Prepares dev environment, use only once"
11+ @echo " \033[92m make test \033[0m"
12+ @echo " ---> Runs test cases in virtual environment"
13+ @echo " \033[92m make lint \033[0m"
14+ @echo " ---> Linting project with autopep8"
15+ @echo " \033[92m make clean \033[0m"
16+ @echo " ---> Cleans project cache and other stuffs"
17+ @echo " \033[92m make docker-test \033[0m"
18+ @echo " ---> Runs test cases in docker environment"
19+
20+
21+ prep-dev :
22+ python3 -m pip install virtualenv # # virtual environment for development purposes
23+ make venv
24+
25+ venv : $(VENV_NAME ) /bin/activate
26+ $(VENV_NAME ) /bin/activate : requirements.txt
27+ test -d $(VENV_NAME ) || virtualenv -p python3 $(VENV_NAME )
28+ ${PYTHON} -m pip install -U pip setuptools
29+ ${PYTHON} -m pip install -U autopep8 coverage isort
30+ ${PYTHON} -m pip install -U -r requirements.txt
31+ touch $(VENV_NAME ) /bin/activate
32+
33+ clean :
34+ rm -rf $(VENV_NAME ) * .eggs * .egg-info dist build docs/_build .cache .coverage
35+ rm -rf .pytest* # cache file for Intellij PyCharm
36+
37+ sort : venv
38+ isort -rc . --skip_glob docs/*
39+
40+
41+ lint : venv
42+ autopep8 --in-place --recursive --max-line-length=100 --exclude docs/source/conf.py,venv,__pycache__,old,build,dist .
43+
44+ test : venv
45+ coverage run --source=richkit -m pytest -Werror --ignore src/python-whois
46+
47+ docker-test : clean
48+ docker build -t richkit-docker-test -f Dockerfile.test .
49+ docker run -e MAXMIND_LICENSE_KEY=$MAXMIND_LICENSE_KEY richkit-docker-test
0 commit comments