Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
192 lines (165 loc) · 9.28 KB
/
Copy pathMakefile
File metadata and controls
192 lines (165 loc) · 9.28 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
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# ByteTable — common developer commands.
# Renderer scripts run via pnpm at the repo root; the Rust core lives in
# src-tauri (driven with --manifest-path so you can run from anywhere).
PNPM := pnpm
CARGO := cargo
MANIFEST := src-tauri/Cargo.toml
# Windows run from cmd.exe / PowerShell: make shells out to cmd.exe, which
# can't run the POSIX recipes below, so borrow the real sh that Git for Windows
# ships. (A bash.exe on PATH is usually WSL's, i.e. a different machine, so
# don't use that.)
#
# ONLY for a native shell: Git Bash / MSYS2 set MSYSTEM, and there make already
# has a POSIX shell and a POSIX, colon-separated PATH. Rewriting either there
# would produce a PATH mixing ';' and ':' that the msys runtime cannot convert,
# so those shells fall through to the Unix branch.
ifeq ($(OS),Windows_NT)
ifndef MSYSTEM
WINDOWS_NATIVE := 1
endif
endif
ifdef WINDOWS_NATIVE
# Candidates, most common first. Every one must be SPACE-FREE: make splits
# variables on whitespace, so "C:/Program Files/..." cannot be used even
# quoted — hence the 8.3 names (~1 = Program Files, ~2 = Program Files (x86)).
# 8.3 generation can be switched off machine-wide (`fsutil 8dot3name query`),
# and Git's "install for me only" lands in LOCALAPPDATA, so the list is probed
# rather than assumed.
GIT_SH_CANDIDATES := \
C:/Progra~1/Git/usr/bin/sh.exe \
C:/Progra~2/Git/usr/bin/sh.exe \
$(subst \,/,$(LOCALAPPDATA))/Programs/Git/usr/bin/sh.exe \
$(subst \,/,$(USERPROFILE))/scoop/apps/git/current/usr/bin/sh.exe
GIT_SH ?= $(firstword $(wildcard $(GIT_SH_CANDIDATES)))
ifeq ($(origin SHELL),command line)
# The caller pointed make at their own sh — respect it and probe nothing.
else ifeq ($(GIT_SH),)
$(error No Git for Windows sh.exe found. Looked in: $(GIT_SH_CANDIDATES). \
Install Git for Windows (https://git-scm.com/download/win), or point make at \
an existing one: make GIT_SH=C:/path/to/Git/usr/bin/sh.exe <target> — the path \
must not contain spaces)
else
SHELL := $(GIT_SH)
endif
.SHELLFLAGS := -c
# Git's usr/bin (grep/awk/sed/uname) goes LAST: it also holds an msys link.exe
# that would shadow MSVC's linker and break cargo builds if it came first.
# PATH stays Windows-style with ';' so the msys runtime converts it for the
# sub-shell. Empty when the caller supplied their own SHELL — nothing to add.
GIT_SH_BIN := $(subst /,\,$(patsubst %/sh.exe,%,$(GIT_SH)))
export PATH := $(USERPROFILE)\.cargo\bin;$(PATH)$(if $(GIT_SH_BIN),;$(GIT_SH_BIN))
else
# Put a rustup-installed toolchain on PATH for every recipe, so a cargo that
# `ensure-cargo` just installed (into ~/.cargo/bin) is found without re-sourcing
# a shell. `export` makes this visible to all recipe sub-shells.
export PATH := $(HOME)/.cargo/bin:$(PATH)
endif
.DEFAULT_GOAL := help
.PHONY: help install hooks ensure-cargo dev dev-cert test lint clippy fmt build build-debug run tag db-up db-down tunnel-up tunnel-down redis-cluster-up redis-cluster-down clean
help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| awk 'BEGIN{FS=":.*?## "}{printf " \033[36m%-12s\033[0m %s\n", $$1, $$2}'
install: ## Install renderer dependencies (pnpm)
$(PNPM) install
hooks: install ## Install the git pre-commit hook (husky + lint-staged)
$(PNPM) exec husky
ensure-cargo: ## Install the Rust toolchain (rustup) if cargo is missing
@command -v cargo >/dev/null 2>&1 && exit 0; \
case "$$(uname -s)" in \
Linux|Darwin|*BSD) \
echo "cargo not found — installing the Rust toolchain via rustup…"; \
command -v curl >/dev/null 2>&1 || { echo "ERROR: curl is required to install Rust. Install curl or Rust manually: https://rustup.rs"; exit 1; }; \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path; \
;; \
MINGW*|MSYS*|CYGWIN*) \
echo "cargo not found."; \
echo "ERROR: install Rust for Windows (the MSVC toolchain Tauri needs):"; \
echo " winget install --id Rustlang.Rustup -e # or https://rustup.rs"; \
echo "Then open a new shell and re-run make."; exit 1;; \
*) echo "ERROR: unsupported OS for auto-install. Install Rust manually: https://rustup.rs"; exit 1;; \
esac; \
command -v cargo >/dev/null 2>&1 || { echo "ERROR: cargo still not on PATH after install — open a new shell or add ~/.cargo/bin to PATH."; exit 1; }
dev: install ensure-cargo ## Run the app in development (Tauri + Vite, hot reload)
$(PNPM) tauri dev
test: install ensure-cargo ## Run the test suite (Rust unit/integration tests + TS typecheck + Vitest)
$(CARGO) test --manifest-path $(MANIFEST)
$(PNPM) typecheck
$(PNPM) test
lint: install ensure-cargo ## Lint everything (ESLint + clippy + rustfmt/prettier checks)
$(PNPM) lint
$(PNPM) format:check
$(CARGO) fmt --manifest-path $(MANIFEST) -- --check
$(CARGO) clippy --manifest-path $(MANIFEST) --all-targets --all-features -- -D warnings
# CI (.github/workflows/ci.yml) runs clippy on the LATEST stable toolchain
# (dtolnay/rust-toolchain@stable, components: clippy) from the src-tauri working
# directory: `cargo clippy --all-targets --all-features -- -D warnings`. Mirror
# that byte-for-byte. Pin to stable (overriding any RUSTUP_TOOLCHAIN the caller's
# shell has set) so a locally-pinned older toolchain can't miss a newer lint that
# CI will fail on.
clippy: ensure-cargo ## Run clippy exactly as CI does (latest stable, all targets/features, deny warnings)
rustup toolchain install stable --profile minimal --component clippy 2>/dev/null || true
cd src-tauri && RUSTUP_TOOLCHAIN=stable $(CARGO) clippy --all-targets --all-features -- -D warnings
fmt: install ensure-cargo ## Auto-format everything (prettier + rustfmt)
$(PNPM) format
$(CARGO) fmt --manifest-path $(MANIFEST)
build: install ensure-cargo ## Build a production desktop bundle (Tauri release)
$(PNPM) tauri build
build-debug: install ensure-cargo ## Build the renderer + a debug binary (fast, no bundling)
$(PNPM) build
$(CARGO) build --manifest-path $(MANIFEST)
@bash scripts/codesign-dev.sh sign 2>/dev/null || true
run: build-debug ## Build (debug) then launch the binary
./src-tauri/target/debug/bytetable
dev-cert: ## macOS: create the stable self-signed identity used to sign dev builds (one-time)
bash scripts/codesign-dev.sh setup
tag: ## Bump the version on dev, merge dev → main, then tag + push the release (usage: make tag VERSION=0.0.2)
@test -n "$(VERSION)" || { echo "usage: make tag VERSION=0.0.2"; exit 1; }
@# git-flow variant A: the version bump originates on dev and flows to
@# main via merge, so dev is never left behind main. Run this on dev.
@test "$$(git rev-parse --abbrev-ref HEAD)" = "dev" || \
{ echo "run 'make tag' on dev — the release flows dev → main"; exit 1; }
@test -z "$$(git status --porcelain)" || \
{ echo "working tree not clean — commit or stash first"; exit 1; }
@git fetch origin -q
@git merge-base --is-ancestor origin/dev HEAD || \
{ echo "local dev is behind origin/dev — pull first"; exit 1; }
@git merge-base --is-ancestor origin/main origin/dev || \
{ echo "origin/main has commits not on dev — merge main → dev first"; exit 1; }
@v=$$(echo "$(VERSION)" | sed 's/^v//'); \
bash scripts/bump-version.sh "$$v" && \
git add src-tauri/tauri.conf.json src-tauri/Cargo.toml src-tauri/Cargo.lock package.json index.html \
src/features/updater/api.ts src/features/workspaces/components/Rail.tsx && \
git commit -m "Release v$$v" && \
git push origin dev && \
git checkout main && \
git merge --ff-only origin/main && \
git merge --ff-only dev && \
git tag -a "v$$v" -m "ByteTable v$$v" && \
git push origin main && \
git push origin "v$$v" && \
git checkout dev && \
echo "Released v$$v: dev → main merged, tagged + pushed — the release workflow will build + publish it."
db-up: ## Start the test databases (Postgres/MySQL/SQL Server/Redis/Redis Cluster/DynamoDB/MongoDB/Cassandra/ClickHouse/Typesense) + seed them
cd test-fixtures && docker compose up -d && ./seed/seed-redis.sh && ./seed/seed-dynamo.sh && ./seed/seed-cassandra.sh && ./seed/seed-mssql.sh && ./seed/seed-typesense.sh
# The cluster is its own compose project (own file + project name), so it is
# a nested make rather than another service in the chain above.
$(MAKE) redis-cluster-up
db-down: ## Stop and wipe the test databases (including the Redis Cluster rig)
cd test-fixtures && docker compose down -v
$(MAKE) redis-cluster-down
tunnel-up: ## Start the SSH-bastion tunnel rig (MySQL/Postgres/Redis behind a bastion) + seed
cd test-fixtures && \
docker compose -p bytetable-tunnel -f docker-compose.tunnel.yml up -d && \
until docker exec bt-redis-tunnel redis-cli -a bytetable ping >/dev/null 2>&1; do sleep 1; done && \
BT_REDIS_CONTAINER=bt-redis-tunnel ./seed/seed-redis.sh
tunnel-down: ## Stop and wipe the SSH-bastion tunnel rig
cd test-fixtures && docker compose -p bytetable-tunnel -f docker-compose.tunnel.yml down -v
redis-cluster-up: ## Start JUST the Redis Cluster rig (3 masters + 3 replicas on 7001-7006) + form and seed it
cd test-fixtures && \
docker compose -p bytetable-rediscluster -f docker-compose.redis-cluster.yml up -d && \
./seed/seed-redis-cluster.sh
redis-cluster-down: ## Stop and wipe JUST the Redis Cluster rig
cd test-fixtures && docker compose -p bytetable-rediscluster -f docker-compose.redis-cluster.yml down -v
clean: ## Remove build artifacts (dist + Rust target)
rm -rf dist
$(CARGO) clean --manifest-path $(MANIFEST)