-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
151 lines (104 loc) · 4.26 KB
/
Makefile
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
SHELL = /bin/bash
BULMA_VERSION := 1.0.0
BULMA_SLIDER_VERSION := 2.0.5
FONTAWESOME_VERSION := 6.1.1
PYTHON_PACKAGES := valens tests tools fabfile.py
FRONTEND_FILES := index.css manifest.json service-worker.js valens-frontend.js valens-frontend_bg.wasm fonts images js
PACKAGE_FRONTEND_FILES := valens/frontend $(addprefix valens/frontend/,$(FRONTEND_FILES))
BUILD_DIR := $(PWD)/build
CONFIG_FILE := $(BUILD_DIR)/config.py
VERSION ?= $(shell uv run -- hatch version)
WHEEL ?= dist/valens-$(VERSION)-py3-none-any.whl
export SQLALCHEMY_WARN_20=1
.PHONY: all
all: check test
.PHONY: check check_general check_lockfile check_kacl check_frontend check_backend check_black check_ruff check_mypy
check: check_frontend check_backend
check_general: check_lockfile check_kacl
check_lockfile:
uv lock --locked
check_kacl:
uv run -- kacl-cli verify
check_frontend:
cargo fmt -- --check
cargo check
cargo clippy -- --warn clippy::pedantic --deny warnings
check_backend: check_lockfile check_black check_ruff check_mypy
check_black:
uv run -- black --check --diff $(PYTHON_PACKAGES)
check_ruff:
uv run -- ruff check $(PYTHON_PACKAGES)
check_mypy:
uv run -- mypy --pretty $(PYTHON_PACKAGES)
.PHONY: format
format:
cargo fmt
uv run -- ruff check --fix-only $(PYTHON_PACKAGES) | true
uv run -- black $(PYTHON_PACKAGES)
.PHONY: test test_frontend test_backend test_e2e
test: test_frontend test_backend test_installation test_e2e
test_frontend:
cargo llvm-cov nextest --no-fail-fast
test_backend:
mkdir -p valens/frontend
touch $(addprefix valens/frontend/,$(FRONTEND_FILES))
uv run -- pytest -n$(shell nproc) -vv --cov=valens --cov-branch --cov-fail-under=100 --cov-report=term-missing:skip-covered tests/backend
test_installation: $(BUILD_DIR)/venv/bin/valens
$(BUILD_DIR)/venv/bin/valens --version
test_e2e: $(BUILD_DIR)/venv/bin/valens
uv run -- pytest -n$(shell nproc) -vv --driver chrome --headless tests/e2e
$(BUILD_DIR)/venv:
python3 -m venv $(BUILD_DIR)/venv
$(BUILD_DIR)/venv/bin/valens: $(BUILD_DIR)/venv $(WHEEL)
$(BUILD_DIR)/venv/bin/pip install --force-reinstall $(WHEEL)
test -f $(BUILD_DIR)/venv/bin/valens
touch --no-create $(BUILD_DIR)/venv/bin/valens
.PHONY: update update_css update_fonts
update: update_css update_fonts
update_css: third-party/bulma third-party/bulma-slider
update_fonts: third-party/fontawesome
cp third-party/fontawesome/webfonts/fa-solid-900.{woff2,ttf} frontend/assets/fonts/
third-party/bulma:
wget -qO- https://github.com/jgthms/bulma/releases/download/$(BULMA_VERSION)/bulma-$(BULMA_VERSION).zip | bsdtar -xf- -C third-party
rm -rf third-party/bulma/css
third-party/bulma-slider:
wget -qO- https://github.com/Wikiki/bulma-slider/archive/refs/tags/v$(BULMA_SLIDER_VERSION).tar.gz | bsdtar -xf- -C third-party
mv third-party/bulma-slider-$(BULMA_SLIDER_VERSION) third-party/bulma-slider
rm -rf third-party/bulma-slider/{.*,dist,src/js,test,*.js,*.json,*.png}
third-party/fontawesome:
wget -qO- https://use.fontawesome.com/releases/v$(FONTAWESOME_VERSION)/fontawesome-free-$(FONTAWESOME_VERSION)-web.zip | bsdtar -xf- -C third-party
rm -rf third-party/fontawesome
mv third-party/fontawesome-* third-party/fontawesome
rm -rf third-party/fontawesome/{css,js,less,metadata,sprites,svgs}
.PHONY: screenshots
screenshots: $(PACKAGE_FRONTEND_FILES)
tools/create_screenshots.py
.PHONY: dist
dist: $(WHEEL)
$(WHEEL): $(PACKAGE_FRONTEND_FILES)
uv build
valens/frontend:
mkdir -p valens/frontend
valens/frontend/%: frontend/dist/%
rm -rf $@
cp -r $< $@
$(addprefix frontend/dist/,$(FRONTEND_FILES)): third-party/bulma third-party/fontawesome $(shell find frontend/src/ -type f -name '*.rs')
cd frontend && trunk build --release --filehash false
.PHONY: run run_frontend run_backend
run:
tmux new-window $(MAKE) CONFIG_FILE=$(CONFIG_FILE) run_frontend
tmux new-window $(MAKE) CONFIG_FILE=$(CONFIG_FILE) run_backend
run_frontend:
PATH=~/.cargo/bin:${PATH} trunk --config frontend/Trunk.toml serve --port 8000
run_backend: $(CONFIG_FILE)
VALENS_CONFIG=$(CONFIG_FILE) uv run -- flask --app valens --debug run -h 0.0.0.0
$(CONFIG_FILE): $(BUILD_DIR)
uv run -- valens config -d build
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
.PHONY: clean clean_all
clean:
rm -rf $(BUILD_DIR)
rm -rf valens.egg-info
rm -rf valens/frontend
cd frontend && trunk clean && cargo clean