-
-
Notifications
You must be signed in to change notification settings - Fork 1
198 lines (178 loc) · 10.3 KB
/
Copy pathtest_uv_revert.yml
File metadata and controls
198 lines (178 loc) · 10.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
name: "🔄 UV Self-Downgrades → Auto-Revert"
on:
workflow_dispatch:
push:
branches: ['development']
jobs:
uv-revert-test:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: 🏁 Checkout code
uses: actions/checkout@v4
- name: 🐍 Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: 🔧 Install Redis for omnipkg
run: |
sudo apt-get update
sudo apt-get install -y redis-server
sudo systemctl start redis-server
redis-cli ping
- name: 📦 Install omnipkg
run: |
python -m pip install --upgrade pip
pip install -e .
- name: ⚙️ Configure omnipkg for non-interactive use
run: |
python - << 'EOF'
import sys
import site
import json
from pathlib import Path
import os
site_packages_path = site.getsitepackages()[0]
python_executable_path = sys.executable
project_root = Path(os.environ['GITHUB_WORKSPACE'])
config_data = {
'site_packages_path': site_packages_path,
'multiversion_base': str(Path(site_packages_path) / '.omnipkg_versions'),
'python_executable': python_executable_path,
'builder_script_path': str(project_root / 'omnipkg' / 'package_meta_builder.py'),
'redis_host': 'localhost',
'redis_port': 6379,
'redis_key_prefix': 'omnipkg:pkg:',
'paths_to_index': [str(Path(python_executable_path).parent), '/usr/local/bin', '/usr/bin', '/bin', '/usr/sbin', '/sbin'],
'auto_cleanup': True,
'cleanup_threshold_days': 30
}
config_dir = Path.home() / '.config' / 'omnipkg'
config_dir.mkdir(parents=True, exist_ok=True)
config_path = config_dir / 'config.json'
with open(config_path, 'w') as f:
json.dump(config_data, f, indent=2)
print(f'omnipkg config created at {config_path}:')
print(json.dumps(config_data, indent=2))
EOF
- name: 🚀 Install uv (latest) using omnipkg - Establish "Good State"
id: install_uv_latest
run: |
echo "--- Installing uv (latest) with omnipkg to establish a 'good state' with snapshot ---"
# FIX: Removed '-y'. Omnipkg detects CI environment automatically (see logs),
# and '-y' was raising "unrecognized arguments".
omnipkg install uv==0.8.13 2>&1 | tee /tmp/initial_uv_install_output.txt
# PIPESTATUS[0] captures the exit code of omnipkg, not tee.
if [ ${PIPESTATUS[0]} -ne 0 ]; then
echo "omnipkg_install_uv_success=false" >> $GITHUB_OUTPUT
exit 1
fi
echo "Initial uv version (omnipkg-installed):" | tee /tmp/initial_uv_version.txt
uv --version | tee -a /tmp/initial_uv_version.txt
echo "omnipkg status after installing uv:" | tee -a /tmp/initial_uv_version.txt
# Use --non-interactive instead of a pipe
omnipkg status --non-interactive | tee -a /tmp/initial_uv_version.txt
echo "omnipkg snapshot created - now we can revert uv's self-sabotage!"
- name: 💥 Force UV to Downgrade Itself (with --system)
id: uv_self_downgrade
run: |
echo "--- Forcing uv to downgrade itself to 0.7.13 using 'uv pip install --system' ---"
echo "Note: Using --system to allow uv to operate within this non-uv-managed virtual environment."
uv pip install uv==0.7.13 --system > /tmp/uv_downgrade_output.txt 2>&1
UV_EXIT_CODE=$?
echo "UV_EXIT_CODE=$UV_EXIT_CODE" >> $GITHUB_OUTPUT
if [ $UV_EXIT_CODE -eq 0 ]; then
echo "downgrade_outcome=success" >> $GITHUB_OUTPUT
echo "uv self-downgraded successfully."
echo "Current uv version (after uv's operation):" | tee -a /tmp/uv_downgrade_output.txt
uv --version | tee -a /tmp/uv_downgrade_output.txt || true
else
echo "downgrade_outcome=failure" >> $GITHUB_OUTPUT
echo "uv self-downgrade failed unexpectedly. Review output."
ERROR_MSG=$(grep -Eo 'error: No virtual environment found|failed to hardlink files|permission denied|Error: Process completed with exit code [0-9]+' /tmp/uv_downgrade_output.txt | head -n 1)
echo "uv_error_message=$ERROR_MSG" >> $GITHUB_OUTPUT
fi
echo "Full output from uv self-downgrade attempt captured to /tmp/uv_downgrade_output.txt"
cat /tmp/uv_downgrade_output.txt
- name: 🚑 Run omnipkg Revert (Regardless of UV's Previous Outcome)
id: omnipkg_revert
run: |
echo "--- Running omnipkg revert to restore good state (omnipkg can recover from other tools' actions) ---"
omnipkg revert --yes
if [ $? -eq 0 ]; then
echo "revert_success=true" >> $GITHUB_OUTPUT
echo "omnipkg revert completed successfully."
else
echo "revert_success=false" >> $GITHUB_OUTPUT
echo "omnipkg revert failed. See logs for details."
exit 1
fi
- name: ✅ Verify Final UV Version After Revert
if: steps.omnipkg_revert.outputs.revert_success == 'true'
run: |
echo "--- Verifying UV version after omnipkg revert ---" | tee /tmp/final_uv_version.txt
uv --version | tee -a /tmp/final_uv_version.txt || echo "uv command not found or failed after revert." | tee -a /tmp/final_uv_version.txt
echo "--- omnipkg status after revert ---" | tee -a /tmp/final_uv_version.txt
omnipkg status --non-interactive | tee -a /tmp/final_uv_version.txt
echo "--- omnipkg info uv after revert ---" | tee -a /tmp/final_uv_version.txt
# Use positional argument '1' and --non-interactive
omnipkg info uv 1 --non-interactive | tee -a /tmp/final_uv_version.txt
- name: 📊 Generate Report
if: always()
run: |
REPORT_FILE="uv_revert_test_report.md"
echo "# 🚨 UV Self-Downgrade & omnipkg Revert Test Report" > $REPORT_FILE
echo "" >> $REPORT_FILE
echo "**Workflow Run:** [${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})" >> $REPORT_FILE
echo "**Test Status:** \`${{ job.status }}\`" >> $REPORT_FILE
echo "" >> $REPORT_FILE
echo "## Test Scenario" >> $REPORT_FILE
echo "\`\`\`bash" >> $REPORT_FILE
echo "# 1. Install uv (latest) using omnipkg to establish 'good state'" >> $REPORT_FILE
echo "omnipkg install uv" >> $REPORT_FILE
echo "" >> $REPORT_FILE
echo "# 2. Force uv to downgrade itself using 'uv pip install --system'" >> $REPORT_FILE
echo "uv pip install uv==0.7.13 --system" >> $REPORT_FILE
echo "" >> $REPORT_FILE
echo "# 3. Run omnipkg revert to restore environment" >> $REPORT_FILE
echo "omnipkg revert --yes" >> $REPORT_FILE
echo "\`\`\`" >> $REPORT_FILE
echo "" >> $REPORT_FILE
echo "## Initial State (omnipkg-installed UV)" >> $REPORT_FILE
echo "\`\`\`" >> $REPORT_FILE
cat /tmp/initial_uv_install_output.txt 2>/dev/null || echo 'N/A: Initial UV install output missing.' >> $REPORT_FILE
echo "---" >> $REPORT_FILE
cat /tmp/initial_uv_version.txt 2>/dev/null || echo 'N/A: Initial UV version check failed.' >> $REPORT_FILE
echo "\`\`\`" >> $REPORT_FILE
echo "" >> $REPORT_FILE
echo "## UV Self-Downgrade Attempt Result (via \`uv pip install --system\`)" >> $REPORT_FILE
echo "\`\`\`" >> $REPORT_FILE
cat /tmp/uv_downgrade_output.txt 2>/dev/null || echo 'N/A: UV downgrade attempt output missing.' >> $REPORT_FILE
echo "\`\`\`" >> $REPORT_FILE
echo "**UV Downgrade Attempt Outcome (uv's own operation):** \`${{ steps.uv_self_downgrade.outputs.downgrade_outcome }}\`" >> $REPORT_FILE
if [ "${{ steps.uv_self_downgrade.outputs.downgrade_outcome }}" == "success" ]; then
echo "**Note:** \`uv\` successfully self-downgraded in this standard virtual environment by explicitly using the \`--system\` flag, demonstrating its ability to modify the environment. \`omnipkg\` then proceeds to revert this change." >> $REPORT_FILE
else
echo "**Insight:** Even with \`--system\`, \`uv\` encountered an unexpected issue trying to operate within this standard environment (Error: \`${{ steps.uv_self_downgrade.outputs.uv_error_message }}\`). This still underscores \`omnipkg\`'s superior adaptability, as \`omnipkg\` will still attempt to recover the environment, highlighting its robustness where other tools might fail or act unpredictably." >> $REPORT_FILE
fi
echo "" >> $REPORT_FILE
echo "## omnipkg Revert Result (and Final State)" >> $REPORT_FILE
echo "\`\`\`" >> $REPORT_FILE
cat /tmp/final_uv_version.txt 2>/dev/null || echo 'N/A: Final UV verification output missing.' >> $REPORT_FILE
echo "\`\`\`" >> $REPORT_FILE
echo "**omnipkg Revert Operation Outcome:** \`${{ steps.omnipkg_revert.outcome }}\`" >> $REPORT_FILE
echo "" >> $REPORT_FILE
if [ "${{ job.status }}" == "success" ]; then
echo "### Conclusion" >> $REPORT_FILE
echo "✅ **omnipkg successfully restored the environment to its last known good state, effectively reversing the \`uv\` self-downgrade (or demonstrating recovery from its operational challenges).** This test highlights \`omnipkg\`'s unparalleled ability to maintain environment integrity and provide robust recovery, even when faced with the specific operational modes of other package managers." >> $REPORT_FILE
else
echo "### Conclusion" >> $REPORT_FILE
echo "❌ The \`omnipkg\` revert test failed. Review workflow logs for details." >> $REPORT_FILE
fi
- name: 📤 Upload Report Artifact
uses: actions/upload-artifact@v4
with:
name: uv-revert-test-report
path: uv_revert_test_report.md
retention-days: 30