2020# ScanCode.io is a free software code scanning tool from nexB Inc. and others.
2121# Visit https://github.com/aboutcode-org/scancode.io for support and download.
2222
23+ # #######################################################################################
24+ # Docker dev commands
25+ # #######################################################################################
26+
27+ IMAGE_NAME =scancodeio
28+ COMPOSE =docker compose -f docker-compose.yml -f docker-compose.dev.yml
29+ MANAGE =${COMPOSE} exec web ./manage.py
30+
31+ run :
32+ @echo " -> Run the Docker compose services in dev mode (hot reload on code changes)"
33+ ${COMPOSE} up
34+
35+ bash :
36+ # Open a bash session in the running web container
37+ ${COMPOSE} exec web bash
38+
39+ shell :
40+ # Open a bash session in a standalone container (no stack required)
41+ docker run -it $(IMAGE_NAME ) bash
42+
43+ test :
44+ @echo " -> Run the test suite"
45+ ${MANAGE} test --noinput
46+
47+ fasttest :
48+ @echo " -> Run the test suite without the PipelinesIntegrationTest"
49+ ${MANAGE} test --noinput --exclude-tag slow
50+
51+ migrations :
52+ @echo " -> Creates new database migrations"
53+ ${MANAGE} makemigrations
54+
55+ migrate :
56+ @echo " -> Apply database migrations"
57+ ${MANAGE} migrate
58+
59+ restart-worker :
60+ ${COMPOSE} restart worker
61+
62+ build :
63+ # Build the dev Docker images
64+ ${COMPOSE} build
65+
66+ build-full :
67+ # Build the full production Docker image
68+ docker build --target full -t $(IMAGE_NAME ) .
69+
70+ regen-fixtures :
71+ @echo " -> Regenerate test fixtures from the running Docker stack"
72+ ${COMPOSE} exec -e SCANCODEIO_TEST_FIXTURES_REGEN=1 web ./manage.py test
73+
74+ # #######################################################################################
75+ # Local venv commands (legacy)
76+ # #######################################################################################
77+
2378# Python version can be specified with `$ PYTHON_EXE=python3.x make conf`
2479PYTHON_EXE? =python3
2580VENV_LOCATION =.venv
2681ACTIVATE? =. ${VENV_LOCATION}/bin/activate;
27- MANAGE =${VENV_LOCATION}/bin/python manage.py
82+ VENV_MANAGE =${VENV_LOCATION}/bin/python manage.py
2883VIRTUALENV_PYZ =etc/thirdparty/virtualenv.pyz
2984PIP_ARGS=--find-links =./etc/thirdparty/dummy_dist
3085# Do not depend on Python to generate the SECRET_KEY
@@ -37,7 +92,6 @@ SCANCODEIO_DB_USER=scancodeio
3792SCANCODEIO_DB_PASSWORD =scancodeio
3893POSTGRES_INITDB_ARGS=--encoding =UTF-8 --lc-collate=en_US.UTF-8 --lc-ctype=en_US.UTF-8
3994DATE =$(shell date +"% Y-% m-% d_% H% M")
40- IMAGE_NAME =scancodeio
4195
4296# Use sudo for postgres, only on Linux
4397UNAME := $(shell uname)
@@ -70,6 +124,13 @@ envfile:
70124 @mkdir -p $(shell dirname ${ENV_FILE}) && touch ${ENV_FILE}
71125 @echo SECRET_KEY=\" ${GET_SECRET_KEY} \" > ${ENV_FILE}
72126
127+ runserver :
128+ DJANGO_RUNSERVER_HIDE_WARNING=true ${VENV_MANAGE} runserver 8001 --insecure
129+
130+ check-deploy :
131+ @echo " -> Check Django deployment settings"
132+ ${VENV_MANAGE} check --deploy
133+
73134doc8 :
74135 @echo " -> Run doc8 validation"
75136 @${ACTIVATE} doc8 --max-line-length 100 --ignore-path docs/_build/ --quiet docs/
@@ -89,24 +150,11 @@ check:
89150 @echo " -> Run ABOUT files validation"
90151 @${ACTIVATE} about check --exclude .venv/ --exclude scanpipe/tests/ .
91152
92- check-deploy :
93- @echo " -> Check Django deployment settings"
94- ${MANAGE} check --deploy
95-
96153clean :
97154 @echo " -> Clean the Python env"
98155 rm -rf .venv/ .* cache/ * .egg-info/ build/ dist/
99156 find . -type f -name ' *.py[co]' -delete -o -type d -name __pycache__ -delete
100157
101- migrate :
102- @echo " -> Apply database migrations"
103- ${MANAGE} migrate
104-
105- upgrade :
106- @echo " -> Upgrade local git checkout"
107- @git pull
108- @$(MAKE ) migrate
109-
110158postgresdb :
111159 @echo " -> Configure PostgreSQL database"
112160 @echo " -> Create database user ${SCANCODEIO_DB_NAME} "
@@ -127,37 +175,13 @@ sqlitedb:
127175 @echo SCANCODEIO_DB_NAME=\" sqlite3.db\" >> ${ENV_FILE}
128176 @$(MAKE ) migrate
129177
130- run :
131- DJANGO_RUNSERVER_HIDE_WARNING=true ${MANAGE} runserver 8001 --insecure
132-
133- run-docker-dev :
134- @echo " -> Run the Docker compose services in dev mode (hot reload on code changes)"
135- docker compose -f docker-compose.yml -f docker-compose.dev.yml up --build --watch
136-
137- test :
138- @echo " -> Run the test suite"
139- ${MANAGE} test --noinput
140-
141- fasttest :
142- @echo " -> Run the test suite without the PipelinesIntegrationTest"
143- ${MANAGE} test --noinput --exclude-tag slow
144-
145178worker :
146179 ${MANAGE} rqworker --worker-class scancodeio.worker.ScanCodeIOWorker --queue-class scancodeio.worker.ScanCodeIOQueue --verbosity 2
147180
148181docs :
149182 rm -rf docs/_build/
150183 @${ACTIVATE} sphinx-build docs/ docs/_build/
151184
152- build :
153- docker build --target base -t $(IMAGE_NAME ) .
154-
155- build-full :
156- docker build --target full -t $(IMAGE_NAME ) .
157-
158- bash :
159- docker run -it $(IMAGE_NAME ) bash
160-
161185docker-images :
162186 @echo " -> Build Docker services"
163187 docker compose build
@@ -174,4 +198,4 @@ offline-package: docker-images
174198 @mkdir -p dist/
175199 @tar -cf dist/scancodeio-offline-package-` git describe --tags` .tar build/
176200
177- .PHONY : virtualenv conf dev envfile install doc8 check valid check-deploy clean migrate upgrade postgresdb sqlitedb backupdb run run-docker-dev test fasttest docs build bash docker-images offline-package
201+ .PHONY : virtualenv conf dev envfile install doc8 check valid check-deploy clean migrate makemigrations restart-worker postgresdb sqlitedb backupdb run test fasttest regen-fixtures docs build bash shell docker-images offline-package
0 commit comments