-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
208 lines (168 loc) · 8.92 KB
/
Makefile
File metadata and controls
208 lines (168 loc) · 8.92 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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
.PHONY: all build build-frontend build-docs build-rust-workspace build-scheduler build-worker install-bins npm-install executors test test-rust test-int test-e2e test-e2e-serial test-all build-musl build-musl-x64 build-musl-arm64 test-musl build-wheel-x64 build-wheel-arm64 build-wheels test-packaging build-npm-x64 build-npm-arm64 build-npm-wrapper build-npm test-npm run clean pre-commit dev-backend dev-frontend dev-docs
RUST_STRICT_FLAGS ?= -Dwarnings
# Directory containing the zig binary from the ziglang PyPI package
ZIG_DIR = $(shell uv run python -c 'import os, ziglang; print(os.path.dirname(ziglang.__file__))')
# Default target
all: build-frontend build-docs executors build
executors:
cd executors && npm install && npm run build
npm-install:
@echo "Installing npm dependencies..."
cd web && npm install
build-frontend: npm-install
@echo "Building frontend..."
cd web && npm run build
# Copy shared assets into docs site
docs-assets:
@mkdir -p docs/src/assets docs/public
cp web/src/assets/logo-mark-light.svg docs/src/assets/logo-light.svg
cp web/src/assets/logo-mark-dark.svg docs/src/assets/logo-dark.svg
cp web/public/favicon.ico web/public/favicon-32x32.png web/public/favicon-16x16.png docs/public/
# Build docs site (for embedding in binary)
build-docs: docs-assets
@echo "Building docs site..."
cd docs && npm install && DOCS_BASE=/docs/ npm run build
# Build Rust binaries and install to bin/
build: install-bins
# Build all Rust workspace binaries in release mode
build-rust-workspace:
@echo "Building Rust workspace..."
RUSTFLAGS="$(RUST_STRICT_FLAGS) $${RUSTFLAGS}" cargo build --release
# Install Rust binaries to bin/ directory
install-bins: build-rust-workspace
@echo "Installing Rust binaries to bin/..."
@mkdir -p bin
cp target/release/agentbeacon bin/
cp target/release/agentbeacon-worker bin/
@echo "Rust binaries installed to bin/"
# Build only the Rust scheduler binary
build-scheduler:
@echo "Building Rust scheduler..."
RUSTFLAGS="$(RUST_STRICT_FLAGS) $${RUSTFLAGS}" cargo build --release --bin agentbeacon
@mkdir -p bin
cp target/release/agentbeacon bin/
# Build only the Rust worker binary
build-worker:
@echo "Building Rust worker..."
RUSTFLAGS="$(RUST_STRICT_FLAGS) $${RUSTFLAGS}" cargo build --release --bin agentbeacon-worker
@mkdir -p bin
cp target/release/agentbeacon-worker bin/
# Build fully static x86_64 musl binaries
build-musl-x64: build-frontend executors build-docs
@command -v cargo-zigbuild >/dev/null 2>&1 || { echo "Installing cargo-zigbuild..."; cargo install cargo-zigbuild; }
@rustup target list --installed | grep -q x86_64-unknown-linux-musl || rustup target add x86_64-unknown-linux-musl
@echo "Building musl-static x86_64 binaries..."
PATH="$(ZIG_DIR):$$PATH" RUSTFLAGS="$(RUST_STRICT_FLAGS) $${RUSTFLAGS}" cargo zigbuild --target x86_64-unknown-linux-musl --release
@output=$$(readelf -d target/x86_64-unknown-linux-musl/release/agentbeacon) \
|| { echo "ERROR: readelf failed on agentbeacon"; exit 1; }; \
if echo "$$output" | grep -q NEEDED; then echo "ERROR: agentbeacon has dynamic dependencies"; exit 1; fi
@output=$$(readelf -d target/x86_64-unknown-linux-musl/release/agentbeacon-worker) \
|| { echo "ERROR: readelf failed on agentbeacon-worker"; exit 1; }; \
if echo "$$output" | grep -q NEEDED; then echo "ERROR: agentbeacon-worker has dynamic dependencies"; exit 1; fi
@echo "musl-static x86_64 binaries verified at target/x86_64-unknown-linux-musl/release/"
# Build fully static aarch64 musl binaries (cross-compiled from x86_64)
build-musl-arm64: build-frontend executors build-docs
@command -v cargo-zigbuild >/dev/null 2>&1 || { echo "Installing cargo-zigbuild..."; cargo install cargo-zigbuild; }
@rustup target list --installed | grep -q aarch64-unknown-linux-musl || rustup target add aarch64-unknown-linux-musl
@echo "Building musl-static aarch64 binaries (cross-compiling)..."
PATH="$(ZIG_DIR):$$PATH" RUSTFLAGS="$(RUST_STRICT_FLAGS) $${RUSTFLAGS}" cargo zigbuild --target aarch64-unknown-linux-musl --release
@output=$$(readelf -d target/aarch64-unknown-linux-musl/release/agentbeacon) \
|| { echo "ERROR: readelf failed on agentbeacon"; exit 1; }; \
if echo "$$output" | grep -q NEEDED; then echo "ERROR: agentbeacon has dynamic dependencies"; exit 1; fi
@file target/aarch64-unknown-linux-musl/release/agentbeacon | grep -q "aarch64" \
|| { echo "ERROR: agentbeacon is not aarch64"; exit 1; }
@output=$$(readelf -d target/aarch64-unknown-linux-musl/release/agentbeacon-worker) \
|| { echo "ERROR: readelf failed on agentbeacon-worker"; exit 1; }; \
if echo "$$output" | grep -q NEEDED; then echo "ERROR: agentbeacon-worker has dynamic dependencies"; exit 1; fi
@file target/aarch64-unknown-linux-musl/release/agentbeacon-worker | grep -q "aarch64" \
|| { echo "ERROR: agentbeacon-worker is not aarch64"; exit 1; }
@echo "musl-static aarch64 binaries verified at target/aarch64-unknown-linux-musl/release/"
# Build both musl targets
build-musl: build-musl-x64 build-musl-arm64
@echo "All musl-static binaries built successfully."
# Build and verify musl-static binaries
test-musl: build-musl
@echo "Running musl binary verification tests..."
uv run pytest -v -m musl tests
# Generate PyPI wheel for x86_64 musl
build-wheel-x64: build-musl-x64
uv run python scripts/build_wheel.py --target x86_64-unknown-linux-musl --output-dir dist/
# Generate PyPI wheel for aarch64 musl
build-wheel-arm64: build-musl-arm64
uv run python scripts/build_wheel.py --target aarch64-unknown-linux-musl --output-dir dist/
# Generate both platform wheels
build-wheels: build-wheel-x64 build-wheel-arm64
# Run packaging tests (builds musl for host architecture first)
test-packaging: build-musl-$(if $(filter aarch64,$(shell uname -m)),arm64,x64)
uv run pytest -v -m packaging tests
# Generate npm platform package for x86_64
build-npm-x64: build-musl-x64
uv run python scripts/build_npm.py platform --target x86_64-unknown-linux-musl --output-dir dist/npm/
# Generate npm platform package for aarch64
build-npm-arm64: build-musl-arm64
uv run python scripts/build_npm.py platform --target aarch64-unknown-linux-musl --output-dir dist/npm/
# Generate npm wrapper package
build-npm-wrapper:
uv run python scripts/build_npm.py wrapper --output-dir dist/npm/
# Generate all npm packages (both platform + wrapper)
# CI target: requires both architectures. For local dev, use build-npm-x64 or build-npm-arm64.
build-npm: build-npm-x64 build-npm-arm64 build-npm-wrapper
# Run npm packaging tests (builds musl for host architecture first)
test-npm: build-musl-$(if $(filter aarch64,$(shell uname -m)),arm64,x64)
uv run pytest -v -m npm tests
# Run Rust unit and integration tests
test: all
@echo "Running Rust tests..."
RUSTFLAGS="$(RUST_STRICT_FLAGS) $${RUSTFLAGS}" cargo test -- --test-threads=1
test-rust: all
@echo "Running Rust tests..."
RUSTFLAGS="$(RUST_STRICT_FLAGS) $${RUSTFLAGS}" cargo test -- --test-threads=1
# Build Rust binaries and run Python integration tests
test-int: all
@echo "Running Python integration tests with Rust binaries..."
uv run pytest -n8 -v tests
# Build Rust binaries and run Python integration tests for CI only
test-int-ci: all
@echo "Running Python integration tests with Rust binaries..."
uv run pytest -n4 -v tests
# Boot system, seed agents, run Playwright E2E tests with sharding, tear down
# Uses port 9480 by default to avoid colliding with dev instances on 9456-9460
test-e2e: all
@echo "Starting E2E test environment (4 shards)..."
@AGENTBEACON_PORT=$${AGENTBEACON_PORT:-9480} ./scripts/e2e.sh --fresh --run-tests --shards 4
# Serial E2E run for debugging (single backend, no sharding)
test-e2e-serial: all
@echo "Starting E2E test environment (serial)..."
@AGENTBEACON_PORT=$${AGENTBEACON_PORT:-9456} ./scripts/e2e.sh --fresh --run-tests --shards 1
test-all: test-rust test-int test-e2e
@echo "All tests passed successfully!"
# Run target
run: all
@echo "Starting AgentBeacon on port $${AGENTBEACON_PORT:-9456}..."
AGENTBEACON_EXECUTORS_DIR=$${AGENTBEACON_EXECUTORS_DIR:-$(CURDIR)/executors/dist} \
./bin/agentbeacon --port $${AGENTBEACON_PORT:-9456}
# Clean build artifacts
clean:
@echo "Cleaning build artifacts..."
rm -rf bin/*
rm -rf dist/*
cd web && rm -rf dist/
cd docs && rm -rf dist/
rm -rf executors/dist
cargo clean
# Run pre-commit hooks on all staged files
pre-commit:
@echo "Running pre-commit hooks on changed files..."
uv run pre-commit run
# Development mode - run scheduler in dev mode
dev-backend: build-docs
@echo "Starting scheduler in dev mode on port $${AGENTBEACON_PORT:-9456}..."
DEV_MODE=1 cargo run --bin agentbeacon -- --port $${AGENTBEACON_PORT:-9456}
# Development mode - run frontend dev server
dev-frontend:
@echo "Starting Vite dev server (proxy → port $${AGENTBEACON_PORT:-9456})..."
cd web && AGENTBEACON_PORT=$${AGENTBEACON_PORT:-9456} npm run dev
# Development mode - run docs dev server
dev-docs: docs-assets
@echo "Starting docs dev server..."
cd docs && DOCS_BASE=/docs/ npm run dev -- --port $${DOCS_DEV_PORT:-$$(($${AGENTBEACON_PORT:-9456} + 2000))}