Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
115 lines (85 loc) · 3.59 KB
/
Copy pathMakefile
File metadata and controls
115 lines (85 loc) · 3.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
PROJECT = redbot
NPX=npx --cache .npx-cache -y
STANDARD=$(NPX) standard
WEBPACK=$(NPX) webpack-cli
CSSMIN=$(NPX) cssmin
SASS=$(NPX) sass
J2LINT=$(VENV)/j2lint
MODULES = src/node_modules
JS_ENTRIES = ./src/js/red_script.js ./src/js/red_request.js ./src/js/red_response.js ./src/js/red_response_multi.js
CSSFILES = redbot/assets/red_style.css $(MODULES)/google-code-prettify/src/prettify.css
ICONS = solid/check-circle solid/times-circle solid/question-circle solid/exclamation-circle solid/info-circle
ICON_FILES = $(foreach i, $(ICONS),$(MODULES)/@fortawesome/fontawesome-free/svgs/$(i).svg)
#############################################################################
## Tasks
.PHONY: clean
clean: clean_py
rm -rf .npx-cache .pytest_cache throwaway fail_*.png test_summary.md *.log $(MODULES)
.PHONY: lint
lint: lint_py
$(STANDARD) "src/js/*.js"
$(J2LINT) redbot/formatter/templates/
.PHONY: typecheck
typecheck: typecheck_py
.PHONY: tidy
tidy: tidy_py
$(STANDARD) --fix "src/js/*.js"
#############################################################################
## Tests
# coverage runs every other test file under pytest, so they aren't run separately here; to run
# one on its own, use `make test_<name>`.
.PHONY: test
test: coverage i18n-check test_webui
# Generic rule for running tests
test_%: venv
PYTHONPATH=.:$(VENV) $(VENV)/python test/$@.py
# Specific rule for webui (needs dependencies)
.PHONY: test_webui
test_webui: venv
$(VENV)/playwright install chromium
@echo "Starting test server..."
@PYTHONPATH=.:$(VENV) $(VENV)/python -u test/server.py > server.log 2>&1 & PID=$$!; \
echo "Starting REDbot server..."; \
PYTHONPATH=.:$(VENV) $(VENV)/python -u test/run_redbot.py > redbot.log 2>&1 & RPID=$$!; \
trap "kill $$PID $$RPID; wait $$PID $$RPID; echo '--- Test Server Log ---'; cat server.log; rm server.log; echo '--- REDbot Server Log ---'; cat redbot.log; rm redbot.log" EXIT; \
echo "Waiting for test server..."; \
while ! nc -z localhost 8001; do sleep 0.1; done; \
echo "Waiting for REDbot server..."; \
while ! nc -z localhost 8000; do sleep 0.1; done; \
PYTHONPATH=.:$(VENV) $(VENV)/python test/test_webui.py
.PHONY: coverage
coverage: venv
PYTHONPATH=. $(VENV)/python test/coverage.py
#############################################################################
## Local test server / cli
.PHONY: server
server: venv
PYTHONPATH=.:$(VENV) $(VENV)/python -u redbot/daemon.py config.txt
.PHONY: test_server
test_server: venv
PYTHONPATH=.:$(VENV) $(VENV)/python -u test/server.py
.PHONY: cli
cli: venv
PYTHONPATH=.:$(VENV) $(VENV)/python redbot/cli.py $(filter-out $@,$(MAKECMDGOALS))
#############################################################################
## Assets
.PHONY: redbot/assets
redbot/assets: redbot/assets/script.js redbot/assets/prettify.js redbot/assets/style.css redbot/assets/icons
redbot/assets/prettify.js: $(MODULES)
$(WEBPACK) --entry ./$(MODULES)/google-code-prettify/src/prettify.js --config ./src/js/webpack.config.js --mode production --output-path . --output-filename $@
redbot/assets/script.js: $(MODULES) src/js/*.js
$(WEBPACK) $(JS_ENTRIES) --config ./src/js/webpack.config.js --mode production --output-path . --output-filename $@
redbot/assets/red_style.css: src/scss/*.scss
$(SASS) src/scss/red_style.scss $@
redbot/assets/style.css: $(MODULES) $(CSSFILES)
cat $(CSSFILES) | $(CSSMIN) > $@
redbot/assets/icons: $(MODULES)
mkdir -p $@
cp $(ICON_FILES) $@/
.PHONY: clean-assets
clean-assets:
rm -rf redbot/assets/*.js redbot/assets/*.map redbot/assets/*.css redbot/assets/icons
$(MODULES):
npm i --prefix=./src/
include Makefile.pyproject
include Makefile.i18n