diff --git a/AGENTS.md b/AGENTS.md index 3da7bbb..1244a6c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -4,21 +4,14 @@ **NEVER make git commits.** A human must make all commits. You may stage files and prepare commit messages, but do not run `git commit`. -If instructed to "run all tests" or "get ready for a commit" or other summative, work ending directives, make sure you run the following and that they all pass green: +If instructed to "run all tests" or "get ready for a commit" or other summative, work ending directives, run: ```bash -uv run ruff check app/ tests/ --fix # check for python violations -uv run ruff format app/ tests/ # format python -uv run pyright app/ # type check python -PYTHONPATH=. uv run pytest tests/ -v # test python - -cd frontend/ # move to frontend directory -npm run lint:fix # fix lint violations -npm run format # format the code -npm run test:run # run frontend tests -npm run build # run a frontend build +./scripts/all_quality.sh ``` +This runs all linting, formatting, type checking, tests, and builds for both backend and frontend in parallel. All checks must pass green. + ## Overview A web interface for MeshCore mesh radio networks. The backend connects to a MeshCore-compatible radio over Serial, TCP, or BLE and exposes REST/WebSocket APIs. The React frontend provides real-time messaging and radio configuration. @@ -171,6 +164,10 @@ This message-layer echo/path handling is independent of raw-packet storage dedup │ │ ├── MapView.tsx # Leaflet map showing node locations │ │ └── ... │ └── vite.config.ts +├── scripts/ +│ ├── all_quality.sh # Run all lint, format, typecheck, tests, build (parallelized) +│ ├── publish.sh # Version bump, changelog, docker build & push +│ └── deploy.sh # Deploy to production server ├── tests/ # Backend tests (pytest) ├── data/ # SQLite database (runtime) └── pyproject.toml # Python dependencies @@ -246,20 +243,7 @@ npm run test:run ### Before Completing Changes -**Always run both backend and frontend validation before finishing any changes:** - -```bash -# From project root - run backend tests -PYTHONPATH=. uv run pytest tests/ -v - -# From project root - run frontend tests and build -cd frontend && npm run test:run && npm run build -``` - -This catches: -- Type mismatches between frontend and backend (e.g., missing fields in TypeScript interfaces) -- Breaking changes to shared types or API contracts -- Runtime errors that only surface during compilation +**Always run `./scripts/all_quality.sh` before finishing any changes.** This runs all linting, formatting, type checking, tests, and builds in parallel, catching type mismatches, breaking changes, and compilation errors. ## API Summary diff --git a/README.md b/README.md index 4ddbead..301551c 100644 --- a/README.md +++ b/README.md @@ -161,8 +161,14 @@ Run both the backend and `npm run dev` for hot-reloading frontend development. Please test, lint, format, and quality check your code before PRing or committing. At the least, run a lint + autoformat + pyright check on the backend, and a lint + autoformat on the frontend. +Run everything at once (parallelized): + +```bash +./scripts/all_quality.sh +``` +
-But how? +Or run individual checks ```bash # python diff --git a/frontend/AGENTS.md b/frontend/AGENTS.md index c047da2..45896f9 100644 --- a/frontend/AGENTS.md +++ b/frontend/AGENTS.md @@ -276,6 +276,14 @@ Do not rely on old class-only layout assumptions. ## Testing +Run all quality checks (backend + frontend, parallelized) from the repo root: + +```bash +./scripts/all_quality.sh +``` + +Or run frontend checks individually: + ```bash cd frontend npm run test:run diff --git a/scripts/all_quality.sh b/scripts/all_quality.sh new file mode 100644 index 0000000..c978ff5 --- /dev/null +++ b/scripts/all_quality.sh @@ -0,0 +1,88 @@ +#!/bin/bash +set -e + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)" + +echo -e "${YELLOW}=== RemoteTerm Quality Checks ===${NC}" +echo + +# --- Phase 1: Lint + Format (backend ∥ frontend) --- + +echo -e "${YELLOW}=== Phase 1: Lint & Format ===${NC}" + +( + echo -e "${BLUE}[backend lint]${NC} Running ruff check + format..." + cd "$SCRIPT_DIR" + uv run ruff check app/ tests/ --fix + uv run ruff format app/ tests/ + echo -e "${GREEN}[backend lint]${NC} Passed!" +) & +PID_BACKEND_LINT=$! + +( + echo -e "${BLUE}[frontend lint]${NC} Running eslint + prettier..." + cd "$SCRIPT_DIR/frontend" + npm run lint:fix + npm run format + echo -e "${GREEN}[frontend lint]${NC} Passed!" +) & +PID_FRONTEND_LINT=$! + +FAIL=0 +wait $PID_BACKEND_LINT || FAIL=1 +wait $PID_FRONTEND_LINT || FAIL=1 +if [ $FAIL -ne 0 ]; then + echo -e "${RED}Phase 1 failed — aborting.${NC}" + exit 1 +fi +echo -e "${GREEN}=== Phase 1 complete ===${NC}" +echo + +# --- Phase 2: Typecheck + Tests + Build (all parallel) --- + +echo -e "${YELLOW}=== Phase 2: Typecheck, Tests & Build ===${NC}" + +( + echo -e "${BLUE}[pyright]${NC} Running type check..." + cd "$SCRIPT_DIR" + uv run pyright app/ + echo -e "${GREEN}[pyright]${NC} Passed!" +) & +PID_PYRIGHT=$! + +( + echo -e "${BLUE}[pytest]${NC} Running backend tests..." + cd "$SCRIPT_DIR" + PYTHONPATH=. uv run pytest tests/ -v + echo -e "${GREEN}[pytest]${NC} Passed!" +) & +PID_PYTEST=$! + +( + echo -e "${BLUE}[frontend]${NC} Running tests + build..." + cd "$SCRIPT_DIR/frontend" + npm run test:run + npm run build + echo -e "${GREEN}[frontend]${NC} Passed!" +) & +PID_FRONTEND=$! + +FAIL=0 +wait $PID_PYRIGHT || FAIL=1 +wait $PID_PYTEST || FAIL=1 +wait $PID_FRONTEND || FAIL=1 +if [ $FAIL -ne 0 ]; then + echo -e "${RED}Phase 2 failed — aborting.${NC}" + exit 1 +fi +echo -e "${GREEN}=== Phase 2 complete ===${NC}" +echo + +echo -e "${GREEN}=== All quality checks passed! ===${NC}" diff --git a/scripts/deploy.sh b/scripts/deploy.sh new file mode 100644 index 0000000..bf68115 --- /dev/null +++ b/scripts/deploy.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -e + +# Colors for output +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' # No Color + +echo -e "${YELLOW}Deploying to production server...${NC}" +ssh jack@192.168.1.199 "\ + cd /opt/remoteterm/ && \ + sudo -u remoteterm git checkout main && \ + sudo -u remoteterm git pull && \ + cd frontend && \ + sudo -u remoteterm bash -c 'source ~/.nvm/nvm.sh && npm install && npm run build' && \ + sudo systemctl restart remoteterm && \ + sudo journalctl -u remoteterm -f" + +echo -e "${GREEN}=== Deploy complete! ===${NC}" diff --git a/scripts/e2e.sh b/scripts/e2e.sh new file mode 100644 index 0000000..484130b --- /dev/null +++ b/scripts/e2e.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -e + +SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)" + +cd "$SCRIPT_DIR/tests/e2e" +npx playwright test "$@" diff --git a/publish.sh b/scripts/publish.sh similarity index 97% rename from publish.sh rename to scripts/publish.sh index d098f42..6e0b264 100644 --- a/publish.sh +++ b/scripts/publish.sh @@ -7,6 +7,9 @@ GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color +SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)" +cd "$SCRIPT_DIR" + echo -e "${YELLOW}=== RemoteTerm for MeshCore Publish Script ===${NC}" echo @@ -33,7 +36,7 @@ echo # Run frontend linting and formatting check echo -e "${YELLOW}Running frontend lint (ESLint)...${NC}" -cd frontend +cd "$SCRIPT_DIR/frontend" npm run lint echo -e "${GREEN}Frontend lint passed!${NC}" echo @@ -52,7 +55,7 @@ echo echo -e "${YELLOW}Building frontend...${NC}" npm run build echo -e "${GREEN}Frontend build complete!${NC}" -cd .. +cd "$SCRIPT_DIR" echo # Prompt for version