2424# Python version can be specified with `$ PYTHON_EXE=python3.x make conf`
2525PYTHON_EXE? =python3
2626VENV =venv
27+ MANAGE =${VENV}/bin/python manage.py
2728ACTIVATE? =. ${VENV}/bin/activate;
2829VIRTUALENV_PYZ =etc/thirdparty/virtualenv.pyz
29- BLACK_ARGS =-l 100 .
30- ISORT_ARGS =.
3130# Do not depend on Python to generate the SECRET_KEY
3231GET_SECRET_KEY =` base64 /dev/urandom | head -c50 `
3332# Customize with `$ make envfile ENV_FILE=/etc/vulnerablecode/.env`
@@ -49,41 +48,48 @@ virtualenv:
4948
5049conf : virtualenv
5150 @echo " -> Install dependencies"
52- @${ACTIVATE} pip install -r requirements.txt
51+ @${ACTIVATE} pip install -e . -c requirements.txt
5352
54- dev : conf
53+ dev : virtualenv
5554 @echo " -> Configure and install development dependencies"
56- @${ACTIVATE} pip install -r requirements- dev.txt
55+ @${ACTIVATE} pip install -e .[ dev] -c requirements .txt
5756
5857envfile :
5958 @echo " -> Create the .env file and generate a secret key"
6059 @if test -f ${ENV_FILE} ; then echo " .env file exists already" ; exit 1; fi
6160 @mkdir -p $(shell dirname ${ENV_FILE}) && touch ${ENV_FILE}
6261 @echo SECRET_KEY=\" ${GET_SECRET_KEY} \" > ${ENV_FILE}
6362
64- check :
65- @echo " -> Run isort validation"
66- @${ACTIVATE} isort --check-only ${ISORT_ARGS}
67- @echo " -> Run black validation"
68- @${ACTIVATE} black --check ${BLACK_ARGS}
63+ isort :
64+ @echo " -> Apply isort changes to ensure proper imports ordering"
65+ ${VENV} /bin/isort .
6966
7067black :
7168 @echo " -> Apply black code formatter"
72- ${VENV} /bin/black ${BLACK_ARGS}
69+ ${VENV} /bin/black .
7370
74- isort :
75- @echo " -> Apply isort code formatter "
76- ${VENV} /bin/isort ${ISORT_ARGS}
71+ doc8 :
72+ @echo " -> Run doc8 validation "
73+ @ ${ACTIVATE} doc8 --max-line-length 100 --ignore-path docs/_build/ --quiet docs/
7774
7875valid : isort black
7976
77+ check :
78+ @echo " -> Run pycodestyle (PEP8) validation"
79+ @${ACTIVATE} pycodestyle --max-line-length=100 --exclude=venv,lib,thirdparty,docs,migrations,settings.py .
80+ @echo " -> Run isort imports ordering validation"
81+ @${ACTIVATE} isort --check-only .
82+ @echo " -> Run black validation"
83+ @${ACTIVATE} black --check ${BLACK_ARGS}
84+
8085clean :
8186 @echo " -> Clean the Python env"
82- rm -rf ${VENV}
87+ rm -rf ${VENV} build/ dist/ vulnerablecode.egg-info/ docs/_build/ pip-selfcheck.json
88+ find . -type f -name ' *.py[co]' -delete -o -type d -name __pycache__ -delete
8389
8490migrate :
8591 @echo " -> Apply database migrations"
86- ${ACTIVATE} ./manage.py migrate
92+ ${MANAGE} migrate
8793
8894postgres :
8995 @echo " -> Configure PostgreSQL database"
@@ -103,26 +109,31 @@ sqlite:
103109 @$(MAKE ) migrate
104110
105111run :
106- ${ACTIVATE} ./manage.py runserver
112+ ${MANAGE} runserver 8001 --noreload --insecure
107113
108114test :
109- @echo " -> Run offline tests "
110- ${ACTIVATE} ${PYTHON_EXE} -m pytest -v -m " not webtest"
115+ @echo " -> Run the test suite "
116+ ${ACTIVATE} ${PYTHON_EXE} -m pytest -vvs -m " not webtest"
111117
112118webtest :
113119 @echo " -> Run web tests"
114- ${ACTIVATE} ${PYTHON_EXE} -m pytest -v -m " webtest"
115-
116- package : conf
117- @echo " -> Create a VulnerableCode package for offline installation"
118- @echo " -> Fetch dependencies in thirdparty/ for offline installation"
119- rm -rf thirdparty && mkdir thirdparty
120- ${VENV} /bin/pip download -r requirements.txt --no-cache-dir --dest thirdparty
121- @echo " -> Create package in dist/ for offline installation"
122- ${VENV} /bin/python setup.py sdist
123-
124- install : virtualenv
125- @echo " -> Install and configure the Python env with base dependencies, offline"
126- ${VENV} /bin/pip install --upgrade --no-index --no-cache-dir --find-links=thirdparty -e .
127-
128- .PHONY : virtualenv conf dev envfile install check valid clean migrate postgres sqlite run test package
120+ ${ACTIVATE} ${PYTHON_EXE} -m pytest -vvs -m " webtest"
121+
122+ bump :
123+ @echo " -> Bump the version"
124+ bin/bumpver update --no-fetch --patch
125+
126+ docs :
127+ rm -rf docs/_build/
128+ @${ACTIVATE} sphinx-build docs/ docs/_build/
129+
130+ docker-images :
131+ @echo " -> Build Docker services"
132+ docker-compose build
133+ @echo " -> Pull service images"
134+ docker-compose pull
135+ @echo " -> Save the service images to a compressed tar archive in the dist/ directory"
136+ @mkdir -p dist/
137+ @docker save postgres vulnerablecode_vulnerablecode nginx | gzip > dist/vulnerablecode-images-` git describe --tags` .tar.gz
138+
139+ .PHONY : virtualenv conf dev envfile install check valid isort clean migrate postgres sqlite run test bump docs docker-images
0 commit comments