Show More
@@ -1,144 +1,130 b'' | |||
|
1 | .DEFAULT_GOAL := help | |
|
2 | ||
|
3 | # Pretty print values cf. https://misc.flogisoft.com/bash/tip_colors_and_formatting | |
|
4 | RESET := \033[0m # Reset all formatting | |
|
5 | GREEN := \033[0;32m # Resets before setting 16b colour (32 -- green) | |
|
6 | YELLOW := \033[0;33m | |
|
7 | ORANGE := \033[0;38;5;208m # Reset then set 256b colour (208 -- orange) | |
|
8 | PEACH := \033[0;38;5;216m | |
|
9 | ||
|
10 | ||
|
11 | ## ---------------------------------------------------------------------------------- ## | |
|
12 | ## ------------------------- Help usage builder ------------------------------------- ## | |
|
13 | ## ---------------------------------------------------------------------------------- ## | |
|
14 | # use '# >>> Build commands' to create section | |
|
15 | # use '# target: target description' to create help for target | |
|
16 | .PHONY: help | |
|
17 | help: | |
|
18 | @echo "Usage:" | |
|
19 | @cat $(MAKEFILE_LIST) | grep -E '^# >>>|^# [A-Za-z0-9_.-]+:' | sed -E 's/^# //' | awk ' \ | |
|
20 | BEGIN { \ | |
|
21 | green="\033[32m"; \ | |
|
22 | yellow="\033[33m"; \ | |
|
23 | reset="\033[0m"; \ | |
|
24 | section=""; \ | |
|
25 | } \ | |
|
26 | /^>>>/ { \ | |
|
27 | section=substr($$0, 5); \ | |
|
28 | printf "\n" green ">>> %s" reset "\n", section; \ | |
|
29 | next; \ | |
|
30 | } \ | |
|
31 | /^([A-Za-z0-9_.-]+):/ { \ | |
|
32 | target=$$1; \ | |
|
33 | gsub(/:$$/, "", target); \ | |
|
34 | description=substr($$0, index($$0, ":") + 2); \ | |
|
35 | if (description == "") { description="-"; } \ | |
|
36 | printf " - " yellow "%-35s" reset " %s\n", target, description; \ | |
|
37 | } \ | |
|
38 | ' | |
|
39 | ||
|
1 | 40 | # required for pushd to work.. |
|
2 | 41 | SHELL = /bin/bash |
|
3 | 42 | |
|
4 | ||
|
5 | # set by: PATH_TO_OUTDATED_PACKAGES=/some/path/outdated_packages.py | |
|
6 | OUTDATED_PACKAGES = ${PATH_TO_OUTDATED_PACKAGES} | |
|
43 | # >>> Tests commands | |
|
7 | 44 | |
|
8 | 45 | .PHONY: clean |
|
9 |
# |
|
|
46 | # clean: Cleanup compiled and cache py files | |
|
10 | 47 | clean: |
|
11 | 48 | make test-clean |
|
12 | 49 | find . -type f \( -iname '*.c' -o -iname '*.pyc' -o -iname '*.so' -o -iname '*.orig' \) -exec rm '{}' ';' |
|
13 | 50 | find . -type d -name "build" -prune -exec rm -rf '{}' ';' |
|
14 | 51 | |
|
15 | 52 | |
|
16 | 53 | .PHONY: test |
|
17 |
# |
|
|
54 | # test: run test-clean and tests | |
|
18 | 55 | test: |
|
19 | 56 | make test-clean |
|
20 | make test-only | |
|
57 | unset RC_SQLALCHEMY_DB1_URL && unset RC_DB_URL && make test-only | |
|
21 | 58 | |
|
22 | 59 | |
|
23 | 60 | .PHONY: test-clean |
|
24 |
# |
|
|
61 | # test-clean: run test-clean and tests | |
|
25 | 62 | test-clean: |
|
26 | 63 | rm -rf coverage.xml htmlcov junit.xml pylint.log result |
|
27 | 64 | find . -type d -name "__pycache__" -prune -exec rm -rf '{}' ';' |
|
28 | 65 | find . -type f \( -iname '.coverage.*' \) -exec rm '{}' ';' |
|
29 | 66 | |
|
30 | 67 | |
|
31 | 68 | .PHONY: test-only |
|
32 |
# |
|
|
69 | # test-only: Run tests only without cleanup | |
|
33 | 70 | test-only: |
|
34 | 71 | PYTHONHASHSEED=random \ |
|
35 | 72 | py.test -x -vv -r xw -p no:sugar \ |
|
36 | 73 | --cov-report=term-missing --cov-report=html \ |
|
37 | 74 | --cov=vcsserver vcsserver |
|
38 | 75 | |
|
39 | ||
|
40 | .PHONY: ruff-check | |
|
41 | ## run a ruff analysis | |
|
42 | ruff-check: | |
|
43 | ruff check --ignore F401 --ignore I001 --ignore E402 --ignore E501 --ignore F841 --exclude rhodecode/lib/dbmigrate --exclude .eggs --exclude .dev . | |
|
76 | # >>> Dev commands | |
|
44 | 77 | |
|
45 | .PHONY: pip-packages | |
|
46 | ## Show outdated packages | |
|
47 | pip-packages: | |
|
48 | python ${OUTDATED_PACKAGES} | |
|
49 | ||
|
50 | ||
|
51 | .PHONY: build | |
|
52 | ## Build sdist/egg | |
|
53 | build: | |
|
54 | python -m build | |
|
55 | 78 | |
|
56 | 79 | |
|
57 | 80 | .PHONY: dev-sh |
|
58 |
# |
|
|
81 | # dev-sh: make dev-sh | |
|
59 | 82 | dev-sh: |
|
60 | 83 | sudo echo "deb [trusted=yes] https://apt.fury.io/rsteube/ /" | sudo tee -a "/etc/apt/sources.list.d/fury.list" |
|
61 | 84 | sudo apt-get update |
|
62 | 85 | sudo apt-get install -y zsh carapace-bin |
|
63 | 86 | rm -rf /home/rhodecode/.oh-my-zsh |
|
64 | 87 | curl https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh |
|
65 | 88 | @echo "source <(carapace _carapace)" > /home/rhodecode/.zsrc |
|
66 | 89 | @echo "${RC_DEV_CMD_HELP}" |
|
67 | 90 | @PROMPT='%(?.%F{green}β.%F{red}?%?)%f %B%F{240}%1~%f%b %# ' zsh |
|
68 | 91 | |
|
69 | 92 | |
|
70 | 93 | .PHONY: dev-cleanup |
|
71 |
# |
|
|
94 | # dev-cleanup: Cleanup: pip freeze | grep -v "^-e" | grep -v "@" | xargs pip uninstall -y | |
|
72 | 95 | dev-cleanup: |
|
73 | 96 | pip freeze | grep -v "^-e" | grep -v "@" | xargs pip uninstall -y |
|
74 | 97 | rm -rf /tmp/* |
|
75 | 98 | |
|
76 | 99 | |
|
77 | 100 | .PHONY: dev-env |
|
78 |
# |
|
|
101 | # dev-env: make dev-env based on the requirements files and install develop of packages | |
|
79 | 102 | ## Cleanup: pip freeze | grep -v "^-e" | grep -v "@" | xargs pip uninstall -y |
|
80 | 103 | dev-env: |
|
81 | 104 | sudo -u root chown rhodecode:rhodecode /home/rhodecode/.cache/pip/ |
|
82 | 105 | pip install build virtualenv |
|
83 | 106 | pip wheel --wheel-dir=/home/rhodecode/.cache/pip/wheels -r requirements.txt -r requirements_test.txt -r requirements_debug.txt |
|
84 | 107 | pip install --no-index --find-links=/home/rhodecode/.cache/pip/wheels -r requirements.txt -r requirements_test.txt -r requirements_debug.txt |
|
85 | 108 | pip install -e . |
|
86 | 109 | |
|
87 | 110 | |
|
88 | 111 | .PHONY: sh |
|
89 |
# |
|
|
112 | # sh: shortcut for make dev-sh dev-env | |
|
90 | 113 | sh: |
|
91 | 114 | make dev-env |
|
92 | 115 | make dev-sh |
|
93 | 116 | |
|
94 | 117 | |
|
95 | 118 | ## Allows changes of workers e.g make dev-srv-g workers=2 |
|
96 | 119 | workers?=1 |
|
97 | 120 | |
|
98 | 121 | .PHONY: dev-srv |
|
99 |
# |
|
|
122 | # dev-srv: run gunicorn web server with reloader, use workers=N to set multiworker mode, workers=N allows changes of workers | |
|
100 | 123 | dev-srv: |
|
101 | 124 | gunicorn --paste=.dev/dev.ini --bind=0.0.0.0:10010 --config=.dev/gunicorn_config.py --reload --workers=$(workers) |
|
102 | 125 | |
|
103 | ||
|
104 | # Default command on calling make | |
|
105 | .DEFAULT_GOAL := show-help | |
|
126 | .PHONY: ruff-check | |
|
127 | # ruff-check: run a ruff analysis | |
|
128 | ruff-check: | |
|
129 | ruff check --ignore F401 --ignore I001 --ignore E402 --ignore E501 --ignore F841 --exclude rhodecode/lib/dbmigrate --exclude .eggs --exclude .dev . | |
|
106 | 130 |
|
|
107 | .PHONY: show-help | |
|
108 | show-help: | |
|
109 | @echo "$$(tput bold)Available rules:$$(tput sgr0)" | |
|
110 | @echo | |
|
111 | @sed -n -e "/^## / { \ | |
|
112 | h; \ | |
|
113 | s/.*//; \ | |
|
114 | :doc" \ | |
|
115 | -e "H; \ | |
|
116 | n; \ | |
|
117 | s/^## //; \ | |
|
118 | t doc" \ | |
|
119 | -e "s/:.*//; \ | |
|
120 | G; \ | |
|
121 | s/\\n## /---/; \ | |
|
122 | s/\\n/ /g; \ | |
|
123 | p; \ | |
|
124 | }" ${MAKEFILE_LIST} \ | |
|
125 | | LC_ALL='C' sort --ignore-case \ | |
|
126 | | awk -F '---' \ | |
|
127 | -v ncol=$$(tput cols) \ | |
|
128 | -v indent=19 \ | |
|
129 | -v col_on="$$(tput setaf 6)" \ | |
|
130 | -v col_off="$$(tput sgr0)" \ | |
|
131 | '{ \ | |
|
132 | printf "%s%*s%s ", col_on, -indent, $$1, col_off; \ | |
|
133 | n = split($$2, words, " "); \ | |
|
134 | line_length = ncol - indent; \ | |
|
135 | for (i = 1; i <= n; i++) { \ | |
|
136 | line_length -= length(words[i]) + 1; \ | |
|
137 | if (line_length <= 0) { \ | |
|
138 | line_length = ncol - indent - length(words[i]) - 1; \ | |
|
139 | printf "\n%*s ", -indent, " "; \ | |
|
140 | } \ | |
|
141 | printf "%s ", words[i]; \ | |
|
142 | } \ | |
|
143 | printf "\n"; \ | |
|
144 | }' |
General Comments 0
You need to be logged in to leave comments.
Login now