Move build scripts into better places

This commit is contained in:
Jack Kingsman
2026-03-01 18:06:55 -08:00
parent 56d4fa707a
commit 0bde67d66c
7 changed files with 143 additions and 28 deletions

88
scripts/all_quality.sh Normal file
View File

@@ -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}"

19
scripts/deploy.sh Normal file
View File

@@ -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}"

7
scripts/e2e.sh Normal file
View File

@@ -0,0 +1,7 @@
#!/bin/bash
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
cd "$SCRIPT_DIR/tests/e2e"
npx playwright test "$@"

176
scripts/publish.sh Normal file
View File

@@ -0,0 +1,176 @@
#!/bin/bash
set -e
# Colors for output
RED='\033[0;31m'
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
# Run backend linting and type checking
echo -e "${YELLOW}Running backend lint (Ruff)...${NC}"
uv run ruff check app/ tests/ --fix
uv run ruff format app/ tests/
# validate
uv run ruff check app/ tests/
uv run ruff format --check app/ tests/
echo -e "${GREEN}Backend lint passed!${NC}"
echo
echo -e "${YELLOW}Running backend type check (Pyright)...${NC}"
uv run pyright app/
echo -e "${GREEN}Backend type check passed!${NC}"
echo
# Run backend tests
echo -e "${YELLOW}Running backend tests...${NC}"
PYTHONPATH=. uv run pytest tests/ -v
echo -e "${GREEN}Backend tests passed!${NC}"
echo
# Run frontend linting and formatting check
echo -e "${YELLOW}Running frontend lint (ESLint)...${NC}"
cd "$SCRIPT_DIR/frontend"
npm run lint
echo -e "${GREEN}Frontend lint passed!${NC}"
echo
echo -e "${YELLOW}Checking frontend formatting (Prettier)...${NC}"
npm run format:check
echo -e "${GREEN}Frontend formatting OK!${NC}"
echo
# Run frontend tests and build
echo -e "${YELLOW}Running frontend tests...${NC}"
npm run test:run
echo -e "${GREEN}Frontend tests passed!${NC}"
echo
echo -e "${YELLOW}Building frontend...${NC}"
npm run build
echo -e "${GREEN}Frontend build complete!${NC}"
cd "$SCRIPT_DIR"
echo
# Prompt for version
echo -e "${YELLOW}Current versions:${NC}"
echo -n " pyproject.toml: "
grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/'
echo -n " package.json: "
grep '"version"' frontend/package.json | head -1 | sed 's/.*"version": "\(.*\)".*/\1/'
echo
read -p "Enter new version (e.g., 1.2.3): " VERSION
if [[ ! $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo -e "${RED}Error: Version must be in format X.Y.Z${NC}"
exit 1
fi
# Update pyproject.toml
echo -e "${YELLOW}Updating pyproject.toml...${NC}"
sed -i "s/^version = \".*\"/version = \"$VERSION\"/" pyproject.toml
# Update frontend package.json
echo -e "${YELLOW}Updating frontend/package.json...${NC}"
sed -i "s/\"version\": \".*\"/\"version\": \"$VERSION\"/" frontend/package.json
# Update uv.lock with new version
echo -e "${YELLOW}Updating uv.lock...${NC}"
uv sync
echo -e "${GREEN}Version updated to $VERSION${NC}"
echo
# Prompt for changelog entry
echo -e "${YELLOW}Enter changelog entry for version $VERSION${NC}"
echo -e "${YELLOW}(Enter your changes, then press Ctrl+D when done):${NC}"
echo
CHANGELOG_ENTRY=$(cat)
# Create changelog entry with date
DATE=$(date +%Y-%m-%d)
CHANGELOG_HEADER="## [$VERSION] - $DATE"
# Prepend to CHANGELOG.md (after the title if it exists)
if [ -f CHANGELOG.md ]; then
# Check if file starts with a title
if head -1 CHANGELOG.md | grep -q "^# "; then
# Insert after title line
{
head -1 CHANGELOG.md
echo
echo "$CHANGELOG_HEADER"
echo
echo "$CHANGELOG_ENTRY"
echo
tail -n +2 CHANGELOG.md
} > CHANGELOG.md.tmp
mv CHANGELOG.md.tmp CHANGELOG.md
else
# No title, prepend directly
{
echo "$CHANGELOG_HEADER"
echo
echo "$CHANGELOG_ENTRY"
echo
cat CHANGELOG.md
} > CHANGELOG.md.tmp
mv CHANGELOG.md.tmp CHANGELOG.md
fi
else
# Create new changelog
{
echo "# Changelog"
echo
echo "$CHANGELOG_HEADER"
echo
echo "$CHANGELOG_ENTRY"
} > CHANGELOG.md
fi
echo
echo -e "${GREEN}Changelog updated!${NC}"
echo
# Commit the changes
echo -e "${YELLOW}Committing changes...${NC}"
git add .
git commit -m "Updating changelog + build for $VERSION"
git push
echo -e "${GREEN}Changes committed!${NC}"
echo
# Get git short hash (after commit so it reflects the new commit)
GIT_HASH=$(git rev-parse --short HEAD)
# Build docker image
echo -e "${YELLOW}Building Docker image...${NC}"
docker build -t jkingsman/remoteterm-meshcore:latest \
-t jkingsman/remoteterm-meshcore:$VERSION \
-t jkingsman/remoteterm-meshcore:$GIT_HASH .
echo -e "${GREEN}Docker build complete!${NC}"
echo
# Push docker images
echo -e "${YELLOW}Pushing Docker images...${NC}"
docker push jkingsman/remoteterm-meshcore:latest
docker push jkingsman/remoteterm-meshcore:$VERSION
docker push jkingsman/remoteterm-meshcore:$GIT_HASH
echo -e "${GREEN}Docker push complete!${NC}"
echo
echo -e "${GREEN}=== Publish complete! ===${NC}"
echo -e "Version: ${YELLOW}$VERSION${NC}"
echo -e "Git hash: ${YELLOW}$GIT_HASH${NC}"
echo -e "Docker tags pushed:"
echo -e " - jkingsman/remoteterm-meshcore:latest"
echo -e " - jkingsman/remoteterm-meshcore:$VERSION"
echo -e " - jkingsman/remoteterm-meshcore:$GIT_HASH"