|
| 1 | +# .github/workflows/test-uv-binary-switching.yml |
| 2 | +name: ⚙️ UV Binary Switching Test |
| 3 | + |
| 4 | +on: |
| 5 | + workflow_dispatch: |
| 6 | + push: |
| 7 | + branches: ['main'] |
| 8 | + |
| 9 | +jobs: |
| 10 | + run-uv-binary-test: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + permissions: |
| 13 | + contents: write |
| 14 | + |
| 15 | + steps: |
| 16 | + - name: 🏁 Checkout code |
| 17 | + uses: actions/checkout@v4 |
| 18 | + |
| 19 | + - name: 🐍 Set up Python 3.11 |
| 20 | + uses: actions/setup-python@v5 |
| 21 | + with: |
| 22 | + python-version: '3.11' |
| 23 | + |
| 24 | + - name: 🔧 Install Redis for omnipkg |
| 25 | + run: | |
| 26 | + sudo apt-get update |
| 27 | + sudo apt-get install -y redis-server |
| 28 | + sudo systemctl start redis-server |
| 29 | + redis-cli ping |
| 30 | +
|
| 31 | + - name: 📦 Install omnipkg (editable) |
| 32 | + run: | |
| 33 | + python -m pip install --upgrade pip |
| 34 | + pip install -e . |
| 35 | + |
| 36 | + - name: ⚙️ Configure omnipkg for non-interactive use |
| 37 | + run: | |
| 38 | + python - << 'EOF' |
| 39 | + import sys |
| 40 | + import site |
| 41 | + import json |
| 42 | + from pathlib import Path |
| 43 | + import os |
| 44 | +
|
| 45 | + site_packages_path = site.getsitepackages()[0] |
| 46 | + project_root = Path(os.environ['GITHUB_WORKSPACE']) |
| 47 | +
|
| 48 | + config_data = { |
| 49 | + 'site_packages_path': site_packages_path, |
| 50 | + 'multiversion_base': str(Path(site_packages_path) / '.omnipkg_versions'), |
| 51 | + 'python_executable': sys.executable, |
| 52 | + 'builder_script_path': str(project_root / 'omnipkg' / 'package_meta_builder.py'), |
| 53 | + 'redis_host': 'localhost', |
| 54 | + 'redis_port': 6379, |
| 55 | + 'redis_key_prefix': 'omnipkg:pkg:', |
| 56 | + 'paths_to_index': [str(Path(sys.executable).parent), '/usr/local/bin', '/usr/bin', '/bin', '/usr/sbin', '/sbin'], |
| 57 | + 'auto_cleanup': True, |
| 58 | + 'cleanup_threshold_days': 30 |
| 59 | + } |
| 60 | +
|
| 61 | + config_dir = Path.home() / '.config' / 'omnipkg' |
| 62 | + config_dir.mkdir(parents=True, exist_ok=True) |
| 63 | + config_path = config_dir / 'config.json' |
| 64 | +
|
| 65 | + with open(config_path, 'w') as f: |
| 66 | + json.dump(config_data, f, indent=2) |
| 67 | +
|
| 68 | + print(f'omnipkg config created at {config_path}:') |
| 69 | + print(json.dumps(config_data, indent=2)) |
| 70 | + EOF |
| 71 | +
|
| 72 | + - name: 🧪 Run the Demo: UV Test (Binary Switching) |
| 73 | + id: run_demo |
| 74 | + run: | |
| 75 | + echo "--- Running Omnipkg Demo for UV Test (Binary Switching) ---" |
| 76 | + # Simulate user input '2' for UV test |
| 77 | + DEMO_OUTPUT=$(echo "2" | omnipkg demo 2>&1) |
| 78 | + DEMO_EXIT_CODE=$? |
| 79 | + |
| 80 | + echo "$DEMO_OUTPUT" > /tmp/demo_output.txt |
| 81 | + |
| 82 | + if [ $DEMO_EXIT_CODE -eq 0 ]; then |
| 83 | + echo "demo_outcome=success" >> $GITHUB_OUTPUT |
| 84 | + echo "Demo completed successfully." |
| 85 | + else |
| 86 | + echo "demo_outcome=failure" >> $GITHUB_OUTPUT |
| 87 | + echo "Demo failed with exit code $DEMO_EXIT_CODE." |
| 88 | + echo "$DEMO_OUTPUT" # Output to job log on failure |
| 89 | + exit 1 |
| 90 | + fi |
| 91 | +
|
| 92 | + - name: 📊 Generate Report |
| 93 | + if: always() |
| 94 | + run: | |
| 95 | + REPORT_FILE="uv_binary_test_report.md" |
| 96 | + echo "# ⚙️ UV Binary Switching Test Report" > $REPORT_FILE |
| 97 | + echo "" >> $REPORT_FILE |
| 98 | + echo "**Workflow Run:** [${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})" >> $REPORT_FILE |
| 99 | + echo "**Test Status:** \`${{ job.status }}\`" >> $REPORT_FILE |
| 100 | + echo "" >> $REPORT_FILE |
| 101 | + |
| 102 | + echo "## Demo Execution Output" >> $REPORT_FILE |
| 103 | + echo "\`\`\`" >> $REPORT_FILE |
| 104 | + cat /tmp/demo_output.txt 2>/dev/null || echo 'N/A: Demo output missing.' >> $REPORT_FILE |
| 105 | + echo "\`\`\`" >> $REPORT_FILE |
| 106 | + echo "" >> $REPORT_FILE |
| 107 | + |
| 108 | + echo "## Conclusion" >> $REPORT_FILE |
| 109 | + if [ "${{ steps.run_demo.outputs.demo_outcome }}" == "success" ]; then |
| 110 | + echo "✅ **omnipkg successfully demonstrated seamless version switching for binary packages (UV).** The test suite confirmed that different UV versions can coexist and be activated dynamically, including their associated binaries." >> $REPORT_FILE |
| 111 | + else |
| 112 | + echo "❌ The UV Binary Switching Test failed. Review workflow logs for detailed output and errors." >> $REPORT_FILE |
| 113 | + fi |
| 114 | + echo "" >> $REPORT_FILE |
| 115 | + |
| 116 | + - name: 📤 Upload Report Artifact |
| 117 | + uses: actions/upload-artifact@v4 |
| 118 | + with: |
| 119 | + name: uv-binary-test-report |
| 120 | + path: uv_binary_test_report.md |
| 121 | + retention-days: 30 |
0 commit comments