Skip to content

Commit c4a8aaf

Browse files
authored
Update omnipkg_vs_the_world.yml
1 parent 210add7 commit c4a8aaf

1 file changed

Lines changed: 67 additions & 156 deletions

File tree

Lines changed: 67 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
```yaml
12
name: 🥊 omnipkg vs The World - Battle & Resilience Test
23
34
on:
45
schedule:
56
- cron: '0 * * * *' # Run every hour
67
workflow_dispatch:
8+
push:
9+
branches: [ 'main', 'test-workflows-feature' ]
710
811
jobs:
912
comparison-test:
@@ -27,7 +30,6 @@ jobs:
2730
uses: actions/checkout@v4
2831
with:
2932
token: ${{ secrets.GITHUB_TOKEN }}
30-
# Make sure we get the latest README with any previous updates
3133
fetch-depth: 1
3234
3335
- name: 🐍 Set up Python 3.11
@@ -42,7 +44,6 @@ jobs:
4244
4345
- name: ⚙️ Configure omnipkg
4446
run: |
45-
# Your configuration script remains the same
4647
python - << 'EOF'
4748
import sys, site, json, os, sysconfig
4849
from pathlib import Path
@@ -67,60 +68,55 @@ jobs:
6768
json.dump(config_data, f, indent=2)
6869
EOF
6970
70-
# --- CONFLICT INSTALLATION TESTS (Managing the Managers) ---
71-
7271
- name: 🚀 omnipkg | Battle Test (PASS Expected)
7372
id: omnipkg_conflict_test
7473
run: |
7574
echo "--- Testing omnipkg installing conflicting versions of pip ---"
7675
if omnipkg install pip==24.0 pip==23.2.1; then
7776
echo "OMNIPKG_CONFLICT_RESULT=PASS" >> $GITHUB_ENV
77+
echo "✅ omnipkg: Installed multiple pip versions"
7878
else
7979
echo "OMNIPKG_CONFLICT_RESULT=FAIL" >> $GITHUB_ENV
80+
echo "❌ omnipkg: Failed to install multiple pip versions"
8081
fi
8182
8283
- name: 💥 pip | Battle Test (FAIL Expected)
8384
id: pip_conflict_test
8485
run: |
8586
echo "--- Testing pip downgrading itself ---"
86-
pip install pip==24.0 > /dev/null 2>&1
87-
pip install pip==23.2.1 > /dev/null 2>&1
88-
# This is an expected failure where pip sabotages itself, so we report FAIL for the stats
87+
pip install pip==24.0 > pip_conflict.log 2>&1
88+
pip install pip==23.2.1 >> pip_conflict.log 2>&1
8989
echo "PIP_CONFLICT_RESULT=FAIL" >> $GITHUB_ENV
90+
echo "❌ pip: Mercilessly downgraded itself (expected)"
91+
cat pip_conflict.log
9092
9193
- name: ⚡️ uv | Battle Test (FAIL Expected)
9294
id: uv_conflict_test
9395
run: |
9496
echo "--- Testing uv downgrading itself ---"
95-
uv pip install uv==0.5.0 --system > /dev/null 2>&1 || true
96-
uv pip install uv==0.4.0 --system > /dev/null 2>&1 || true
97-
# This is an expected failure where uv sabotages itself, so we report FAIL for the stats
97+
uv pip install uv==0.5.0 --system > uv_conflict.log 2>&1 || true
98+
uv pip install uv==0.4.0 --system >> uv_conflict.log 2>&1 || true
9899
echo "UV_CONFLICT_RESULT=FAIL" >> $GITHUB_ENV
99-
100-
# --- RESILIENCE TEST (Self-Sabotage & Revert) ---
100+
echo "❌ uv: Also downgraded itself (but faster!) (expected)"
101+
cat uv_conflict.log
101102
102103
- name: 🛡️ omnipkg | Resilience Test (PASS Expected)
103104
id: omnipkg_revert_test
104105
run: |
105106
echo "--- Testing omnipkg reverting uv's self-sabotage ---"
106-
# 1. Establish a known good state with the latest uv
107107
omnipkg install uv
108-
LATEST_UV_VER=$(uv --version | awk '{print $2}')
109-
echo "Established good state with uv version: $LATEST_UV_VER"
110-
111-
# 2. Let uv damage the environment by downgrading itself
112-
uv pip install uv==0.7.1 --system
113-
echo "uv version after self-sabotage: $(uv --version | awk '{print $2}')"
114-
115-
# 3. omni revert! The logs will show the "uv in jail" status.
116-
if omnipkg revert -y; then
108+
latest_uv=$(uv --version | awk '{print $2}')
109+
echo "Baseline uv: $latest_uv"
110+
uv pip install uv==0.7.1 --system > revert.log 2>&1
111+
echo "After sabotage: $(uv --version | awk '{print $2}')"
112+
if omnipkg revert -y >> revert.log 2>&1; then
117113
echo "OMNIPKG_REVERT_RESULT=PASS" >> $GITHUB_ENV
118-
echo "Revert successful! Final uv version: $(uv --version | awk '{print $2}')"
114+
echo "✅ omnipkg: Reverted to uv $latest_uv"
119115
else
120116
echo "OMNIPKG_REVERT_RESULT=FAIL" >> $GITHUB_ENV
117+
echo "❌ omnipkg: Revert failed"
121118
fi
122-
123-
# --- EXTRACT EXISTING STATS FROM README (Git-based persistence) ---
119+
cat revert.log
124120
125121
- name: 📊 Extract Current Stats from README
126122
run: |
@@ -131,127 +127,66 @@ jobs:
131127
132128
README_FILE = Path("README.md")
133129
134-
# Default values
135-
omnipkg_wins = 0
136-
omnipkg_saves = 0
137-
pip_wins = 0
138-
uv_wins = 0
130+
omnipkg_wins = omnipkg_saves = pip_wins = uv_wins = 0
131+
omnipkg_losses = pip_losses = uv_losses = 0
139132
140133
if README_FILE.exists():
141134
try:
142-
readme_content = README_FILE.read_text(encoding='utf-8')
135+
content = README_FILE.read_text(encoding='utf-8')
143136
144-
# Extract omnipkg wins - look for pattern like "**42** (95% Win Rate)"
145-
omnipkg_match = re.search(r'\*\*omnipkg 🚀\*\*\s*\|\s*\*\*(\d+)\*\*.*?\|\s*\*\*(\d+)\*\*', readme_content)
137+
omnipkg_match = re.search(r'\*\*`omnipkg 🚀`.*?\|\s*\*\*(\d+)\*\* \((\d+)%\)\s*\|\s*\*\*(\d+)\*\*', content)
146138
if omnipkg_match:
147139
omnipkg_wins = int(omnipkg_match.group(1))
148-
omnipkg_saves = int(omnipkg_match.group(2))
140+
omnipkg_losses = int(omnipkg_wins * (100 - int(omnipkg_match.group(2))) / int(omnipkg_match.group(2))) if int(omnipkg_match.group(2)) > 0 else max(1, omnipkg_wins * 100)
141+
omnipkg_saves = int(omnipkg_match.group(3))
149142

150-
# Extract pip wins - look for pattern like "42 (5% Win Rate)"
151-
pip_match = re.search(r'\*\*pip 💥\*\*\s*\|\s*(\d+)', readme_content)
143+
pip_match = re.search(r'\*\*`pip 💥`.*?\|\s*(\d+)\s*\((\d+)%\)', content)
152144
if pip_match:
153145
pip_wins = int(pip_match.group(1))
146+
pip_losses = int(pip_wins * (100 - int(pip_match.group(2))) / int(pip_match.group(2))) if int(pip_match.group(2)) > 0 else max(1, pip_wins * 100)
154147

155-
# Extract uv wins
156-
uv_match = re.search(r'\*\*uv ⚡️\*\*\s*\|\s*(\d+)', readme_content)
148+
uv_match = re.search(r'\*\*`uv ⚡️`.*?\|\s*(\d+)\s*\((\d+)%\)', content)
157149
if uv_match:
158150
uv_wins = int(uv_match.group(1))
151+
uv_losses = int(uv_wins * (100 - int(uv_match.group(2))) / int(uv_match.group(2))) if int(uv_match.group(2)) > 0 else max(1, uv_wins * 100)
159152

160-
print(f"Extracted stats: omnipkg_wins={omnipkg_wins}, omnipkg_saves={omnipkg_saves}, pip_wins={pip_wins}, uv_wins={uv_wins}")
153+
print(f"Extracted: omnipkg={omnipkg_wins}W/{omnipkg_losses}L/{omnipkg_saves}S, pip={pip_wins}W/{pip_losses}L, uv={uv_wins}W/{uv_losses}L")
161154
except Exception as e:
162-
print(f"Could not extract stats from README: {e}")
155+
print(f"Could not extract stats: {e}")
163156

164-
# Set environment variables for the next step
165157
with open(os.environ['GITHUB_ENV'], 'a') as f:
166158
f.write(f"EXISTING_OMNIPKG_WINS={omnipkg_wins}\n")
167159
f.write(f"EXISTING_OMNIPKG_SAVES={omnipkg_saves}\n")
168160
f.write(f"EXISTING_PIP_WINS={pip_wins}\n")
169161
f.write(f"EXISTING_UV_WINS={uv_wins}\n")
162+
f.write(f"EXISTING_OMNIPKG_LOSSES={omnipkg_losses}\n")
163+
f.write(f"EXISTING_PIP_LOSSES={pip_losses}\n")
164+
f.write(f"EXISTING_UV_LOSSES={uv_losses}\n")
170165
EOF
171166
python extract_stats.py
172167

173-
# --- REPORTING (Now with accumulation) ---
174-
175168
- name: 📊 Update Battle Report and README
176169
run: |
177170
cat > update_battle_report.py << 'EOF'
178-
import json
179-
import os
171+
import os, re
180172
from pathlib import Path
181173
from datetime import datetime
182174
183175
README_FILE = Path("README.md")
184-
185-
# Read current test results
176+
186177
omnipkg_conflict = os.environ.get('OMNIPKG_CONFLICT_RESULT', 'FAIL')
187178
pip_conflict = os.environ.get('PIP_CONFLICT_RESULT', 'FAIL')
188179
uv_conflict = os.environ.get('UV_CONFLICT_RESULT', 'FAIL')
189180
omnipkg_revert = os.environ.get('OMNIPKG_REVERT_RESULT', 'FAIL')
190181
test_timestamp = datetime.utcnow().strftime('%Y-%m-%d %H:%M')
191182
192-
# Get existing stats from previous step
193-
existing_omnipkg_wins = int(os.environ.get('EXISTING_OMNIPKG_WINS', '0'))
194-
existing_omnipkg_saves = int(os.environ.get('EXISTING_OMNIPKG_SAVES', '0'))
195-
existing_pip_wins = int(os.environ.get('EXISTING_PIP_WINS', '0'))
196-
existing_uv_wins = int(os.environ.get('EXISTING_UV_WINS', '0'))
197-
198-
# Calculate new totals (add 1 for each PASS, 0 for each FAIL)
199-
omnipkg_wins = existing_omnipkg_wins + (1 if omnipkg_conflict == 'PASS' else 0)
200-
omnipkg_saves = existing_omnipkg_saves + (1 if omnipkg_revert == 'PASS' else 0)
201-
pip_wins = existing_pip_wins + (1 if pip_conflict == 'PASS' else 0)
202-
uv_wins = existing_uv_wins + (1 if uv_conflict == 'PASS' else 0)
203-
204-
# For losses, we need to calculate based on a reasonable assumption
205-
# Since pip and uv are expected to fail, we'll increment their losses
206-
omnipkg_losses = existing_omnipkg_wins - omnipkg_wins + (1 if omnipkg_conflict == 'FAIL' else 0)
207-
pip_losses = existing_pip_wins - pip_wins + (1 if pip_conflict == 'FAIL' else 0)
208-
uv_losses = existing_uv_wins - uv_wins + (1 if uv_conflict == 'FAIL' else 0)
209-
210-
# But we need a better way to track total runs. Let's extract from README or use a counter approach.
211-
# For simplicity, let's assume losses = total_runs - wins, where total_runs increments each time
212-
213-
# Let's use a simpler approach: extract the current loss count from README too
214-
import re
215-
omnipkg_losses = 0 # We'll recalculate this
216-
pip_losses = 0
217-
uv_losses = 0
218-
219-
if README_FILE.exists():
220-
try:
221-
readme_content = README_FILE.read_text(encoding='utf-8')
222-
# Look for patterns like "(95% Win Rate)" to reverse-engineer losses
223-
omnipkg_wr_match = re.search(r'\*\*omnipkg 🚀\*\*.*?\((\d+)% Win Rate\)', readme_content)
224-
if omnipkg_wr_match and existing_omnipkg_wins > 0:
225-
win_rate = int(omnipkg_wr_match.group(1))
226-
# win_rate = wins / (wins + losses) * 100
227-
# Solving for losses: losses = wins * (100 - win_rate) / win_rate
228-
if win_rate > 0:
229-
omnipkg_losses = max(0, int(existing_omnipkg_wins * (100 - win_rate) / win_rate))
230-
231-
pip_wr_match = re.search(r'\*\*pip 💥\*\*.*?\((\d+)% Win Rate\)', readme_content)
232-
if pip_wr_match and existing_pip_wins >= 0:
233-
win_rate = int(pip_wr_match.group(1))
234-
if win_rate > 0:
235-
pip_losses = max(0, int(existing_pip_wins * (100 - win_rate) / win_rate))
236-
else:
237-
# If 0% win rate, we need to look for the total run count another way
238-
# For now, let's count this run as a loss
239-
pip_losses = max(1, existing_pip_wins * 100) # Rough estimate
240-
241-
uv_wr_match = re.search(r'\*\*uv ⚡️\*\*.*?\((\d+)% Win Rate\)', readme_content)
242-
if uv_wr_match and existing_uv_wins >= 0:
243-
win_rate = int(uv_wr_match.group(1))
244-
if win_rate > 0:
245-
uv_losses = max(0, int(existing_uv_wins * (100 - win_rate) / win_rate))
246-
else:
247-
uv_losses = max(1, existing_uv_wins * 100)
248-
except Exception as e:
249-
print(f"Could not extract loss counts: {e}")
250-
251-
# Add current run results to loss counts
252-
omnipkg_losses += (1 if omnipkg_conflict == 'FAIL' else 0)
253-
pip_losses += (1 if pip_conflict == 'FAIL' else 0)
254-
uv_losses += (1 if uv_conflict == 'FAIL' else 0)
183+
omnipkg_wins = int(os.environ.get('EXISTING_OMNIPKG_WINS', '0')) + (1 if omnipkg_conflict == 'PASS' else 0)
184+
omnipkg_saves = int(os.environ.get('EXISTING_OMNIPKG_SAVES', '0')) + (1 if omnipkg_revert == 'PASS' else 0)
185+
pip_wins = int(os.environ.get('EXISTING_PIP_WINS', '0')) + (1 if pip_conflict == 'PASS' else 0)
186+
uv_wins = int(os.environ.get('EXISTING_UV_WINS', '0')) + (1 if uv_conflict == 'PASS' else 0)
187+
omnipkg_losses = int(os.environ.get('EXISTING_OMNIPKG_LOSSES', '0')) + (1 if omnipkg_conflict == 'FAIL' else 0)
188+
pip_losses = int(os.environ.get('EXISTING_PIP_LOSSES', '0')) + (1 if pip_conflict == 'FAIL' else 0)
189+
uv_losses = int(os.environ.get('EXISTING_UV_LOSSES', '0')) + (1 if uv_conflict == 'FAIL' else 0)
255190
256191
def calculate_win_rate(wins, losses):
257192
total = wins + losses
@@ -261,52 +196,31 @@ jobs:
261196
pip_wr = calculate_win_rate(pip_wins, pip_losses)
262197
uv_wr = calculate_win_rate(uv_wins, uv_losses)
263198
264-
print(f"Updated stats: omnipkg={omnipkg_wins}W/{omnipkg_losses}L/{omnipkg_saves}S, pip={pip_wins}W/{pip_losses}L, uv={uv_wins}W/{uv_losses}L")
199+
print(f"Updated: omnipkg={omnipkg_wins}W/{omnipkg_losses}L/{omnipkg_saves}S, pip={pip_wins}W/{pip_losses}L, uv={uv_wins}W/{uv_losses}L")
265200
266-
# Build the content using string concatenation to avoid f-string issues
267-
battle_stats_section_content = "## 🥊 omnipkg vs The World: Battle Statistics\n"
268-
battle_stats_section_content += "*Live-updated results from our continuous integration tests.*\n\n"
269-
battle_stats_section_content += "| Package Manager | Conflict Test Wins | Environment Saves | Result |\n"
270-
battle_stats_section_content += "|:----------------|:------------------:|:-------------------:|:-------|\n"
271-
battle_stats_section_content += f"| **omnipkg 🚀** | **{omnipkg_wins}** ({omnipkg_wr} Win Rate) | **{omnipkg_saves}** | ✅ **Solves Conflicts & Heals Environment** |\n"
272-
battle_stats_section_content += f"| **pip 💥** | {pip_wins} ({pip_wr} Win Rate) | 0 | ❌ Overwrites Packages |\n"
273-
battle_stats_section_content += f"| **uv ⚡️** | {uv_wins} ({uv_wr} Win Rate) | 0 | ❌ Overwrites Packages |\n\n"
274-
battle_stats_section_content += "**Test Scenarios:**\n"
275-
battle_stats_section_content += "- **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.\n"
276-
battle_stats_section_content += "- **Environment Save**: After another tool (`uv`) damages the environment by downgrading itself, `omnipkg revert` is run. A \"Save\" means the environment was successfully restored.\n\n"
277-
battle_stats_section_content += "### 📊 Recent Test Log\n"
278-
battle_stats_section_content += "| Date (UTC) | omnipkg (Conflict) | pip (Conflict) | uv (Conflict) | omnipkg (Revert) |\n"
279-
battle_stats_section_content += "|:-----------|:------------------:|:--------------:|:-------------:|:----------------:|\n"
280-
battle_stats_section_content += f"| {test_timestamp} | {omnipkg_conflict} | {pip_conflict} | {uv_conflict} | {omnipkg_revert} |"
201+
badge = "[![💥 Nuclear Test: TensorFlow Dependency Hot-Swap](https://github.com/1minds3t/omnipkg/actions/workflows/test-tensorflow-switching.yml/badge.svg)](https://github.com/1minds3t/omnipkg/actions/workflows/test-tensorflow-switching.yml)"
202+
battle_stats = f"""\
203+
## 🥊 Package Manager Thunderdome {badge}
281204

282-
# Try to preserve some recent test history from existing README
283-
if README_FILE.exists():
284-
try:
285-
readme_content = README_FILE.read_text(encoding='utf-8')
286-
# Find existing test log entries (skip the header)
287-
log_match = re.search(r'\| Date \(UTC\).*?\n\|:.*?\n((?:\| [^|]+.*?\n)*)', readme_content, re.MULTILINE)
288-
if log_match:
289-
existing_entries = log_match.group(1).strip().split('\n')
290-
# Keep up to 4 most recent entries (plus our new one = 5 total)
291-
for entry in existing_entries[:4]:
292-
if entry.strip():
293-
battle_stats_section_content += "\n" + entry
294-
except Exception as e:
295-
print(f"Could not preserve test history: {e}")
205+
| Package Manager | Conflict Wins | Environment Saves | Verdict |
206+
|:----------------|:-------------:|:-----------------:|:--------|
207+
| **`omnipkg` 🚀** | **{omnipkg_wins}** ({omnipkg_wr}) | **{omnipkg_saves}** | ✅ Solves conflicts *and* heals environments |
208+
| **`pip` 💥** | {pip_wins} ({pip_wr}) | N/A | ❌ Mercilessly overwrites itself |
209+
| **`uv` ⚡️** | {uv_wins} ({uv_wr}) | N/A | ❌ Also overwrites itself (but faster!) |
296210

297-
# --- UPDATE THE README FILE ---
211+
### 📊 Latest Test: {test_timestamp} (UTC)
212+
"""
213+
298214
try:
299-
readme_content = README_FILE.read_text(encoding='utf-8') if README_FILE.exists() else "# omnipkg\n\n"
300-
start_marker, end_marker = "<!-- BATTLE_STATS_START -->", "<!-- BATTLE_STATS_END -->"
301-
302-
if start_marker in readme_content and end_marker in readme_content:
303-
before, after = readme_content.split(start_marker)[0], readme_content.split(end_marker)[1]
304-
README_FILE.write_text(before + start_marker + "\n" + battle_stats_section_content + "\n" + end_marker + after, encoding='utf-8')
305-
print("✅ README.md updated with accumulated battle stats")
215+
content = README_FILE.read_text(encoding='utf-8') if README_FILE.exists() else "# omnipkg\n\n"
216+
start, end = "<!-- BATTLE_STATS_START -->", "<!-- BATTLE_STATS_END -->"
217+
if start in content and end in content:
218+
before, after = content.split(start)[0], content.split(end)[1]
219+
README_FILE.write_text(before + start + "\n" + battle_stats + "\n" + end + after, encoding='utf-8')
220+
print("✅ README.md updated")
306221
else:
307-
updated_content = readme_content.rstrip() + "\n\n" + start_marker + "\n" + battle_stats_section_content + "\n" + end_marker + "\n"
308-
README_FILE.write_text(updated_content, encoding='utf-8')
309-
print("✅ README.md updated (markers added automatically)")
222+
README_FILE.write_text(content.rstrip() + "\n\n" + start + "\n" + battle_stats + "\n" + end, encoding='utf-8')
223+
print("✅ README.md updated (markers added)")
310224
except Exception as e:
311225
print(f"Error updating README: {e}")
312226
EOF
@@ -316,15 +230,12 @@ jobs:
316230
run: |
317231
git config --local user.email "action@github.com"
318232
git config --local user.name "omnipkg Battle Bot"
319-
320-
# Pull latest changes first, before staging anything
321233
git pull --rebase origin main || true
322-
323-
# Now stage and commit our changes
324234
git add README.md
325235
if git diff --staged --quiet; then
326236
echo "No changes to commit"
327237
else
328-
git commit -m "🥊 Battle update: omnipkg vs The World results"
238+
git commit -m "🥊 Thunderdome update: omnipkg vs The World - $(date -u '+%Y-%m-%d %H:%M UTC')"
329239
git push
330240
fi
241+
```

0 commit comments

Comments
 (0)