|
1 | | -- name: ⚙️ Configure omnipkg for non-interactive use |
2 | | - run: | |
| 1 | +name: Omnipkg CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + pull_request: |
| 7 | + branches: [ main ] |
| 8 | + |
| 9 | +jobs: |
| 10 | + test: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + services: |
| 13 | + redis: |
| 14 | + image: redis:7 |
| 15 | + options: >- |
| 16 | + --health-cmd "redis-cli ping" |
| 17 | + --health-interval 10s |
| 18 | + --health-timeout 5s |
| 19 | + --health-retries 5 |
| 20 | + ports: |
| 21 | + - 6379:6379 |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Checkout repository |
| 25 | + uses: actions/checkout@v4 |
| 26 | + |
| 27 | + - name: Set up Python 3.11 |
| 28 | + uses: actions/setup-python@v5 |
| 29 | + with: |
| 30 | + python-version: '3.11' |
| 31 | + |
| 32 | + - name: Install dependencies |
| 33 | + run: | |
| 34 | + python -m pip install --upgrade pip |
| 35 | + pip install omnipkg redis |
| 36 | +
|
| 37 | + - name: ⚙️ Configure omnipkg for non-interactive use |
| 38 | + run: | |
3 | 39 | python - << 'EOF' |
4 | 40 | import sys |
5 | 41 | import site |
6 | 42 | import json |
7 | 43 | from pathlib import Path |
8 | 44 | import os |
9 | | - site_packages_path = site.getsitepackages()[0] |
10 | | - |
| 45 | + import sysconfig |
| 46 | +
|
| 47 | + # Get site-packages path safely |
| 48 | + try: |
| 49 | + site_packages_path = site.getsitepackages()[0] |
| 50 | + except (IndexError, AttributeError): |
| 51 | + site_packages_path = sysconfig.get_paths()['purelib'] |
| 52 | +
|
11 | 53 | # Determine project root (where pyproject.toml is) |
12 | | - project_root = Path(os.environ['GITHUB_WORKSPACE']) # GITHUB_WORKSPACE is the repo root |
| 54 | + project_root = Path(os.environ['GITHUB_WORKSPACE']) |
| 55 | + |
| 56 | + # Verify builder script exists |
| 57 | + builder_script = project_root / 'omnipkg' / 'package_meta_builder.py' |
| 58 | + if not builder_script.exists(): |
| 59 | + print(f"Error: {builder_script} does not exist") |
| 60 | + sys.exit(1) |
| 61 | +
|
13 | 62 | config_data = { |
14 | 63 | 'site_packages_path': site_packages_path, |
15 | 64 | 'multiversion_base': str(Path(site_packages_path) / '.omnipkg_versions'), |
16 | 65 | 'python_executable': sys.executable, |
17 | | - # Adjust builder_script_path to be relative from project root to omnipkg/package_meta_builder.py |
18 | | - 'builder_script_path': str(project_root / 'omnipkg' / 'package_meta_builder.py'), |
| 66 | + 'builder_script_path': str(builder_script), |
19 | 67 | 'redis_host': 'localhost', |
20 | 68 | 'redis_port': 6379, |
21 | 69 | 'redis_key_prefix': 'omnipkg:pkg:', |
22 | 70 | 'paths_to_index': [str(Path(sys.executable).parent), '/usr/local/bin', '/usr/bin', '/bin', '/usr/sbin', '/sbin'], |
23 | 71 | 'auto_cleanup': True, |
24 | 72 | 'cleanup_threshold_days': 30 |
25 | 73 | } |
| 74 | +
|
26 | 75 | config_dir = Path.home() / '.config' / 'omnipkg' |
27 | 76 | config_dir.mkdir(parents=True, exist_ok=True) |
28 | 77 | config_path = config_dir / 'config.json' |
29 | | - with open(config_path, 'w') as f: |
30 | | - json.dump(config_data, f, indent=2) |
31 | | - print(f'omnipkg config created at {config_path}:') |
32 | | - print(json.dumps(config_data, indent=2)) |
| 78 | + |
| 79 | + try: |
| 80 | + with open(config_path, 'w') as f: |
| 81 | + json.dump(config_data, f, indent=2) |
| 82 | + print(f'omnipkg config created at {config_path}:') |
| 83 | + print(json.dumps(config_data, indent=2)) |
| 84 | + except Exception as e: |
| 85 | + print(f"Error writing config: {e}") |
| 86 | + sys.exit(1) |
33 | 87 | EOF |
34 | | - - name: 🧪 Run the Demo: UV Test (Binary Switching) |
| 88 | +
|
| 89 | + - name: 🧪 Run the Demo - UV Test (Binary Switching) |
35 | 90 | id: run_demo |
36 | 91 | run: | |
37 | 92 | echo "--- Running Omnipkg Demo for UV Test (Binary Switching) ---" |
38 | | - # Simulate user input '2' for UV test |
39 | | - DEMO_OUTPUT=$(echo "2" | omnipkg demo 2>&1) |
| 93 | + # Simulate user input '2' for UV test with timeout |
| 94 | + DEMO_OUTPUT=$(timeout 300 bash -c 'echo "2" | omnipkg demo 2>&1') |
40 | 95 | DEMO_EXIT_CODE=$? |
41 | 96 | |
42 | 97 | echo "$DEMO_OUTPUT" > /tmp/demo_output.txt |
43 | 98 | |
44 | 99 | if [ $DEMO_EXIT_CODE -eq 0 ]; then |
45 | | - echo "demo_outcome=success" >> $GITHUB_OUTPUT |
46 | 100 | echo "Demo completed successfully." |
| 101 | + echo "demo_outcome=success" >> $GITHUB_OUTPUT |
| 102 | + # Verify UV Easter egg in output |
| 103 | + if grep -q "UV’s speeding through the matrix like a Python outlaw" /tmp/demo_output.txt; then |
| 104 | + echo "UV Easter egg found in output!" |
| 105 | + else |
| 106 | + echo "Error: UV Easter egg not found in output." |
| 107 | + exit 1 |
| 108 | + fi |
| 109 | + # Verify expected UV version |
| 110 | + if grep -q "Main environment version: 0.6.13" /tmp/demo_output.txt; then |
| 111 | + echo "Main environment UV version 0.6.13 confirmed!" |
| 112 | + else |
| 113 | + echo "Error: Main environment UV version 0.6.13 not found." |
| 114 | + exit 1 |
| 115 | + fi |
47 | 116 | else |
48 | | - echo "demo_outcome=failure" >> $GITHUB_OUTPUT |
49 | 117 | echo "Demo failed with exit code $DEMO_EXIT_CODE." |
50 | | - echo "$DEMO_OUTPUT" # Output to job log on failure |
51 | | - exit 1 |
| 118 | + echo "demo_outcome=failure" >> $GITHUB_OUTPUT |
| 119 | + cat /tmp/demo_output.txt |
| 120 | + exit 1 |
52 | 121 | fi |
0 commit comments