-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
139 lines (117 loc) · 3.87 KB
/
Copy pathMakefile
File metadata and controls
139 lines (117 loc) · 3.87 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
# Makefile for Synapse Rust workspace
# Default target
help:
@echo "Available targets:"
@echo " setup - Install development dependencies"
@echo " setup-python - Set up Python virtual environment with uv"
@echo " build - Build all workspace members"
@echo " test - Run tests for all workspace members"
@echo " fmt - Format code"
@echo " fmt-check - Check code formatting (for CI)"
@echo " lint - Run clippy linter (warnings as errors)"
@echo " fix - Auto-fix formatting and clippy issues"
@echo " check - Run cargo check"
@echo " clean - Clean build artifacts"
@echo " run-locator - Run the locator service"
@echo " run-proxy - Run the proxy service"
@echo " run-ingest-router - Run the ingest-router service"
@echo " run-mock-control-api - Run the mock control API server"
.PHONY: help
# Setup development environment
setup: setup-python
rustup update
cargo install cargo-watch
@echo "Setting up Git hooks..."
@mkdir -p .git/hooks
@cp scripts/pre-commit .git/hooks/pre-commit
@chmod +x .git/hooks/pre-commit
@echo "Git pre-commit hook installed successfully!"
.PHONY: setup
# Setup Python virtual environment with uv
setup-python:
@echo "Setting up Python virtual environment with uv..."
@command -v uv >/dev/null 2>&1 || { echo "Error: uv is not installed. Install it from https://docs.astral.sh/uv/getting-started/installation/"; exit 1; }
uv venv .venv --python 3.13
@echo "Python virtual environment created at .venv"
@echo "Run 'direnv allow' to automatically activate the virtual environment"
.PHONY: setup-python
# Build all workspace members
build:
cargo build --workspace
.PHONY: build
# Test all workspace members
test:
docker compose -f docker-compose.test.yml up -d
curl -s -X POST \
-H "Content-Type: application/json" \
-d '{"name":"test-bucket"}' \
http://localhost:4443/storage/v1/b?project=test-project
cargo test --workspace
docker compose -f docker-compose.test.yml down -v
.PHONY: test
# Format code
fmt:
cargo fmt --all
.PHONY: fmt
# Check code formatting (for CI)
fmt-check:
cargo fmt --all -- --check
.PHONY: fmt-check
# Run clippy linter
lint:
cargo clippy --workspace -- -D warnings
.PHONY: lint
# Auto-fix formatting and clippy issues
fix:
cargo fmt --all
cargo clippy --workspace --fix --allow-dirty
.PHONY: fix
# Run cargo check
check:
cargo check --workspace
.PHONY: check
# Clean build artifacts
clean:
cargo clean
.PHONY: clean
# Run services
run-locator:
cargo run locator --config-file-path example_config_locator.yaml
.PHONY: run-locator
run-locator-gcs:
cargo run locator --config-file-path example_config_locator_gcs.yaml
run-proxy:
cargo run proxy --config-file-path example_config_proxy.yaml
.PHONY: run-proxy
run-ingest-router: generate-credentials
cargo run ingest-router --config-file-path example_config_ingest_router.yaml --credentials-path relay-credentials.json
.PHONY: run-ingest-router
generate-credentials:
@test -f relay-credentials.json || cargo run generate-relay-credentials > relay-credentials.json
.PHONY: generate-credentials
run-mock-control-api:
python scripts/mock_control_api.py
.PHONY: run-mock-control-api
run-mock-relay-api:
python scripts/mock_relay_api.py
.PHONY: run-mock-relay-api
# CI-like checks (what runs in GitHub Actions)
ci: fmt-check lint test build
@echo "All CI checks passed!"
.PHONY: ci
# Server for testing proxy locally
run-echo-server:
python scripts/echo_server.py
.PHONY: run-echo-server
# Build Docker image for local testing
build-docker-local:
docker buildx build --platform linux/amd64 -t synapse --load .
.PHONY: build-docker-local
# Run locally built docker image, for testing locally
run-docker-proxy-local:
docker run \
--platform linux/amd64 \
-v $(PWD)/example_config_proxy.yaml:/app/example_config_proxy.yaml \
--rm synapse proxy \
--config-file-path example_config_proxy.yaml
.PHONY: run-docker-local