forked from chatml/chatml
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
103 lines (88 loc) · 4.05 KB
/
Makefile
File metadata and controls
103 lines (88 loc) · 4.05 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
.PHONY: build build-debug dev backend agent-runner clean init deps install-debug test test-cover test-cover-html release
# Load .env file if it exists (for OAuth credentials, API keys)
-include .env
export
# Get the Rust target triple for the current platform
TARGET := $(shell rustc -vV | grep host | cut -d' ' -f2)
# Install npm dependencies if node_modules is missing
deps:
@if [ ! -d "node_modules" ]; then \
echo "Installing npm dependencies..."; \
npm install; \
fi
# Build Go backend for current platform (development - uses env vars at runtime)
backend:
cd backend && go build -o ../src-tauri/binaries/chatml-backend-$(TARGET)
# Build agent-runner TypeScript
agent-runner:
cd agent-runner && npm install && npm run build
# Development mode (auto-installs deps if needed)
# Trap SIGINT/SIGTERM to kill all child processes in the process group
# Note: .env file is auto-loaded and exported (see -include .env above)
dev: deps backend agent-runner
@trap 'kill 0' INT TERM; npm run tauri:dev & wait
# Production build for local dev testing (no signing — use CI for distributable builds)
build: deps backend agent-runner
npm run tauri:build
# Debug build (for testing deep links, OAuth, etc.)
# Note: The updater plugin fails without a valid signing key, but we only need the .app bundle
# We capture the exit code and only fail if both the build failed AND no .app was created
build-debug: deps backend agent-runner
@npm run tauri build -- --debug --bundles app; \
BUILD_EXIT=$$?; \
if [ ! -d src-tauri/target/debug/bundle/macos/chatml.app ]; then \
echo "Build failed - .app not created"; \
exit 1; \
fi; \
if [ $$BUILD_EXIT -ne 0 ]; then \
echo "Note: Build completed with warnings (exit code $$BUILD_EXIT), but .app bundle was created successfully"; \
fi
# Install debug build to /Applications (enables deep link testing)
install-debug: build-debug
@echo "Installing debug build to /Applications..."
@rm -rf /Applications/chatml.app
@cp -r src-tauri/target/debug/bundle/macos/chatml.app /Applications/
@echo "Installed! Run 'open /Applications/chatml.app' to test deep links"
# Prepare a release: bumps version and creates a PR.
# Merging the PR auto-tags main (via auto-tag-release workflow) which triggers the release build.
# Usage: make release VERSION=0.2.0
release:
@if [ -z "$(VERSION)" ]; then echo "Usage: make release VERSION=x.y.z"; exit 1; fi
git checkout main && git pull origin main
@git branch -D release/v$(VERSION) 2>/dev/null || true
@git push origin --delete release/v$(VERSION) 2>/dev/null || true
git checkout -b release/v$(VERSION)
@echo "Bumping version to $(VERSION)..."
@sed -i '' 's/"version": "[^"]*"/"version": "$(VERSION)"/' package.json
@sed -i '' '/"version":/{s/"version": "[^"]*"/"version": "$(VERSION)"/;};' src-tauri/tauri.conf.json
@sed -i '' '/^\[package\]/,/^\[/{s/^version = "[^"]*"/version = "$(VERSION)"/;}' src-tauri/Cargo.toml
npm install --package-lock-only
git add package.json package-lock.json src-tauri/tauri.conf.json src-tauri/Cargo.toml
git diff --cached --quiet && echo "Version already at $(VERSION)" || true
git commit --allow-empty -m "release: v$(VERSION)"
git push -u origin release/v$(VERSION)
gh pr create --title "release: v$(VERSION)" --body "Bump version to $(VERSION)."
@echo "PR created. Merge it to trigger the release build."
# Initialize fresh worktree - explicit setup command
init: deps backend agent-runner
@echo "Worktree initialized. Run 'make dev' to start development."
# Run Go backend tests
test:
cd backend && go test -race ./...
# Run Go backend tests with coverage report
test-cover:
cd backend && go test -race -coverprofile=coverage.out -covermode=atomic ./...
cd backend && go tool cover -func=coverage.out | tail -1
# Generate HTML coverage report
test-cover-html: test-cover
cd backend && go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report: backend/coverage.html"
# Clean build artifacts
clean:
rm -rf src-tauri/binaries/*
rm -rf src-tauri/target
rm -rf backend/chatml-backend
rm -rf out
rm -rf .next
rm -rf agent-runner/dist
rm -rf agent-runner/node_modules