|
| 1 | +# .github/workflows/numpy-scipy-c-extension-test.yml |
| 2 | +name: 🧬 NumPy + SciPy C-Extension Switching Test |
| 3 | + |
| 4 | +on: |
| 5 | + workflow_dispatch: |
| 6 | + push: |
| 7 | + branches: ['main'] |
| 8 | + |
| 9 | +jobs: |
| 10 | + run-numpy-scipy-test: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + permissions: |
| 13 | + contents: write |
| 14 | + |
| 15 | + services: |
| 16 | + redis: |
| 17 | + image: redis:7 |
| 18 | + options: >- |
| 19 | + --health-cmd "redis-cli ping" |
| 20 | + --health-interval 10s |
| 21 | + --health-timeout 5s |
| 22 | + --health-retries 5 |
| 23 | + ports: |
| 24 | + - 6379:6379 |
| 25 | + |
| 26 | + steps: |
| 27 | + - name: 🏁 Checkout repository |
| 28 | + uses: actions/checkout@v4 |
| 29 | + |
| 30 | + - name: 🐍 Set up Python 3.11 |
| 31 | + uses: actions/setup-python@v5 |
| 32 | + with: |
| 33 | + python-version: '3.11' |
| 34 | + |
| 35 | + - name: 📦 Install omnipkg (editable) and Redis client |
| 36 | + run: | |
| 37 | + python -m pip install --upgrade pip |
| 38 | + pip install -e . redis |
| 39 | +
|
| 40 | + - name: ⚙️ Configure omnipkg for non-interactive use |
| 41 | + run: | |
| 42 | + python - << 'EOF' |
| 43 | + import sys |
| 44 | + import site |
| 45 | + import json |
| 46 | + from pathlib import Path |
| 47 | + import os |
| 48 | + import sysconfig |
| 49 | +
|
| 50 | + try: |
| 51 | + site_packages_path = site.getsitepackages()[0] |
| 52 | + except (IndexError, AttributeError): |
| 53 | + site_packages_path = sysconfig.get_paths()['purelib'] |
| 54 | +
|
| 55 | + project_root = Path(os.environ['GITHUB_WORKSPACE']) |
| 56 | + builder_script = project_root / 'omnipkg' / 'package_meta_builder.py' |
| 57 | + if not builder_script.exists(): |
| 58 | + print(f"Error: {builder_script} does not exist") |
| 59 | + sys.exit(1) |
| 60 | +
|
| 61 | + config_data = { |
| 62 | + 'site_packages_path': site_packages_path, |
| 63 | + 'multiversion_base': str(Path(site_packages_path) / '.omnipkg_versions'), |
| 64 | + 'python_executable': sys.executable, |
| 65 | + 'builder_script_path': str(builder_script), |
| 66 | + 'redis_host': 'localhost', |
| 67 | + 'redis_port': 6379, |
| 68 | + 'redis_key_prefix': 'omnipkg:pkg:', |
| 69 | + 'paths_to_index': [str(Path(sys.executable).parent), '/usr/local/bin', '/usr/bin', '/bin', '/usr/sbin', '/sbin'], |
| 70 | + 'auto_cleanup': True, |
| 71 | + 'cleanup_threshold_days': 30 |
| 72 | + } |
| 73 | +
|
| 74 | + config_dir = Path.home() / '.config' / 'omnipkg' |
| 75 | + config_dir.mkdir(parents=True, exist_ok=True) |
| 76 | + config_path = config_dir / 'config.json' |
| 77 | + |
| 78 | + try: |
| 79 | + with open(config_path, 'w') as f: |
| 80 | + json.dump(config_data, f, indent=2) |
| 81 | + print(f'omnipkg config created at {config_path}:') |
| 82 | + print(json.dumps(config_data, indent=2)) |
| 83 | + except Exception as e: |
| 84 | + print(f"Error writing config: {e}") |
| 85 | + sys.exit(1) |
| 86 | + EOF |
| 87 | +
|
| 88 | + - name: 🧪 Run the Demo: NumPy + SciPy Stress Test (C-Extensions) |
| 89 | + id: run_demo |
| 90 | + run: | |
| 91 | + echo "--- Running Omnipkg Demo for NumPy + SciPy Stress Test (C-Extensions) ---" |
| 92 | + mkdir -p /tmp/omnipkg-artifacts |
| 93 | + |
| 94 | + # Simulate user input '3' for NumPy + SciPy test, capture output, and limit runtime |
| 95 | + timeout 600 bash -c 'echo "3" | omnipkg demo 2>&1 | tee /tmp/omnipkg-artifacts/demo_output.txt' # Increased timeout for heavy packages |
| 96 | + DEMO_EXIT_CODE=$? |
| 97 | + |
| 98 | + echo "## NumPy + SciPy Demo Output" >> $GITHUB_STEP_SUMMARY |
| 99 | + echo '```' >> $GITHUB_STEP_SUMMARY |
| 100 | + cat /tmp/omnipkg-artifacts/demo_output.txt >> $GITHUB_STEP_SUMMARY |
| 101 | + echo '```' >> $GITHUB_STEP_SUMMARY |
| 102 | + |
| 103 | + if [ $DEMO_EXIT_CODE -eq 0 ]; then |
| 104 | + echo "Demo completed successfully." |
| 105 | + echo "demo_outcome=success" >> $GITHUB_OUTPUT |
| 106 | + # Verify key NumPy/SciPy demo outputs |
| 107 | + if grep -q "ALL TESTS PASSED!" /tmp/omnipkg-artifacts/demo_output.txt && \ |
| 108 | + grep -q "NUMPY VERSION JUGGLING:" /tmp/omnipkg-artifacts/demo_output.txt && \ |
| 109 | + grep -q "SCIPY C-EXTENSION TEST:" /tmp/omnipkg-artifacts/demo_output.txt && \ |
| 110 | + grep -q "NUMPY + SCIPY VERSION MIXING:" /tmp/omnipkg-artifacts/demo_output.txt && \ |
| 111 | + grep -q "OMNIPKG SURVIVED NUCLEAR TESTING!" /tmp/omnipkg-artifacts/demo_output.txt; then |
| 112 | + echo "NumPy + SciPy demo verified: All tests passed, including C-extension handling and version mixing." |
| 113 | + else |
| 114 | + echo "Error: Expected NumPy + SciPy demo output not found." |
| 115 | + echo "Missing one of: 'ALL TESTS PASSED!', 'NUMPY VERSION JUGGLING:', 'SCIPY C-EXTENSION TEST:', 'NUMPY + SCIPY VERSION MIXING:', or 'OMNIPKG SURVIVED NUCLEAR TESTING!'" |
| 116 | + cat /tmp/omnipkg-artifacts/demo_output.txt |
| 117 | + exit 1 |
| 118 | + fi |
| 119 | + else |
| 120 | + echo "Demo failed with exit code $DEMO_EXIT_CODE." |
| 121 | + echo "demo_outcome=failure" >> $GITHUB_OUTPUT |
| 122 | + cat /tmp/omnipkg-artifacts/demo_output.txt |
| 123 | + exit 1 |
| 124 | + fi |
| 125 | +
|
| 126 | + - name: 📦 Archive Demo Output |
| 127 | + if: always() |
| 128 | + uses: actions/upload-artifact@v4 |
| 129 | + with: |
| 130 | + name: omnipkg-numpy-scipy-demo-output |
| 131 | + path: /tmp/omnipkg-artifacts/ |
| 132 | + retention-days: 7 |
| 133 | + compression-level: 6 |
0 commit comments