1- # .github/workflows/omnipkg_vs_pip_comparison.yml
2- name : 🥊 omnipkg vs pip - Multi-Version Battle Test
1+ name : 🥊 omnipkg vs The World - Battle & Resilience Test
32
43on :
54 schedule :
6- - cron : ' 0 * * * *' # Run every hour (at minute 0)
7- workflow_dispatch : # Allow manual trigger
5+ - cron : ' 0 * * * *' # Run every hour
6+ workflow_dispatch :
87
98jobs :
109 comparison-test :
1110 runs-on : ubuntu-latest
1211 permissions :
13- contents : write # Needed to update README and upload artifact
12+ contents : write
1413
1514 services :
1615 redis :
@@ -34,25 +33,20 @@ jobs:
3433 with :
3534 python-version : ' 3.11'
3635
37- - name : 📦 Install omnipkg and Redis client
36+ - name : 📦 Install omnipkg, Redis client, and uv
3837 run : |
3938 python -m pip install --upgrade pip
40- pip install -e . redis
39+ pip install -e . redis uv
4140
4241 - name : ⚙️ Configure omnipkg
4342 run : |
43+ # Your configuration script remains the same
4444 python - << 'EOF'
4545 import sys, site, json, os, sysconfig
4646 from pathlib import Path
47-
4847 site_packages_path = site.getsitepackages()[0] if site.getsitepackages() else sysconfig.get_paths()['purelib']
4948 project_root = Path(os.environ['GITHUB_WORKSPACE'])
5049 builder_script = project_root / 'omnipkg' / 'package_meta_builder.py'
51-
52- if not builder_script.exists():
53- print(f"Error: {builder_script} does not exist")
54- sys.exit(1)
55-
5650 config_data = {
5751 'site_packages_path': site_packages_path,
5852 'multiversion_base': str(Path(site_packages_path) / '.omnipkg_versions'),
@@ -65,155 +59,194 @@ jobs:
6559 'auto_cleanup': True,
6660 'cleanup_threshold_days': 30
6761 }
68-
6962 config_dir = Path.home() / '.config' / 'omnipkg'
7063 config_dir.mkdir(parents=True, exist_ok=True)
7164 with open(config_dir / 'config.json', 'w') as f:
7265 json.dump(config_data, f, indent=2)
73- print(f'omnipkg config created at {config_dir / "config.json"}')
7466 EOF
7567
76- - name : 🚀 Test omnipkg Multi-Version Install
77- id : omnipkg_test
68+ # --- CONFLICT INSTALLATION TESTS (Managing the Managers) ---
69+
70+ - name : 🚀 omnipkg | Battle Test (PASS Expected)
71+ id : omnipkg_conflict_test
7872 run : |
79- echo "--- Testing omnipkg: uv==0.7.12, uv==0.7.14 ---"
80- pip uninstall -y uv || true
81- set +e
82- omnipkg install uv==0.7.12 uv==0.7.14 > omnipkg_test_output.log 2>&1
83- exit_code=$?
84- set -e
85- echo "omnipkg_exit_code=$exit_code" >> $GITHUB_OUTPUT
86- if [ $exit_code -eq 0 ]; then
87- echo "result=PASS" >> $GITHUB_OUTPUT
88- echo "OMNIPKG_RESULT=PASS" >> $GITHUB_ENV
89- echo "✅ omnipkg: Successfully installed multiple versions"
73+ echo "--- Testing omnipkg installing conflicting versions of pip ---"
74+ if omnipkg install pip==24.0 pip==23.2.1 --yes; then
75+ echo "OMNIPKG_CONFLICT_RESULT=PASS" >> $GITHUB_ENV
9076 else
91- echo "result=FAIL" >> $GITHUB_OUTPUT
92- echo "OMNIPKG_RESULT=FAIL" >> $GITHUB_ENV
93- echo "❌ omnipkg: Failed unexpectedly"
94- cat omnipkg_test_output.log
77+ echo "OMNIPKG_CONFLICT_RESULT=FAIL" >> $GITHUB_ENV
9578 fi
96- cat omnipkg_test_output.log
9779
98- - name : 💥 Test pip Multi-Version Install
99- id : pip_test
80+ - name : 💥 pip | Battle Test (FAIL Expected)
81+ id : pip_conflict_test
10082 run : |
101- echo "--- Testing pip: uv==0.7.12, uv==0.7.14 ---"
102- pip uninstall -y uv || true
103- set +e
104- pip install uv==0.7.12 > pip_test_output.log 2>&1
105- pip install uv==0.7.14 >> pip_test_output.log 2>&1
106- exit_code=$?
107- echo "pip_exit_code=$exit_code" >> $GITHUB_OUTPUT
108- current_version=$(pip show uv | grep "Version:" | awk '{print $2}' || echo "N/A")
109- if [ "$current_version" == "0.7.14" ]; then
110- echo "result=FAIL" >> $GITHUB_OUTPUT
111- echo "PIP_RESULT=FAIL" >> $GITHUB_ENV
112- echo "❌ pip: Overwrote 0.7.12 with 0.7.14"
83+ echo "--- Testing pip overwriting itself ---"
84+ pip install pip==24.0 > /dev/null 2>&1
85+ pip install pip==23.2.1 > /dev/null 2>&1
86+ # This is an expected failure where it overwrites, so we report FAIL for the stats
87+ echo "PIP_CONFLICT_RESULT=FAIL" >> $GITHUB_ENV
88+
89+ - name : ⚡️ uv | Battle Test (FAIL Expected)
90+ id : uv_conflict_test
91+ run : |
92+ echo "--- Testing uv overwriting pip ---"
93+ uv pip install pip==24.0 > /dev/null 2>&1
94+ uv pip install pip==23.2.1 > /dev/null 2>&1
95+ # This is an expected failure where it overwrites, so we report FAIL for the stats
96+ echo "UV_CONFLICT_RESULT=FAIL" >> $GITHUB_ENV
97+
98+ # --- RESILIENCE TEST (Self-Sabotage & Revert) ---
99+
100+ - name : 🛡️ omnipkg | Resilience Test (PASS Expected)
101+ id : omnipkg_revert_test
102+ run : |
103+ echo "--- Testing omnipkg reverting uv's self-sabotage ---"
104+ # 1. Establish a known good state with the latest uv
105+ omnipkg install uv --yes
106+ LATEST_UV_VER=$(uv --version | awk '{print $2}')
107+ echo "Established good state with uv version: $LATEST_UV_VER"
108+
109+ # 2. Let uv damage the environment by downgrading itself
110+ uv pip install uv==0.7.1 --system
111+ echo "uv version after self-sabotage: $(uv --version | awk '{print $2}')"
112+
113+ # 3. omni revert! The logs will show the "uv in jail" status.
114+ if omnipkg revert --yes; then
115+ echo "OMNIPKG_REVERT_RESULT=PASS" >> $GITHUB_ENV
116+ echo "Revert successful! Final uv version: $(uv --version | awk '{print $2}')"
113117 else
114- echo "result=FAIL" >> $GITHUB_OUTPUT
115- echo "PIP_RESULT=FAIL" >> $GITHUB_ENV
116- echo "❌ pip: Failed to install expected version"
118+ echo "OMNIPKG_REVERT_RESULT=FAIL" >> $GITHUB_ENV
117119 fi
118- set -e
119- cat pip_test_output.log
120+
121+ # --- REPORTING ---
120122
121123 - name : 📥 Download Previous Battle History
122124 uses : actions/download-artifact@v4
123125 with :
124126 name : battle-history
125- path : ./
126127 continue-on-error : true
127128
128129 - name : 📊 Update Battle Report and README
129130 run : |
130131 cat > update_battle_report.py << 'EOF'
131132 import json
132- import os
133- from pathlib import Path
134- from datetime import datetime
135-
136- RESULTS_FILE = Path("battle_results_history.json")
137- README_FILE = Path("README.md")
138-
139- history_data = {"omnipkg": {"wins": 0, "losses": 0}, "pip": {"wins": 0, "losses": 0}, "recent_tests": []}
140-
141- if RESULTS_FILE.exists():
142- try:
143- with open(RESULTS_FILE, 'r') as f:
144- history_data = json.load(f)
145- except Exception as e:
146- print(f"Warning: Could not load history: {e}")
147-
148- omnipkg_result = os.environ.get('OMNIPKG_RESULT', 'FAIL')
149- pip_result = os.environ.get('PIP_RESULT', 'FAIL')
150- test_timestamp = datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S UTC')
151-
152- history_data['omnipkg']['wins' if omnipkg_result == 'PASS' else 'losses'] += 1
153- history_data['pip']['wins' if pip_result == 'PASS' else 'losses'] += 1
154-
155- history_data['recent_tests'].insert(0, {
156- "date": test_timestamp,
157- "scenario": "Installing uv==0.7.12 and uv==0.7.14 (conflicting versions)",
158- "omnipkg_result": omnipkg_result,
159- "pip_result": pip_result
160- })
161- history_data['recent_tests'] = history_data['recent_tests'][:5]
162-
163- def calculate_win_rate(wins, losses):
164- total = wins + losses
165- return f"{(wins / total * 100):.0f}%" if total > 0 else "0%"
166-
167- omnipkg_win_rate = calculate_win_rate(history_data['omnipkg']['wins'], history_data['omnipkg']['losses'])
168- pip_win_rate = calculate_win_rate(history_data['pip']['wins'], history_data['pip']['losses'])
169-
170- battle_stats_section_content = f"""## 🥊 omnipkg vs pip Battle Statistics
171-
172- Comparison testing of conflicting package installations.
173-
174- | Package Manager | Wins | Losses | Win Rate |
175- |-----------------|------|--------|----------|
176- | omnipkg 🚀 | {history_data['omnipkg']['wins']} | {history_data['omnipkg']['losses']} | {omnipkg_win_rate} |
177- | pip 💥 | {history_data['pip']['wins']} | {history_data['pip']['losses']} | {pip_win_rate} |
178-
179- ### 📊 Recent Test Results
180- | Date | Test Scenario | omnipkg Result | pip Result |
181- |------|---------------|----------------|------------|
182- """
183-
184- for test in history_data['recent_tests']:
185- battle_stats_section_content += f"| {test['date']} | {test['scenario']} | {test['omnipkg_result']} | {test['pip_result']} |\n"
186-
187- battle_stats_section_content += """
188- **Test Scenario Details:**
189- - **Test Case**: Installing uv==0.7.12 and uv==0.7.14 (conflicting versions)
190- - ✅ **PASS**: Successfully maintains both versions
191- - ❌ **FAIL**: Overwrites or fails to install both versions
192- """
193-
194- try:
195- readme_content = README_FILE.read_text() if README_FILE.exists() else "# omnipkg\n\n"
196- start_marker, end_marker = "<!-- BATTLE_STATS_START -->", "<!-- BATTLE_STATS_END -->"
197-
198- if start_marker in readme_content and end_marker in readme_content:
199- # Update existing section
200- before, after = readme_content.split(start_marker)[0], readme_content.split(end_marker)[1]
201- README_FILE.write_text(before + start_marker + "\n" + battle_stats_section_content + "\n" + end_marker + after)
202- print("✅ README.md updated")
203- else:
204- # Add markers and content to end of file
205- updated_content = readme_content.rstrip() + "\n\n" + start_marker + "\n" + battle_stats_section_content + "\n" + end_marker + "\n"
206- README_FILE.write_text(updated_content)
207- print("✅ README.md updated (markers added automatically)")
208- except Exception as e:
209- print(f"Error updating README: {e}")
210-
211- try:
212- with open(RESULTS_FILE, 'w') as f:
213- json.dump(history_data, f, indent=2)
214- print(f"✅ Saved history to {RESULTS_FILE}")
215- except Exception as e:
216- print(f"Error saving history: {e}")
133+ import os
134+ from pathlib import Path
135+ from datetime import datetime
136+
137+ RESULTS_FILE = Path("battle_results_history.json")
138+ README_FILE = Path("README.md")
139+
140+ # A lean data structure
141+ default_data = {
142+ " omnipkg " : {"wins": 0, "losses": 0, "saves": 0},
143+ " pip " : {"wins": 0, "losses": 0},
144+ " uv " : {"wins": 0, "losses": 0},
145+ " recent_tests " : []
146+ }
147+
148+ # Load existing history
149+ history_data = default_data
150+ if RESULTS_FILE.exists() :
151+ try :
152+ with open(RESULTS_FILE, 'r') as f :
153+ loaded_data = json.load(f)
154+ # Basic validation to ensure new keys exist
155+ for key, value in default_data.items() :
156+ if key not in loaded_data :
157+ loaded_data[key] = value
158+ if isinstance(value, dict) :
159+ for sub_key in value :
160+ if sub_key not in loaded_data.get(key, {}) :
161+ loaded_data[key][sub_key] = value[sub_key]
162+ history_data = loaded_data
163+ except Exception as e :
164+ print(f"Warning : Could not load or migrate history, starting fresh: {e}")
165+ history_data = default_data
166+
167+ # Read results from environment variables
168+ omnipkg_conflict = os.environ.get('OMNIPKG_CONFLICT_RESULT', 'FAIL')
169+ pip_conflict = os.environ.get('PIP_CONFLICT_RESULT', 'FAIL')
170+ uv_conflict = os.environ.get('UV_CONFLICT_RESULT', 'FAIL')
171+ omnipkg_revert = os.environ.get('OMNIPKG_REVERT_RESULT', 'FAIL')
172+ test_timestamp = datetime.utcnow().strftime('%Y-%m-%d %H:%M')
173+
174+ # Update stats
175+ history_data['omnipkg']['wins' if omnipkg_conflict == 'PASS' else 'losses'] += 1
176+ history_data['pip']['wins' if pip_conflict == 'PASS' else 'losses'] += 1
177+ history_data['uv']['wins' if uv_conflict == 'PASS' else 'losses'] += 1
178+ if omnipkg_revert == 'PASS' :
179+ history_data['omnipkg']['saves'] += 1
180+
181+ # Update recent tests log
182+ history_data['recent_tests'].insert(0, {
183+ " date " : test_timestamp,
184+ " conflict_omnipkg " : omnipkg_conflict,
185+ " conflict_pip " : pip_conflict,
186+ " conflict_uv " : uv_conflict,
187+ " revert_omnipkg " : omnipkg_revert
188+ })
189+ history_data['recent_tests'] = history_data['recent_tests'][:5]
190+
191+ # --- GENERATE CONCISE README CONTENT ---
192+
193+ def calculate_win_rate(wins, losses) :
194+ total = wins + losses
195+ return f"{(wins / total * 100):.0f}%" if total > 0 else "0%"
196+
197+ omnipkg_stats = history_data['omnipkg']
198+ pip_stats = history_data['pip']
199+ uv_stats = history_data['uv']
200+
201+ omnipkg_wr = calculate_win_rate(omnipkg_stats['wins'], omnipkg_stats['losses'])
202+ pip_wr = calculate_win_rate(pip_stats['wins'], pip_stats['losses'])
203+ uv_wr = calculate_win_rate(uv_stats['wins'], uv_stats['losses'])
204+
205+ battle_stats_section_content = f"""## 🥊 omnipkg vs The World: Battle Statistics
206+ *Live-updated results from our continuous integration tests.*
207+
208+ | Package Manager | Conflict Test Wins | Environment Saves | Result |
209+ |:----------------|:------------------:|:-------------------:|:-------|
210+ | **omnipkg 🚀** | **{omnipkg_stats['wins']}** ({omnipkg_wr} Win Rate) | **{omnipkg_stats['saves']}** | ✅ **Solves Conflicts & Heals Environment** |
211+ | **pip 💥** | {pip_stats['wins']} ({pip_wr} Win Rate) | N/A | ❌ Overwrites Packages |
212+ | **uv ⚡️** | {uv_stats['wins']} ({uv_wr} Win Rate) | N/A | ❌ Overwrites Packages |
213+
214+ **Test Scenarios:**
215+ - **Conflict Test**: Attempting to install conflicting versions of another package manager (e.g., `pip==24.0` and `pip==23.2.1`). A "Win" means both versions are usable.
216+ - **Environment Save**: After another tool (`uv`) damages the environment by downgrading itself, `omnipkg revert` is run. A "Save" means the environment was successfully restored.
217+
218+ # ## 📊 Recent Test Log
219+ | Date (UTC) | omnipkg (Conflict) | pip (Conflict) | uv (Conflict) | omnipkg (Revert) |
220+ |:-----------|:------------------:|:--------------:|:-------------:|:----------------:|
221+ " " "
222+ for test in history_data['recent_tests']:
223+ battle_stats_section_content += f" | {test['date']} | {test['conflict_omnipkg']} | {test['conflict_pip']} | {test['conflict_uv']} | {test['revert_omnipkg']} |\n"
224+
225+
226+ # --- UPDATE THE README FILE ---
227+
228+ try :
229+ readme_content = README_FILE.read_text(encoding='utf-8') if README_FILE.exists() else "# omnipkg\n\n"
230+ start_marker, end_marker = "<!-- BATTLE_STATS_START -->", "<!-- BATTLE_STATS_END -->"
231+
232+ if start_marker in readme_content and end_marker in readme_content :
233+ before, after = readme_content.split(start_marker)[0], readme_content.split(end_marker)[1]
234+ README_FILE.write_text(before + start_marker + "\n" + battle_stats_section_content + "\n" + end_marker + after, encoding='utf-8')
235+ print("✅ README.md updated with concise battle stats")
236+ else :
237+ updated_content = readme_content.rstrip() + "\n\n" + start_marker + "\n" + battle_stats_section_content + "\n" + end_marker + "\n"
238+ README_FILE.write_text(updated_content, encoding='utf-8')
239+ print("✅ README.md updated (markers added automatically)")
240+ except Exception as e :
241+ print(f"Error updating README : {e}")
242+
243+ # --- SAVE HISTORY FOR NEXT RUN ---
244+ try :
245+ with open(RESULTS_FILE, 'w') as f :
246+ json.dump(history_data, f, indent=2)
247+ print(f"✅ Saved history to {RESULTS_FILE}")
248+ except Exception as e :
249+ print(f"Error saving history : {e}")
217250 EOF
218251 python update_battle_report.py
219252
@@ -222,7 +255,6 @@ jobs:
222255 with :
223256 name : battle-history
224257 path : battle_results_history.json
225- retention-days : 90
226258
227259 - name : 💾 Commit README Updates
228260 run : |
@@ -232,6 +264,6 @@ jobs:
232264 if git diff --staged --quiet; then
233265 echo "No changes to commit"
234266 else
235- git commit -m "🥊 Battle update: omnipkg vs pip results - $(date -u '+%Y-%m-%d %H:%M UTC') "
267+ git commit -m "🥊 Battle update: omnipkg vs The World results "
236268 git push
237269 fi
0 commit comments