forked from OpenHands/OpenHands-CLI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
124 lines (106 loc) · 4.42 KB
/
Copy pathMakefile
File metadata and controls
124 lines (106 loc) · 4.42 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
SHELL := /usr/bin/env bash
.SHELLFLAGS := -eu -o pipefail -c
# Colors for output
ECHO := printf '%b\n'
GREEN := \033[32m
YELLOW := \033[33m
RED := \033[31m
CYAN := \033[36m
UNDERLINE := \033[4m
RESET := \033[0m
REQUIRED_UV_VERSION := 0.11.6
.PHONY: help install install-dev test test-snapshots test-binary format clean run run-watch check-uv-version build install-uv lint pre-commit
check-uv-version:
@$(ECHO) "$(YELLOW)Checking uv version...$(RESET)"
@if ! command -v uv >/dev/null 2>&1; then \
$(ECHO) "$(RED)Error: uv is not installed$(RESET)"; \
$(ECHO) "$(YELLOW)Install uv first with: make install-uv$(RESET)"; \
exit 1; \
fi
@UV_VERSION=$$(uv --version | cut -d' ' -f2); \
REQUIRED_VERSION=$(REQUIRED_UV_VERSION); \
if [ "$$(printf '%s\n' "$$REQUIRED_VERSION" "$$UV_VERSION" | sort -V | head -n1)" != "$$REQUIRED_VERSION" ]; then \
$(ECHO) "$(RED)Error: uv version $$UV_VERSION is less than required $$REQUIRED_VERSION$(RESET)"; \
$(ECHO) "$(YELLOW)Please update uv with: uv self update$(RESET)"; \
exit 1; \
fi; \
$(ECHO) "$(GREEN)uv version $$UV_VERSION meets requirements$(RESET)"
build: check-uv-version
@$(ECHO) "$(CYAN)Setting up OpenHands V1 development environment...$(RESET)"
@$(ECHO) "$(YELLOW)Installing dependencies with uv sync --dev...$(RESET)"
@uv sync --dev
@$(ECHO) "$(GREEN)Dependencies installed successfully.$(RESET)"
@$(ECHO) "$(YELLOW)Setting up pre-commit hooks...$(RESET)"
@uv run pre-commit install
@$(ECHO) "$(GREEN)Pre-commit hooks installed successfully.$(RESET)"
@$(ECHO) "$(GREEN)Build complete! Development environment is ready.$(RESET)"
help:
@echo "OpenHands CLI: Lightweight OpenHands CLI in a binary executable"
@echo ""
@$(ECHO) "$(UNDERLINE)Usage:$(RESET) make <COMMAND>"
@echo ""
@$(ECHO) "$(UNDERLINE)Commands:$(RESET)"
@$(ECHO) " $(CYAN)install$(RESET) Install the package"
@$(ECHO) " $(CYAN)install-dev$(RESET) Install with development dependencies"
@$(ECHO) " $(CYAN)test$(RESET) Run tests"
@$(ECHO) " $(CYAN)test-snapshots$(RESET) Run tests snapshots"
@$(ECHO) " $(CYAN)test-binary$(RESET) Run end-to-end tests"
@$(ECHO) " $(CYAN)test-all$(RESET) Run tests and tests-snapshots"
@$(ECHO) " $(CYAN)lint$(RESET) Lint code with Ruff"
@$(ECHO) " $(CYAN)format$(RESET) Format code with Ruff"
@$(ECHO) " $(CYAN)pre-commit$(RESET) Run pre-commit"
@$(ECHO) " $(CYAN)clean$(RESET) Clean build artifacts"
@$(ECHO) " $(CYAN)run$(RESET) Run the CLI"
@$(ECHO) " $(CYAN)run-watch$(RESET) Run CLI with auto-restart on file changes"
install: check-uv-version
@$(ECHO) "$(YELLOW)Installing the package...$(RESET)"
uv sync
@$(ECHO) "$(GREEN)Package installed successfully.$(RESET)"
install-dev: check-uv-version
@$(ECHO) "$(YELLOW)Installing dev dependencies...$(RESET)"
uv sync --group dev
@$(ECHO) "$(GREEN)Dev dependencies installed successfully.$(RESET)"
test: check-uv-version
@$(ECHO) "$(YELLOW)Run tests...$(RESET)"
uv run pytest --ignore=tests/snapshots
@$(ECHO) "$(GREEN)Tests completed.$(RESET)"
test-snapshots: check-uv-version
@$(ECHO) "$(YELLOW)Run snapshots tests...$(RESET)"
uv run pytest tests/snapshots -v
@$(ECHO) "$(GREEN)Snapshots tests completed.$(RESET)"
test-binary: check-uv-version
@$(ECHO) "$(YELLOW)Run end-to-end tests...$(RESET)"
uv run pytest tui_e2e
@$(ECHO) "$(GREEN)End-to-end tests completed.$(RESET)"
test-all: test test-snapshots
lint: check-uv-version
@$(ECHO) "$(YELLOW)Linting code with uv format...$(RESET)"
uv run ruff check openhands_cli/ --fix
@$(ECHO) "$(GREEN)Code linted successfully.$(RESET)"
format: check-uv-version
@$(ECHO) "$(YELLOW)Formatting code with uv format...$(RESET)"
uv run ruff format openhands_cli/
@$(ECHO) "$(GREEN)Code formatted successfully.$(RESET)"
pre-commit: check-uv-version
@$(ECHO) "$(YELLOW)Run pre-commit...$(RESET)"
uv run pre-commit run --all-files
@$(ECHO) "$(GREEN)Pre-commit run successfully.$(RESET)"
# Clean build artifacts
clean:
rm -rf .venv/
find . -type d -name "__pycache__" -exec rm -rf {} +
find . -type f -name "*.pyc" -delete
# Run the CLI
run:
uv run openhands
# Run the CLI with auto-restart on file changes (.py and .tcss files)
run-watch:
uv run python scripts/run_watch.py
# Install UV if not present
install-uv:
@if ! command -v uv &> /dev/null; then \
echo "Installing UV..."; \
curl -LsSf https://astral.sh/uv/install.sh | sh; \
else \
echo "UV is already installed"; \
fi