Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
276 changes: 276 additions & 0 deletions .github/workflows/pai-install-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,276 @@
name: PAI Installation & Pack Integration Test

# When to run this workflow
on:
# Manually trigger from GitHub UI
workflow_dispatch:
# Run on push to any branch (optional - can disable if you want manual only)
push:
branches:
- '**'

# Set default shell for all steps
defaults:
run:
shell: bash

jobs:
pai-install-test:
# Run on Ubuntu (fresh environment, no contamination)
runs-on: ubuntu-latest

name: Test PAI Installation & Pack Setup

steps:
# Step 1: Check out the code
- name: Checkout PAI Repository
uses: actions/checkout@v4
with:
fetch-depth: 0

# Step 2: Set up Node.js and Bun
- name: Install Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest

# Step 3: Verify environment is clean
- name: Verify Clean Environment
run: |
echo "=== Environment Verification ==="
echo "User: $(whoami)"
echo "Home: $HOME"
echo "PWD: $PWD"
echo "Bun version: $(bun --version)"
echo "Node version: $(node --version)"
echo "Bash version: $BASH_VERSION"
echo ""
echo "Checking for existing .claude directory..."
if [ -d "$HOME/.claude" ]; then
echo "⚠️ Warning: ~/.claude already exists (shouldn't happen on fresh runner)"
ls -la "$HOME/.claude"
else
echo "✓ ~/.claude does not exist (clean environment)"
fi

# Step 4: Pre-create .env file (non-interactive bootstrap)
- name: Bootstrap Configuration (Pre-create .env)
run: |
echo "=== Creating Bootstrap .env File ==="
mkdir -p "$HOME/.claude"

# Create .env file using tee to avoid YAML parsing issues
{
echo "# PAI Environment Configuration (GitHub Actions Test)"
echo "# Created: $(date)"
echo ""
echo 'DA="TestPai"'
echo 'PAI_DIR="$HOME/.claude"'
echo 'TIME_ZONE="America/New_York"'
echo 'PAI_SOURCE_APP="claude-code"'
} > "$HOME/.claude/.env"

echo "✓ Created $HOME/.claude/.env"
echo "✓ .env file contents verified (not displayed for security)"

# Step 4b: Attempt to run the PAI installer (will likely fail due to interactive prompts)
- name: Run PAI Kai Bundle Installer
run: |
echo "=== Attempting PAI Kai Bundle Installer ==="
cd Bundles/Kai

# Try to run installer - will likely get stuck on prompts
# Timeout after 10 seconds if it hangs
timeout 10s bun run install.ts || {
EXIT_CODE=$?
if [ $EXIT_CODE -eq 124 ]; then
echo "⚠️ Installer timed out (waiting for interactive input)"
echo "This confirms installer requires interactive stdin"
else
echo "⚠️ Installer exited with code: $EXIT_CODE"
fi
}
continue-on-error: true # Don't fail workflow

# Step 5: Manual Installation Bootstrap (if installer fails)
- name: Bootstrap Installation Manually
run: |
echo "=== Bootstrapping PAI Structure Manually ==="

# Create directory structure
mkdir -p "$HOME/.claude/skills/CORE"
mkdir -p "$HOME/.claude/hooks/lib"
mkdir -p "$HOME/.claude/history/sessions"
mkdir -p "$HOME/.claude/history/decisions"
mkdir -p "$HOME/.claude/history/learnings"

# Check if directories were created
if [ -d "$HOME/.claude/skills/CORE" ]; then
echo "✓ Created directory structure"
fi

# Create SKILL.md (CORE skill definition)
cat > "$HOME/.claude/skills/CORE/SKILL.md" << 'EOF'
---
name: CORE
description: Personal AI Infrastructure core. AUTO-LOADS at session start.
---

# CORE - Personal AI Infrastructure

**Auto-loads at session start.**

## Identity

- Name: TestPai
- User: Eli
- Environment: GitHub Actions Test

## Stack Preferences

- Language: TypeScript
- Package Manager: bun
- Runtime: Bun
EOF

echo "✓ Created SKILL.md"

# Source and verify .env
set -a
source "$HOME/.claude/.env"
set +a

echo ""
echo "Environment verification:"
echo " DA=${DA:-'NOT SET'}"
echo " TIME_ZONE=${TIME_ZONE:-'NOT SET'}"

# Step 6: Verify installation files
- name: Verify Installation Files
run: |
echo "=== Verifying Installation Files ==="

echo "Checking ~/.claude directory structure..."
if [ -d "$HOME/.claude" ]; then
echo "✓ ~/.claude exists"
ls -la "$HOME/.claude"
echo ""

# Check for key files
echo "Checking for key installation files:"
[ -f "$HOME/.claude/.env" ] && echo " ✓ .env file exists" || echo " ✗ .env file NOT found"
[ -d "$HOME/.claude/skills" ] && echo " ✓ skills directory exists" || echo " ✗ skills directory NOT found"
[ -d "$HOME/.claude/hooks" ] && echo " ✓ hooks directory exists" || echo " ✗ hooks directory NOT found"
[ -d "$HOME/.claude/history" ] && echo " ✓ history directory exists" || echo " ✗ history directory NOT found"
else
echo "✗ ~/.claude does NOT exist - installation failed"
exit 1
fi

# Step 6: Check .env file contents
- name: Verify .env Configuration
run: |
echo "=== Checking .env File Contents ==="

if [ -f "$HOME/.claude/.env" ]; then
echo "✓ .env file found"
echo ""
echo "Parsing environment variables (not displaying contents for security):"
DA=$(grep "^DA=" "$HOME/.claude/.env" | cut -d'=' -f2 | tr -d '"')
TIME_ZONE=$(grep "^TIME_ZONE=" "$HOME/.claude/.env" | cut -d'=' -f2 | tr -d '"')

echo " DA = $DA (expected: TestPai)"
echo " TIME_ZONE = $TIME_ZONE (expected: America/New_York)"

if [ "$DA" = "TestPai" ]; then
echo " ✓ DA correctly set"
else
echo " ✗ DA mismatch - expected 'TestPai' but got '$DA'"
fi

if [ "$TIME_ZONE" = "America/New_York" ]; then
echo " ✓ TIME_ZONE correctly set"
else
echo " ✗ TIME_ZONE mismatch"
fi
else
echo "✗ .env file NOT found"
exit 1
fi

# Step 7: Attempt to source .env and check environment variables
- name: Test Environment Variable Sourcing
run: |
echo "=== Testing Environment Variable Sourcing ==="

echo "Before sourcing .env:"
echo " DA=${DA:-'NOT SET'}"
echo " TIME_ZONE=${TIME_ZONE:-'NOT SET'}"
echo ""

echo "Sourcing ~/.claude/.env..."
set -a
source "$HOME/.claude/.env"
set +a

echo "After sourcing .env:"
echo " DA=${DA:-'NOT SET'}"
echo " TIME_ZONE=${TIME_ZONE:-'NOT SET'}"
echo ""

if [ -z "$DA" ] || [ "$DA" = "NOT SET" ]; then
echo "⚠️ Warning: DA not sourced properly"
else
echo "✓ DA sourced: $DA"
fi

# Step 8: Check pack files
- name: Verify Pack Files Exist
run: |
echo "=== Checking Pack Files ==="

PACKS=(
"kai-hook-system.md"
"kai-history-system.md"
"kai-core-install.md"
"kai-voice-system.md"
)

for pack in "${PACKS[@]}"; do
if [ -f "Packs/$pack" ]; then
SIZE=$(wc -l < "Packs/$pack")
echo " ✓ $pack ($SIZE lines)"
else
echo " ✗ $pack NOT found"
fi
done

# Step 9: Report Summary
- name: Generate Test Summary
run: |
echo "=== Test Summary ===" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "**Installation Status:** Complete" >> "$GITHUB_STEP_SUMMARY"
echo "**Environment:** Ubuntu Latest (GitHub Actions)" >> "$GITHUB_STEP_SUMMARY"
echo "**Test Date:** $(date -u)" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "### Findings" >> "$GITHUB_STEP_SUMMARY"

if [ -f "$HOME/.claude/.env" ]; then
echo "- ✅ .env file created successfully" >> "$GITHUB_STEP_SUMMARY"
DA=$(grep "^DA=" "$HOME/.claude/.env" | cut -d'=' -f2 | tr -d '"')
echo "- ✅ DA variable set to: $DA" >> "$GITHUB_STEP_SUMMARY"
else
echo "- ❌ .env file NOT created" >> "$GITHUB_STEP_SUMMARY"
fi

echo "" >> "$GITHUB_STEP_SUMMARY"
echo "### Next Steps" >> "$GITHUB_STEP_SUMMARY"
echo "1. Check workflow output for detailed logs" >> "$GITHUB_STEP_SUMMARY"
echo "2. Identify where pack installation would fail" >> "$GITHUB_STEP_SUMMARY"
echo "3. Use this as evidence for GitHub issue" >> "$GITHUB_STEP_SUMMARY"

# SECURITY: Artifact upload removed to prevent accidental exposure of .env files and API keys
# If logs are needed, retrieve from GitHub Actions web UI (logs are private to repo collaborators)

# GitHub Actions Test Run - Tue Dec 30 21:17:08 EST 2025
Loading
Loading