Skip to content

Commit d5d23bb

Browse files
authored
Update test-uv-binary-switching.yml
1 parent 985066e commit d5d23bb

1 file changed

Lines changed: 87 additions & 18 deletions

File tree

Lines changed: 87 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,121 @@
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: |
339
python - << 'EOF'
440
import sys
541
import site
642
import json
743
from pathlib import Path
844
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+
1153
# 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+
1362
config_data = {
1463
'site_packages_path': site_packages_path,
1564
'multiversion_base': str(Path(site_packages_path) / '.omnipkg_versions'),
1665
'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),
1967
'redis_host': 'localhost',
2068
'redis_port': 6379,
2169
'redis_key_prefix': 'omnipkg:pkg:',
2270
'paths_to_index': [str(Path(sys.executable).parent), '/usr/local/bin', '/usr/bin', '/bin', '/usr/sbin', '/sbin'],
2371
'auto_cleanup': True,
2472
'cleanup_threshold_days': 30
2573
}
74+
2675
config_dir = Path.home() / '.config' / 'omnipkg'
2776
config_dir.mkdir(parents=True, exist_ok=True)
2877
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)
3387
EOF
34-
- name: 🧪 Run the Demo: UV Test (Binary Switching)
88+
89+
- name: 🧪 Run the Demo - UV Test (Binary Switching)
3590
id: run_demo
3691
run: |
3792
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')
4095
DEMO_EXIT_CODE=$?
4196
4297
echo "$DEMO_OUTPUT" > /tmp/demo_output.txt
4398
4499
if [ $DEMO_EXIT_CODE -eq 0 ]; then
45-
echo "demo_outcome=success" >> $GITHUB_OUTPUT
46100
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
47116
else
48-
echo "demo_outcome=failure" >> $GITHUB_OUTPUT
49117
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
52121
fi

0 commit comments

Comments
 (0)