Skip to content

Commit 6eea300

Browse files
authored
Add Omnipkg self-upgrade test workflow
1 parent fe27cab commit 6eea300

1 file changed

Lines changed: 176 additions & 0 deletions

File tree

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
name: "🔄 LIVE - Omnipkg Self-Upgrade Test"
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
test-self-upgrade:
12+
runs-on: ubuntu-latest
13+
services:
14+
redis:
15+
image: redis:7
16+
options: >-
17+
--health-cmd "redis-cli ping"
18+
--health-interval 10s
19+
--health-timeout 5s
20+
--health-retries 5
21+
ports:
22+
- 6379:6379
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
28+
- name: Set up Python 3.11
29+
uses: actions/setup-python@v5
30+
with:
31+
python-version: '3.11'
32+
33+
- name: Install dependencies and older omnipkg version
34+
run: |
35+
python -m pip install --upgrade pip
36+
# Install an older version first (e.g., 1.5.7 if 1.5.8 is current)
37+
pip install omnipkg==1.5.7 redis
38+
echo "Installed omnipkg version:"
39+
pip show omnipkg | grep Version
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
50+
51+
try:
52+
site_packages_path = site.getsitepackages()[0]
53+
except (IndexError, AttributeError):
54+
site_packages_path = sysconfig.get_paths()['purelib']
55+
56+
project_root = Path(os.environ['GITHUB_WORKSPACE'])
57+
builder_script = project_root / 'omnipkg' / 'package_meta_builder.py'
58+
59+
if not builder_script.exists():
60+
print(f"Error: {builder_script} does not exist")
61+
sys.exit(1)
62+
63+
config_data = {
64+
'site_packages_path': site_packages_path,
65+
'multiversion_base': str(Path(site_packages_path) / '.omnipkg_versions'),
66+
'python_executable': sys.executable,
67+
'builder_script_path': str(builder_script),
68+
'redis_host': 'localhost',
69+
'redis_port': 6379,
70+
'redis_key_prefix': 'omnipkg:pkg:',
71+
'paths_to_index': [str(Path(sys.executable).parent), '/usr/local/bin', '/usr/bin', '/bin', '/usr/sbin', '/sbin'],
72+
'auto_cleanup': True,
73+
'cleanup_threshold_days': 30
74+
}
75+
76+
config_dir = Path.home() / '.config' / 'omnipkg'
77+
config_dir.mkdir(parents=True, exist_ok=True)
78+
config_path = config_dir / 'config.json'
79+
80+
try:
81+
with open(config_path, 'w') as f:
82+
json.dump(config_data, f, indent=2)
83+
print(f'omnipkg config created at {config_path}:')
84+
print(json.dumps(config_data, indent=2))
85+
except Exception as e:
86+
print(f"Error writing config: {e}")
87+
sys.exit(1)
88+
EOF
89+
90+
- name: Verify initial omnipkg installation
91+
run: |
92+
echo "--- Initial omnipkg version check ---"
93+
8pkg --version
94+
8pkg info omnipkg || true
95+
96+
- name: Run Self-Upgrade Test
97+
id: run_upgrade
98+
run: |
99+
echo "--- Running Omnipkg Self-Upgrade Test ---"
100+
mkdir -p /tmp/omnipkg-artifacts
101+
102+
set -o pipefail
103+
104+
# Perform the self-upgrade using --force-dev flag to upgrade from dev source
105+
if timeout 900 bash -c '8pkg upgrade omnipkg --force-dev -y' 2>&1 | tee /tmp/omnipkg-artifacts/upgrade_output.txt; then
106+
UPGRADE_EXIT_CODE=0
107+
else
108+
UPGRADE_EXIT_CODE=$?
109+
fi
110+
111+
echo "## Self-Upgrade Output" >> $GITHUB_STEP_SUMMARY
112+
echo '```' >> $GITHUB_STEP_SUMMARY
113+
cat /tmp/omnipkg-artifacts/upgrade_output.txt >> $GITHUB_STEP_SUMMARY
114+
echo '```' >> $GITHUB_STEP_SUMMARY
115+
116+
# Check if upgrade completed successfully
117+
if grep -q "FILESYSTEM UPGRADE COMPLETE" /tmp/omnipkg-artifacts/upgrade_output.txt && \
118+
grep -q "successfully upgraded to version" /tmp/omnipkg-artifacts/upgrade_output.txt; then
119+
120+
echo "✅ Self-upgrade completed successfully!"
121+
echo "upgrade_outcome=success" >> $GITHUB_OUTPUT
122+
else
123+
echo "❌ Self-upgrade failed or did not complete successfully."
124+
echo "upgrade_outcome=failure" >> $GITHUB_OUTPUT
125+
echo "Upgrade output:"
126+
cat /tmp/omnipkg-artifacts/upgrade_output.txt
127+
exit 1
128+
fi
129+
130+
- name: Verify upgraded version
131+
run: |
132+
echo "--- Verifying upgraded omnipkg version ---"
133+
8pkg --version 2>&1 | tee /tmp/omnipkg-artifacts/version_after_upgrade.txt
134+
135+
echo "## Version After Upgrade" >> $GITHUB_STEP_SUMMARY
136+
echo '```' >> $GITHUB_STEP_SUMMARY
137+
cat /tmp/omnipkg-artifacts/version_after_upgrade.txt >> $GITHUB_STEP_SUMMARY
138+
echo '```' >> $GITHUB_STEP_SUMMARY
139+
140+
- name: Test bubble creation and version info
141+
run: |
142+
echo "--- Testing bubble and version info ---"
143+
8pkg info omnipkg 2>&1 | tee /tmp/omnipkg-artifacts/info_after_upgrade.txt
144+
145+
echo "## Omnipkg Info After Upgrade" >> $GITHUB_STEP_SUMMARY
146+
echo '```' >> $GITHUB_STEP_SUMMARY
147+
cat /tmp/omnipkg-artifacts/info_after_upgrade.txt >> $GITHUB_STEP_SUMMARY
148+
echo '```' >> $GITHUB_STEP_SUMMARY
149+
150+
# Verify bubble was created for old version
151+
if grep -q "Bubbled Versions:" /tmp/omnipkg-artifacts/info_after_upgrade.txt; then
152+
echo "✅ Bubble verification: Old version was preserved in bubble!"
153+
else
154+
echo "⚠️ Warning: Could not verify bubble creation from info output"
155+
fi
156+
157+
- name: Test basic omnipkg functionality
158+
run: |
159+
echo "--- Testing basic functionality after upgrade ---"
160+
8pkg list 2>&1 | tee /tmp/omnipkg-artifacts/list_after_upgrade.txt
161+
162+
if [ $? -eq 0 ]; then
163+
echo "✅ Basic functionality test passed: 8pkg list command works!"
164+
else
165+
echo "❌ Basic functionality test failed: 8pkg list command failed!"
166+
exit 1
167+
fi
168+
169+
- name: Archive Upgrade Test Outputs
170+
if: always()
171+
uses: actions/upload-artifact@v4
172+
with:
173+
name: omnipkg-self-upgrade-test-output
174+
path: /tmp/omnipkg-artifacts/
175+
retention-days: 7
176+
compression-level: 6

0 commit comments

Comments
 (0)