Skip to content

Commit 2f8ce74

Browse files
authored
Create rich-module-switching-test.yml
1 parent 9bd3e61 commit 2f8ce74

1 file changed

Lines changed: 138 additions & 0 deletions

File tree

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# .github/workflows/rich-module-switching-test.yml
2+
name: 🧪 Rich Module Switching Test
3+
4+
on:
5+
workflow_dispatch: # Allows manual triggering
6+
push:
7+
branches: ['main'] # Runs on pushes to main
8+
9+
jobs:
10+
run-rich-test:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write # Needed for checkout and uploading artifacts
14+
# id-token: write # Only if connecting to PyPI or other OIDC providers
15+
16+
services:
17+
redis:
18+
image: redis:7
19+
options: >-
20+
--health-cmd "redis-cli ping"
21+
--health-interval 10s
22+
--health-timeout 5s
23+
--health-retries 5
24+
ports:
25+
- 6379:6379
26+
27+
steps:
28+
- name: 🏁 Checkout repository
29+
uses: actions/checkout@v4
30+
31+
- name: 🐍 Set up Python 3.11
32+
uses: actions/setup-python@v5
33+
with:
34+
python-version: '3.11'
35+
36+
- name: 📦 Install omnipkg (editable) and Redis client
37+
run: |
38+
python -m pip install --upgrade pip
39+
pip install -e . redis # -e . installs in editable mode, pulling deps from pyproject.toml
40+
41+
- name: ⚙️ Configure omnipkg for non-interactive use
42+
run: |
43+
python - << 'EOF'
44+
import sys
45+
import site
46+
import json
47+
from pathlib import Path
48+
import os
49+
import sysconfig # Added for robust site-packages path
50+
51+
# Get site-packages path safely
52+
try:
53+
site_packages_path = site.getsitepackages()[0]
54+
except (IndexError, AttributeError):
55+
# Fallback for some CI environments or unusual setups
56+
site_packages_path = sysconfig.get_paths()['purelib']
57+
58+
# Determine project root (where pyproject.toml is)
59+
project_root = Path(os.environ['GITHUB_WORKSPACE'])
60+
61+
# Verify builder script exists
62+
builder_script = project_root / 'omnipkg' / 'package_meta_builder.py'
63+
if not builder_script.exists():
64+
print(f"Error: {builder_script} does not exist")
65+
sys.exit(1)
66+
67+
config_data = {
68+
'site_packages_path': site_packages_path,
69+
'multiversion_base': str(Path(site_packages_path) / '.omnipkg_versions'),
70+
'python_executable': sys.executable,
71+
'builder_script_path': str(builder_script),
72+
'redis_host': 'localhost',
73+
'redis_port': 6379,
74+
'redis_key_prefix': 'omnipkg:pkg:',
75+
'paths_to_index': [str(Path(sys.executable).parent), '/usr/local/bin', '/usr/bin', '/bin', '/usr/sbin', '/sbin'],
76+
'auto_cleanup': True,
77+
'cleanup_threshold_days': 30
78+
}
79+
80+
config_dir = Path.home() / '.config' / 'omnipkg'
81+
config_dir.mkdir(parents=True, exist_ok=True)
82+
config_path = config_dir / 'config.json'
83+
84+
try:
85+
with open(config_path, 'w') as f:
86+
json.dump(config_data, f, indent=2)
87+
print(f'omnipkg config created at {config_path}:')
88+
print(json.dumps(config_data, indent=2))
89+
except Exception as e:
90+
print(f"Error writing config: {e}")
91+
sys.exit(1)
92+
EOF
93+
94+
- name: 🧪 Run the Demo: Rich Test (Python Module Switching)
95+
id: run_demo
96+
run: |
97+
echo "--- Running Omnipkg Demo for Rich Test (Python Module Switching) ---"
98+
mkdir -p /tmp/omnipkg-artifacts
99+
100+
# Simulate user input '1' for Rich test, capture output, and limit runtime
101+
timeout 300 bash -c 'echo "1" | omnipkg demo 2>&1 | tee /tmp/omnipkg-artifacts/demo_output.txt'
102+
DEMO_EXIT_CODE=$?
103+
104+
echo "## Rich Demo Output" >> $GITHUB_STEP_SUMMARY
105+
echo '```' >> $GITHUB_STEP_SUMMARY
106+
cat /tmp/omnipkg-artifacts/demo_output.txt >> $GITHUB_STEP_SUMMARY
107+
echo '```' >> $GITHUB_STEP_SUMMARY
108+
109+
if [ $DEMO_EXIT_CODE -eq 0 ]; then
110+
echo "Demo completed successfully."
111+
echo "demo_outcome=success" >> $GITHUB_OUTPUT
112+
# Verify key Rich demo outputs
113+
if grep -q "ALL TESTS PASSED!" /tmp/omnipkg-artifacts/demo_output.txt && \
114+
grep -q "Imported and verified version 13.7.1" /tmp/omnipkg-artifacts/demo_output.txt && \
115+
grep -q "Testing Bubble (rich==13.5.3)" /tmp/omnipkg-artifacts/demo_output.txt && \
116+
grep -q "Testing Bubble (rich==13.4.2)" /tmp/omnipkg-artifacts/demo_output.txt; then
117+
echo "Rich demo verified: All tests passed, including main env and bubbles for 13.5.3 and 13.4.2."
118+
else
119+
echo "Error: Expected Rich demo output not found."
120+
echo "Missing one of: 'ALL TESTS PASSED!', 'Imported and verified version 13.7.1', 'Testing Bubble (rich==13.5.3)', or 'Testing Bubble (rich==13.4.2)'"
121+
cat /tmp/omnipkg-artifacts/demo_output.txt
122+
exit 1
123+
fi
124+
else
125+
echo "Demo failed with exit code $DEMO_EXIT_CODE."
126+
echo "demo_outcome=failure" >> $GITHUB_OUTPUT
127+
cat /tmp/omnipkg-artifacts/demo_output.txt
128+
exit 1
129+
fi
130+
131+
- name: 📦 Archive Demo Output
132+
if: always()
133+
uses: actions/upload-artifact@v4
134+
with:
135+
name: omnipkg-rich-demo-output
136+
path: /tmp/omnipkg-artifacts/
137+
retention-days: 7
138+
compression-level: 6

0 commit comments

Comments
 (0)