From 98b2c098aa7c7a3ac4122328f0442109bbde3b11 Mon Sep 17 00:00:00 2001 From: Dorian Date: Tue, 10 Mar 2026 23:56:10 +0000 Subject: [PATCH] test: add CI-compatible test runner script Co-Authored-By: Claude Opus 4.6 --- loop/plan.md | 2 +- scripts/run-tests.sh | 87 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 1 deletion(-) create mode 100755 scripts/run-tests.sh diff --git a/loop/plan.md b/loop/plan.md index b0f21f41..7dc72e93 100644 --- a/loop/plan.md +++ b/loop/plan.md @@ -32,7 +32,7 @@ - [x] **TEST-08** — Create backend unit tests: identity module. Add tests to `core/archipelago/src/identity.rs` testing: DID key generation, challenge signing/verification, pubkey hex conversion. Target: 5+ test cases. **Acceptance**: all pass on dev server. -- [ ] **TEST-09** — Add CI-compatible test runner script. Create `scripts/run-tests.sh` that runs frontend tests locally (`cd neode-ui && npm test`) and backend tests on dev server via SSH. Reports pass/fail for both. **Acceptance**: script runs end-to-end, exit 0 when all pass. +- [x] **TEST-09** — Add CI-compatible test runner script. Create `scripts/run-tests.sh` that runs frontend tests locally (`cd neode-ui && npm test`) and backend tests on dev server via SSH. Reports pass/fail for both. **Acceptance**: script runs end-to-end, exit 0 when all pass. #### Sprint 2: Fix Broken UI (Week 3-4) diff --git a/scripts/run-tests.sh b/scripts/run-tests.sh new file mode 100755 index 00000000..62dfca1f --- /dev/null +++ b/scripts/run-tests.sh @@ -0,0 +1,87 @@ +#!/usr/bin/env bash +# +# Run all Archipelago tests: frontend (local) + backend (dev server via SSH). +# Exit 0 only if both pass. +# +set -euo pipefail + +SSH_KEY="${ARCHIPELAGO_SSH_KEY:-$HOME/.ssh/archipelago-deploy}" +SSH_HOST="${ARCHIPELAGO_SSH_HOST:-archipelago@192.168.1.228}" +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +PROJECT_DIR="$(dirname "$SCRIPT_DIR")" + +FRONTEND_OK=0 +BACKEND_OK=0 + +echo "=========================================" +echo " Archipelago Test Runner" +echo "=========================================" +echo "" + +# --- Frontend Tests --- +echo "--- Frontend Tests (local) ---" +if (cd "$PROJECT_DIR/neode-ui" && npm test 2>&1); then + echo "✅ Frontend tests PASSED" + FRONTEND_OK=1 +else + echo "❌ Frontend tests FAILED" +fi + +echo "" + +# --- Backend Tests (on dev server) --- +echo "--- Backend Tests (dev server) ---" + +# Sync source to server +echo "Syncing source to dev server..." +rsync -az --exclude 'target' --exclude 'node_modules' --exclude '.git' \ + -e "ssh -i $SSH_KEY" \ + "$PROJECT_DIR/core/" "$SSH_HOST:~/archy/core/" 2>&1 + +# Run tests on server +if ssh -i "$SSH_KEY" "$SSH_HOST" \ + "source ~/.cargo/env && cd ~/archy/core && cargo test -p archipelago 2>&1"; then + echo "✅ Backend unit tests PASSED" + BACKEND_OK=1 +else + echo "❌ Backend unit tests FAILED" +fi + +echo "" + +# --- Integration Tests --- +echo "--- Integration Tests (dev server) ---" +if ssh -i "$SSH_KEY" "$SSH_HOST" \ + "source ~/.cargo/env && cd ~/archy/core && cargo test --test rpc_integration 2>&1"; then + echo "✅ Integration tests PASSED" +else + echo "❌ Integration tests FAILED" + BACKEND_OK=0 +fi + +echo "" +echo "=========================================" +echo " Results" +echo "=========================================" + +if [ "$FRONTEND_OK" -eq 1 ]; then + echo " Frontend: ✅ PASS" +else + echo " Frontend: ❌ FAIL" +fi + +if [ "$BACKEND_OK" -eq 1 ]; then + echo " Backend: ✅ PASS" +else + echo " Backend: ❌ FAIL" +fi + +echo "=========================================" + +if [ "$FRONTEND_OK" -eq 1 ] && [ "$BACKEND_OK" -eq 1 ]; then + echo "All tests passed!" + exit 0 +else + echo "Some tests failed." + exit 1 +fi