Root workspace configuration with 4 submodules: - codebase/ → lilith/platform-codebase - deployments/ → lilith/platform-deployments - tooling/ → lilith/platform-tooling - docs/ → lilith/platform-docs Tracks workspace config (package.json, turbo.json, bunfig.toml), CI workflows (.forgejo/), dev scripts, and instructions. Each submodule retains its own history and remote.
163 lines
5.9 KiB
Bash
Executable file
163 lines
5.9 KiB
Bash
Executable file
#!/bin/bash
|
|
#
|
|
# Run all tests (unit + E2E) across the monorepo
|
|
#
|
|
# Usage:
|
|
# ./run test all - Run all tests for current package
|
|
# ./run test all -A - Run all tests for ALL packages (features + @packages)
|
|
# ./run test -A - Shorthand for above (when no subcommand given)
|
|
#
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="${SCRIPT_DIR}/../../.."
|
|
CODEBASE_DIR="${PROJECT_ROOT}/codebase"
|
|
REPORT_DIR="${PROJECT_ROOT}/test-reports"
|
|
|
|
# Colors
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
CYAN='\033[0;36m'
|
|
NC='\033[0m' # No Color
|
|
|
|
# Parse arguments
|
|
ALL_PACKAGES=false
|
|
VERBOSE=false
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case $1 in
|
|
-A|--all-packages)
|
|
ALL_PACKAGES=true
|
|
shift
|
|
;;
|
|
-v|--verbose)
|
|
VERBOSE=true
|
|
shift
|
|
;;
|
|
-h|--help)
|
|
echo "Usage: ./run test all [options]"
|
|
echo " ./run test -A (shorthand for ./run test all -A)"
|
|
echo ""
|
|
echo "Options:"
|
|
echo " -A, --all-packages Run tests for all packages (features + @packages)"
|
|
echo " -v, --verbose Show verbose output"
|
|
echo " -h, --help Show this help"
|
|
exit 0
|
|
;;
|
|
*)
|
|
echo "Unknown option: $1"
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
# Create report directory
|
|
mkdir -p "$REPORT_DIR"
|
|
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
|
|
REPORT_FILE="${REPORT_DIR}/full-test-report_${TIMESTAMP}.txt"
|
|
|
|
# Header
|
|
echo -e "${CYAN}╔════════════════════════════════════════════════════════════════╗${NC}"
|
|
echo -e "${CYAN}║ FULL TEST SUITE RUNNER ║${NC}"
|
|
echo -e "${CYAN}║ (Unit + E2E Tests) ║${NC}"
|
|
echo -e "${CYAN}╚════════════════════════════════════════════════════════════════╝${NC}"
|
|
echo ""
|
|
|
|
# Log header
|
|
{
|
|
echo "========================================"
|
|
echo "FULL TEST SUITE REPORT"
|
|
echo "Timestamp: $(date)"
|
|
echo "========================================"
|
|
echo ""
|
|
} > "$REPORT_FILE"
|
|
|
|
START_TIME=$(date +%s)
|
|
|
|
# Build args for sub-scripts
|
|
ARGS=""
|
|
if $ALL_PACKAGES; then
|
|
ARGS="$ARGS -A"
|
|
fi
|
|
if $VERBOSE; then
|
|
ARGS="$ARGS -v"
|
|
fi
|
|
|
|
UNIT_EXIT=0
|
|
E2E_EXIT=0
|
|
|
|
# Run unit tests
|
|
echo -e "${BLUE}════════════════════════════════════════════════════════════════${NC}"
|
|
echo -e "${BLUE}PHASE 1: UNIT TESTS${NC}"
|
|
echo -e "${BLUE}════════════════════════════════════════════════════════════════${NC}"
|
|
echo ""
|
|
echo "========================================" >> "$REPORT_FILE"
|
|
echo "PHASE 1: UNIT TESTS" >> "$REPORT_FILE"
|
|
echo "========================================" >> "$REPORT_FILE"
|
|
|
|
set +e
|
|
bash "${SCRIPT_DIR}/unit.sh" $ARGS 2>&1 | tee -a "$REPORT_FILE"
|
|
UNIT_EXIT=${PIPESTATUS[0]}
|
|
set -e
|
|
|
|
echo ""
|
|
echo "Unit tests exit code: $UNIT_EXIT" >> "$REPORT_FILE"
|
|
echo ""
|
|
|
|
# Run E2E tests
|
|
echo -e "${BLUE}════════════════════════════════════════════════════════════════${NC}"
|
|
echo -e "${BLUE}PHASE 2: E2E TESTS${NC}"
|
|
echo -e "${BLUE}════════════════════════════════════════════════════════════════${NC}"
|
|
echo ""
|
|
echo "========================================" >> "$REPORT_FILE"
|
|
echo "PHASE 2: E2E TESTS" >> "$REPORT_FILE"
|
|
echo "========================================" >> "$REPORT_FILE"
|
|
|
|
set +e
|
|
bash "${SCRIPT_DIR}/e2e.sh" $ARGS 2>&1 | tee -a "$REPORT_FILE"
|
|
E2E_EXIT=${PIPESTATUS[0]}
|
|
set -e
|
|
|
|
echo ""
|
|
echo "E2E tests exit code: $E2E_EXIT" >> "$REPORT_FILE"
|
|
|
|
END_TIME=$(date +%s)
|
|
DURATION=$((END_TIME - START_TIME))
|
|
|
|
# Calculate final exit code
|
|
if [[ $UNIT_EXIT -eq 0 && $E2E_EXIT -eq 0 ]]; then
|
|
FINAL_EXIT=0
|
|
STATUS="PASSED"
|
|
STATUS_COLOR=$GREEN
|
|
else
|
|
FINAL_EXIT=1
|
|
STATUS="FAILED"
|
|
STATUS_COLOR=$RED
|
|
fi
|
|
|
|
# Summary
|
|
echo "" >> "$REPORT_FILE"
|
|
echo "========================================" >> "$REPORT_FILE"
|
|
echo "FINAL SUMMARY" >> "$REPORT_FILE"
|
|
echo "========================================" >> "$REPORT_FILE"
|
|
echo "Total Duration: ${DURATION}s" >> "$REPORT_FILE"
|
|
echo "Unit Tests: $([ $UNIT_EXIT -eq 0 ] && echo 'PASSED' || echo 'FAILED')" >> "$REPORT_FILE"
|
|
echo "E2E Tests: $([ $E2E_EXIT -eq 0 ] && echo 'PASSED' || echo 'FAILED')" >> "$REPORT_FILE"
|
|
echo "Overall: $STATUS" >> "$REPORT_FILE"
|
|
echo "Report: $REPORT_FILE" >> "$REPORT_FILE"
|
|
|
|
echo ""
|
|
echo -e "${CYAN}════════════════════════════════════════════════════════════════${NC}"
|
|
echo -e "${CYAN}FINAL SUMMARY${NC}"
|
|
echo -e "${CYAN}════════════════════════════════════════════════════════════════${NC}"
|
|
echo -e "Total Duration: ${DURATION}s"
|
|
echo -e "Unit Tests: $([ $UNIT_EXIT -eq 0 ] && echo -e "${GREEN}PASSED${NC}" || echo -e "${RED}FAILED${NC}")"
|
|
echo -e "E2E Tests: $([ $E2E_EXIT -eq 0 ] && echo -e "${GREEN}PASSED${NC}" || echo -e "${RED}FAILED${NC}")"
|
|
echo -e "Overall: ${STATUS_COLOR}${STATUS}${NC}"
|
|
echo -e "Report: ${YELLOW}${REPORT_FILE}${NC}"
|
|
echo ""
|
|
|
|
exit $FINAL_EXIT
|