Makefile
158 lines
| 5.0 KiB
| text/x-makefile
|
MakefileLexer
r5514 | .DEFAULT_GOAL := help | |||
# Pretty print values cf. https://misc.flogisoft.com/bash/tip_colors_and_formatting | ||||
RESET := \033[0m # Reset all formatting | ||||
GREEN := \033[0;32m # Resets before setting 16b colour (32 -- green) | ||||
YELLOW := \033[0;33m | ||||
ORANGE := \033[0;38;5;208m # Reset then set 256b colour (208 -- orange) | ||||
PEACH := \033[0;38;5;216m | ||||
## ---------------------------------------------------------------------------------- ## | ||||
## ------------------------- Help usage builder ------------------------------------- ## | ||||
## ---------------------------------------------------------------------------------- ## | ||||
# use '# >>> Build commands' to create section | ||||
# use '# target: target description' to create help for target | ||||
.PHONY: help | ||||
help: | ||||
@echo "Usage:" | ||||
@cat $(MAKEFILE_LIST) | grep -E '^# >>>|^# [A-Za-z0-9_.-]+:' | sed -E 's/^# //' | awk ' \ | ||||
BEGIN { \ | ||||
green="\033[32m"; \ | ||||
yellow="\033[33m"; \ | ||||
reset="\033[0m"; \ | ||||
section=""; \ | ||||
} \ | ||||
/^>>>/ { \ | ||||
section=substr($$0, 5); \ | ||||
printf "\n" green ">>> %s" reset "\n", section; \ | ||||
next; \ | ||||
} \ | ||||
/^([A-Za-z0-9_.-]+):/ { \ | ||||
target=$$1; \ | ||||
gsub(/:$$/, "", target); \ | ||||
description=substr($$0, index($$0, ":") + 2); \ | ||||
if (description == "") { description="-"; } \ | ||||
printf " - " yellow "%-35s" reset " %s\n", target, description; \ | ||||
} \ | ||||
' | ||||
r5036 | # required for pushd to work.. | |||
r5013 | SHELL = /bin/bash | |||
r1220 | ||||
r5514 | # >>> Tests commands | |||
r1 | ||||
r4899 | .PHONY: clean | |||
r5514 | # clean: Cleanup compiled and cache py files | |||
r1220 | clean: | |||
make test-clean | ||||
r3476 | find . -type f \( -iname '*.c' -o -iname '*.pyc' -o -iname '*.so' -o -iname '*.orig' \) -exec rm '{}' ';' | |||
r5105 | find . -type d -name "build" -prune -exec rm -rf '{}' ';' | |||
r4899 | ||||
r5181 | ||||
r4899 | .PHONY: test | |||
r5514 | # test: run test-clean and tests | |||
r1220 | test: | |||
make test-clean | ||||
r5514 | unset RC_SQLALCHEMY_DB1_URL && unset RC_DB_URL && make test-only | |||
r13 | ||||
r4899 | ||||
r5036 | .PHONY: test-clean | |||
r5514 | # test-clean: run test-clean and tests | |||
r1220 | test-clean: | |||
rm -rf coverage.xml htmlcov junit.xml pylint.log result | ||||
find . -type d -name "__pycache__" -prune -exec rm -rf '{}' ';' | ||||
r3845 | find . -type f \( -iname '.coverage.*' \) -exec rm '{}' ';' | |||
r1220 | ||||
r4899 | ||||
.PHONY: test-only | ||||
r5514 | # test-only: Run tests only without cleanup | |||
r1220 | test-only: | |||
r2100 | PYTHONHASHSEED=random \ | |||
r4899 | py.test -x -vv -r xw -p no:sugar \ | |||
--cov-report=term-missing --cov-report=html \ | ||||
--cov=rhodecode rhodecode | ||||
r2100 | ||||
r5514 | # >>> Docs commands | |||
r5036 | ||||
r4899 | .PHONY: docs | |||
r5514 | # docs: build docs | |||
r13 | docs: | |||
r5193 | (cd docs; docker run --rm -v $(PWD):/project --workdir=/project/docs sphinx-doc-build-rc make clean html) | |||
r1 | ||||
r4899 | ||||
.PHONY: docs-clean | ||||
r5514 | # docs-clean: Cleanup docs | |||
r13 | docs-clean: | |||
r5193 | (cd docs; docker run --rm -v $(PWD):/project --workdir=/project/docs sphinx-doc-build-rc make clean) | |||
r13 | ||||
r4899 | ||||
.PHONY: docs-cleanup | ||||
r5514 | # docs-cleanup: Cleanup docs | |||
r1214 | docs-cleanup: | |||
r5193 | (cd docs; docker run --rm -v $(PWD):/project --workdir=/project/docs sphinx-doc-build-rc make cleanup) | |||
r1214 | ||||
r5514 | # >>> Dev commands | |||
r4899 | ||||
.PHONY: web-build | ||||
r5514 | # web-build: Build JS packages static/js | |||
r1 | web-build: | |||
r5475 | rm -rf node_modules | |||
r5239 | docker run -it --rm -v $(PWD):/project --workdir=/project rhodecode/static-files-build:16 -c "npm install && /project/node_modules/.bin/grunt" | |||
r5233 | # run static file check | |||
./rhodecode/tests/scripts/static-file-check.sh rhodecode/public/ | ||||
rm -rf node_modules | ||||
r1 | ||||
r4899 | ||||
r5191 | .PHONY: dev-sh | |||
r5514 | # dev-sh: make dev-sh | |||
r5191 | dev-sh: | |||
r5194 | sudo echo "deb [trusted=yes] https://apt.fury.io/rsteube/ /" | sudo tee -a "/etc/apt/sources.list.d/fury.list" | |||
r5191 | sudo apt-get update | |||
r5194 | sudo apt-get install -y zsh carapace-bin | |||
r5212 | rm -rf /home/rhodecode/.oh-my-zsh | |||
r5191 | curl https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh | |||
r5305 | @echo "source <(carapace _carapace)" > /home/rhodecode/.zsrc | |||
@echo "${RC_DEV_CMD_HELP}" | ||||
r5327 | @PROMPT='%(?.%F{green}√.%F{red}?%?)%f %B%F{240}%1~%f%b %# ' zsh | |||
r5191 | ||||
r5222 | ||||
.PHONY: dev-cleanup | ||||
r5514 | # dev-cleanup: Cleanup: pip freeze | grep -v "^-e" | grep -v "@" | xargs pip uninstall -y | |||
r5222 | dev-cleanup: | |||
pip freeze | grep -v "^-e" | grep -v "@" | xargs pip uninstall -y | ||||
rm -rf /tmp/* | ||||
r4905 | .PHONY: dev-env | |||
r5514 | # dev-env: make dev-env based on the requirements files and install develop of packages | |||
r5414 | ## Cleanup: pip freeze | grep -v "^-e" | grep -v "@" | xargs pip uninstall -y | |||
r4905 | dev-env: | |||
Andrii Verbytskyi
|
r5385 | sudo -u root chown rhodecode:rhodecode /home/rhodecode/.cache/pip/ | ||
r5036 | pip install build virtualenv | |||
r4967 | pushd ../rhodecode-vcsserver/ && make dev-env && popd | |||
r5036 | pip wheel --wheel-dir=/home/rhodecode/.cache/pip/wheels -r requirements.txt -r requirements_rc_tools.txt -r requirements_test.txt -r requirements_debug.txt | |||
pip install --no-index --find-links=/home/rhodecode/.cache/pip/wheels -r requirements.txt -r requirements_rc_tools.txt -r requirements_test.txt -r requirements_debug.txt | ||||
r4905 | pip install -e . | |||
r5036 | ||||
r5209 | .PHONY: sh | |||
r5514 | # sh: shortcut for make dev-sh dev-env | |||
r5209 | sh: | |||
r5278 | make dev-env | |||
make dev-sh | ||||
r5212 | ||||
r5209 | ||||
r5404 | ## Allows changes of workers e.g make dev-srv-g workers=2 | |||
workers?=1 | ||||
r5181 | ||||
r5413 | .PHONY: dev-srv | |||
r5514 | # dev-srv: run gunicorn web server with reloader, use workers=N to set multiworker mode, workers=N allows changes of workers | |||
r5414 | dev-srv: | |||
r5404 | gunicorn --paste=.dev/dev.ini --bind=0.0.0.0:10020 --config=.dev/gunicorn_config.py --timeout=120 --reload --workers=$(workers) | |||
r5036 | ||||
r5514 | .PHONY: ruff-check | |||
# ruff-check: run a ruff analysis | ||||
ruff-check: | ||||
ruff check --ignore F401 --ignore I001 --ignore E402 --ignore E501 --ignore F841 --exclude rhodecode/lib/dbmigrate --exclude .eggs --exclude .dev . | ||||
r3531 | ||||