|
| 1 | +name: "🌌 LIVE - Quantum Python Auto-Switch Test" |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + pull_request: |
| 7 | + branches: [ main ] |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +jobs: |
| 11 | + test-quantum-switch: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + services: |
| 14 | + redis: |
| 15 | + image: redis:7 |
| 16 | + options: >- |
| 17 | + --health-cmd "redis-cli ping" |
| 18 | + --health-interval 10s |
| 19 | + --health-timeout 5s |
| 20 | + --health-retries 5 |
| 21 | + ports: |
| 22 | + - 6379:6379 |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Checkout repository |
| 26 | + uses: actions/checkout@v4 |
| 27 | + |
| 28 | + - name: Set up Python 3.11 |
| 29 | + uses: actions/setup-python@v5 |
| 30 | + with: |
| 31 | + python-version: '3.11' |
| 32 | + |
| 33 | + - name: Install dependencies |
| 34 | + run: | |
| 35 | + python -m pip install --upgrade pip |
| 36 | + pip install -e . redis |
| 37 | +
|
| 38 | + - name: Configure omnipkg and Establish Authoritative ENV_ID |
| 39 | + id: setup_omnipkg |
| 40 | + run: | |
| 41 | + python - << 'EOF' |
| 42 | + import json |
| 43 | + import os |
| 44 | + from pathlib import Path |
| 45 | + from omnipkg.core import ConfigManager |
| 46 | + |
| 47 | + config_dir = Path.home() / '.config' / 'omnipkg' |
| 48 | + config_dir.mkdir(parents=True, exist_ok=True) |
| 49 | + |
| 50 | + config = { |
| 51 | + "interactive": False, |
| 52 | + "auto_confirm": True, |
| 53 | + "redis_url": "redis://localhost:6379" |
| 54 | + } |
| 55 | + with open(config_dir / 'config.json', 'w') as f: |
| 56 | + json.dump(config, f, indent=2) |
| 57 | + print("✅ Omnipkg configured for non-interactive use") |
| 58 | + |
| 59 | + main_env_id = ConfigManager().env_id |
| 60 | + print(f"Authoritative Environment ID for this job: {main_env_id}") |
| 61 | + |
| 62 | + with open(os.environ['GITHUB_ENV'], 'a') as f: |
| 63 | + f.write(f"OMNIPKG_ENV_ID_OVERRIDE={main_env_id}\n") |
| 64 | + EOF |
| 65 | +
|
| 66 | + - name: Adopt and Switch to Python 3.14 |
| 67 | + env: |
| 68 | + OMNIPKG_ENV_ID_OVERRIDE: ${{ env.OMNIPKG_ENV_ID_OVERRIDE }} |
| 69 | + run: | |
| 70 | + echo "--- Adopting Python 3.14 ---" |
| 71 | + mkdir -p /tmp/omnipkg-artifacts |
| 72 | + |
| 73 | + omnipkg python adopt 3.14 2>&1 | tee /tmp/omnipkg-artifacts/adopt_314.txt |
| 74 | + |
| 75 | + echo "## Python 3.14 Adoption Output" >> $GITHUB_STEP_SUMMARY |
| 76 | + echo '```' >> $GITHUB_STEP_SUMMARY |
| 77 | + cat /tmp/omnipkg-artifacts/adopt_314.txt >> $GITHUB_STEP_SUMMARY |
| 78 | + echo '```' >> $GITHUB_STEP_SUMMARY |
| 79 | + |
| 80 | + echo "--- Switching to Python 3.14 ---" |
| 81 | + |
| 82 | + omnipkg swap python 3.14 2>&1 | tee /tmp/omnipkg-artifacts/swap_to_314.txt |
| 83 | + |
| 84 | + echo "## Swap to Python 3.14 Output" >> $GITHUB_STEP_SUMMARY |
| 85 | + echo '```' >> $GITHUB_STEP_SUMMARY |
| 86 | + cat /tmp/omnipkg-artifacts/swap_to_314.txt >> $GITHUB_STEP_SUMMARY |
| 87 | + echo '```' >> $GITHUB_STEP_SUMMARY |
| 88 | + |
| 89 | + # Verify we're on 3.14 |
| 90 | + CURRENT_VERSION=$(omnipkg info python 2>/dev/null | grep "Active Context:" | awk '{print $4}') |
| 91 | + echo "Current Python version: $CURRENT_VERSION" |
| 92 | + |
| 93 | + if [[ "$CURRENT_VERSION" == "3.14" ]]; then |
| 94 | + echo "✅ Successfully switched to Python 3.14" |
| 95 | + else |
| 96 | + echo "❌ Failed to switch to Python 3.14. Current: $CURRENT_VERSION" |
| 97 | + exit 1 |
| 98 | + fi |
| 99 | +
|
| 100 | + - name: Attempt to Install TensorFlow (Should Auto-Adopt 3.13 + Auto-Switch) |
| 101 | + env: |
| 102 | + OMNIPKG_ENV_ID_OVERRIDE: ${{ env.OMNIPKG_ENV_ID_OVERRIDE }} |
| 103 | + run: | |
| 104 | + echo "--- Attempting to install TensorFlow on Python 3.14 (incompatible) ---" |
| 105 | + echo "This should trigger Quantum Healing, auto-adopt Python 3.13, and auto-switch to it..." |
| 106 | + |
| 107 | + set -o pipefail |
| 108 | + |
| 109 | + if timeout 900 bash -c 'omnipkg install tensorflow' 2>&1 | tee /tmp/omnipkg-artifacts/tensorflow_install.txt; then |
| 110 | + INSTALL_EXIT_CODE=0 |
| 111 | + else |
| 112 | + INSTALL_EXIT_CODE=$? |
| 113 | + fi |
| 114 | + |
| 115 | + echo "## TensorFlow Installation Output" >> $GITHUB_STEP_SUMMARY |
| 116 | + echo '```' >> $GITHUB_STEP_SUMMARY |
| 117 | + cat /tmp/omnipkg-artifacts/tensorflow_install.txt >> $GITHUB_STEP_SUMMARY |
| 118 | + echo '```' >> $GITHUB_STEP_SUMMARY |
| 119 | + |
| 120 | + # Check for quantum healing activation |
| 121 | + if grep -q "QUANTUM HEALING: Python Incompatibility Detected" /tmp/omnipkg-artifacts/tensorflow_install.txt; then |
| 122 | + echo "✅ Quantum Healing was triggered!" |
| 123 | + else |
| 124 | + echo "❌ Quantum Healing was NOT triggered!" |
| 125 | + exit 1 |
| 126 | + fi |
| 127 | + |
| 128 | + # Check for auto-switch to Python 3.13 |
| 129 | + if grep -q "Swapping active context to Python 3.13" /tmp/omnipkg-artifacts/tensorflow_install.txt || \ |
| 130 | + grep -q "Successfully switched omnipkg context to Python 3.13" /tmp/omnipkg-artifacts/tensorflow_install.txt; then |
| 131 | + echo "✅ Auto-switched to Python 3.13!" |
| 132 | + else |
| 133 | + echo "❌ Did not auto-switch to Python 3.13!" |
| 134 | + exit 1 |
| 135 | + fi |
| 136 | + |
| 137 | + # Check for successful installation |
| 138 | + if grep -q "All package operations complete" /tmp/omnipkg-artifacts/tensorflow_install.txt || \ |
| 139 | + grep -q "Retrying in new Python 3.13 context" /tmp/omnipkg-artifacts/tensorflow_install.txt; then |
| 140 | + echo "✅ Installation completed successfully!" |
| 141 | + else |
| 142 | + echo "⚠️ Installation may not have completed fully" |
| 143 | + fi |
| 144 | +
|
| 145 | + - name: Verify Final State |
| 146 | + env: |
| 147 | + OMNIPKG_ENV_ID_OVERRIDE: ${{ env.OMNIPKG_ENV_ID_OVERRIDE }} |
| 148 | + run: | |
| 149 | + echo "--- Verifying final state ---" |
| 150 | + |
| 151 | + # Check current Python version |
| 152 | + FINAL_VERSION=$(omnipkg info python 2>/dev/null | grep "Active Context:" | awk '{print $4}') |
| 153 | + echo "Final Python version: $FINAL_VERSION" |
| 154 | + |
| 155 | + if [[ "$FINAL_VERSION" == "3.13" ]]; then |
| 156 | + echo "✅ Confirmed: Now running on Python 3.13" |
| 157 | + else |
| 158 | + echo "❌ Unexpected Python version: $FINAL_VERSION" |
| 159 | + exit 1 |
| 160 | + fi |
| 161 | + |
| 162 | + # Check if TensorFlow is installed |
| 163 | + omnipkg info tensorflow 2>&1 | tee /tmp/omnipkg-artifacts/tensorflow_info.txt |
| 164 | + |
| 165 | + if grep -q "Active Version:" /tmp/omnipkg-artifacts/tensorflow_info.txt; then |
| 166 | + echo "✅ TensorFlow is installed and active!" |
| 167 | + else |
| 168 | + echo "⚠️ TensorFlow installation could not be verified" |
| 169 | + fi |
| 170 | + |
| 171 | + echo "## Final State Verification" >> $GITHUB_STEP_SUMMARY |
| 172 | + echo '```' >> $GITHUB_STEP_SUMMARY |
| 173 | + cat /tmp/omnipkg-artifacts/tensorflow_info.txt >> $GITHUB_STEP_SUMMARY |
| 174 | + echo '```' >> $GITHUB_STEP_SUMMARY |
| 175 | +
|
| 176 | + - name: Test TensorFlow Import |
| 177 | + env: |
| 178 | + OMNIPKG_ENV_ID_OVERRIDE: ${{ env.OMNIPKG_ENV_ID_OVERRIDE }} |
| 179 | + run: | |
| 180 | + echo "--- Testing TensorFlow import ---" |
| 181 | + |
| 182 | + PYTHON_INFO=$(omnipkg info python 2>/dev/null) |
| 183 | + PYTHON_313_EXE=$(echo "$PYTHON_INFO" | grep 'Python 3.13:' | awk '{print $4}' || echo "") |
| 184 | + |
| 185 | + if [ -n "$PYTHON_313_EXE" ]; then |
| 186 | + echo "Testing TensorFlow import on Python 3.13..." |
| 187 | + if "$PYTHON_313_EXE" -c "import tensorflow as tf; print(f'TensorFlow version: {tf.__version__}')" 2>&1 | tee /tmp/omnipkg-artifacts/tensorflow_import.txt; then |
| 188 | + echo "✅ TensorFlow imports successfully!" |
| 189 | + else |
| 190 | + echo "❌ TensorFlow import failed!" |
| 191 | + exit 1 |
| 192 | + fi |
| 193 | + else |
| 194 | + echo "⚠️ Could not find Python 3.13 executable" |
| 195 | + exit 1 |
| 196 | + fi |
| 197 | +
|
| 198 | + - name: Generate Test Summary |
| 199 | + if: always() |
| 200 | + run: | |
| 201 | + echo "## 🌌 Quantum Python Auto-Switch Test Summary" >> $GITHUB_STEP_SUMMARY |
| 202 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 203 | + echo "### Test Scenario" >> $GITHUB_STEP_SUMMARY |
| 204 | + echo "1. Manually adopted and swapped to Python 3.14" >> $GITHUB_STEP_SUMMARY |
| 205 | + echo "2. Attempted to install TensorFlow (incompatible with Python 3.14)" >> $GITHUB_STEP_SUMMARY |
| 206 | + echo "3. Omnipkg detected incompatibility via Quantum Healing" >> $GITHUB_STEP_SUMMARY |
| 207 | + echo "4. **Auto-adopted Python 3.13** and **auto-switched** to it (zero manual intervention!)" >> $GITHUB_STEP_SUMMARY |
| 208 | + echo "5. TensorFlow installed successfully on Python 3.13" >> $GITHUB_STEP_SUMMARY |
| 209 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 210 | + echo "### Key Verifications" >> $GITHUB_STEP_SUMMARY |
| 211 | + echo "- ✅ Started on Python 3.14" >> $GITHUB_STEP_SUMMARY |
| 212 | + echo "- ✅ Quantum Healing triggered on incompatibility" >> $GITHUB_STEP_SUMMARY |
| 213 | + echo "- ✅ **Python 3.13 auto-adopted during install** (the magic!)" >> $GITHUB_STEP_SUMMARY |
| 214 | + echo "- ✅ **Auto-switched from 3.14 → 3.13** (zero user intervention!)" >> $GITHUB_STEP_SUMMARY |
| 215 | + echo "- ✅ TensorFlow installed without any manual steps" >> $GITHUB_STEP_SUMMARY |
| 216 | + echo "- ✅ TensorFlow imports successfully" >> $GITHUB_STEP_SUMMARY |
| 217 | +
|
| 218 | + - name: Archive Test Outputs |
| 219 | + if: always() |
| 220 | + uses: actions/upload-artifact@v4 |
| 221 | + with: |
| 222 | + name: omnipkg-quantum-switch-test-output |
| 223 | + path: /tmp/omnipkg-artifacts/ |
| 224 | + retention-days: 7 |
| 225 | + compression-level: 6 |
0 commit comments