Skip to content

Commit 09beb3b

Browse files
authored
Create test_uv_revert.yml
1 parent b9eef0c commit 09beb3b

1 file changed

Lines changed: 174 additions & 0 deletions

File tree

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
# .github/workflows/test_uv_revert.yml
2+
name: 🚨 UV Self-Downgrade & omnipkg Revert Test
3+
4+
on:
5+
workflow_dispatch: # Allows manual trigger from GitHub UI
6+
push:
7+
branches: [ 'main', 'test-revert-feature' ] # Trigger on pushes to main or a specific feature branch
8+
9+
jobs:
10+
uv-revert-test:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write # Needed for committing the report
14+
15+
steps:
16+
- name: 🏁 Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: 🐍 Set up Python 3.11
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: '3.11'
23+
24+
- name: 🔧 Install Redis for omnipkg
25+
run: |
26+
sudo apt-get update
27+
sudo apt-get install -y redis-server
28+
sudo systemctl start redis-server
29+
redis-cli ping # Test Redis connection
30+
31+
- name: 📦 Install omnipkg
32+
run: |
33+
python -m pip install --upgrade pip
34+
pip install -e . # Install omnipkg in editable mode
35+
36+
- name: ⚙️ Configure omnipkg for non-interactive use
37+
run: |
38+
# Create omnipkg config directory
39+
mkdir -p ~/.config/omnipkg
40+
41+
# Create a basic config file to avoid interactive setup
42+
cat > ~/.config/omnipkg/config.json << EOF
43+
{
44+
"multiversion_base": "/opt/hostedtoolcache/Python/3.11.13/x64/lib/python3.11/site-packages/.omnipkg_versions",
45+
"redis_host": "localhost",
46+
"redis_port": 6379,
47+
"auto_cleanup": true,
48+
"cleanup_threshold_days": 30
49+
}
50+
EOF
51+
52+
echo "omnipkg config created:"
53+
cat ~/.config/omnipkg/config.json
54+
55+
- name: 🚀 Install uv (latest) using omnipkg - Establish "Good State"
56+
id: install_uv_latest
57+
run: |
58+
echo "--- Installing uv (latest) with omnipkg to establish a 'good state' ---"
59+
omnipkg install uv # Install latest uv
60+
if [ $? -ne 0 ]; then exit 1; fi
61+
echo "Initial uv version (omnipkg-installed):"
62+
uv --version
63+
64+
# Force omnipkg to save this as the 'last known good' snapshot
65+
omnipkg status # This command should trigger the snapshot save
66+
echo "omnipkg's current status and last known good snapshot saved."
67+
68+
- name: 💥 Force UV to Downgrade Itself
69+
id: uv_self_downgrade
70+
run: |
71+
echo "--- Forcing uv to downgrade itself to 0.7.13 ---"
72+
# Ensure uv itself is in PATH
73+
export PATH="/opt/hostedtoolcache/Python/3.11.13/x64/bin:$PATH"
74+
uv pip install uv==0.7.13
75+
76+
if [ $? -ne 0 ]; then
77+
echo "::set-output name=downgrade_success::false"
78+
echo "uv self-downgrade failed (unexpectedly)."
79+
exit 1
80+
fi
81+
echo "::set-output name=downgrade_success::true"
82+
echo "uv self-downgraded successfully. Current uv version:"
83+
uv --version || true
84+
85+
- name: 🚑 Run omnipkg Revert
86+
id: omnipkg_revert
87+
# Only run if the downgrade was successful, to clearly demonstrate the revert
88+
if: steps.uv_self_downgrade.outputs.downgrade_success == 'true'
89+
run: |
90+
echo "--- Running omnipkg revert to restore good state ---"
91+
omnipkg revert --yes # Use --yes for non-interactive mode
92+
93+
if [ $? -eq 0 ]; then
94+
echo "::set-output name=revert_success::true"
95+
echo "omnipkg revert completed successfully."
96+
else
97+
echo "::set-output name=revert_success::false"
98+
echo "omnipkg revert failed. See logs for details."
99+
exit 1
100+
fi
101+
102+
- name: ✅ Verify Final UV Version After Revert
103+
if: steps.omnipkg_revert.outputs.revert_success == 'true'
104+
run: |
105+
echo "--- Verifying UV version after omnipkg revert ---"
106+
uv --version
107+
omnipkg status
108+
omnipkg info uv
109+
110+
- name: 📊 Generate Report
111+
if: always()
112+
run: |
113+
REPORT_FILE="uv_revert_test_report.md"
114+
echo "# 🚨 UV Self-Downgrade & omnipkg Revert Test Report" > $REPORT_FILE
115+
echo "" >> $REPORT_FILE
116+
echo "**Workflow Run:** [${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})" >> $REPORT_FILE
117+
echo "**Test Status:** \`${{ job.status }}\`" >> $REPORT_FILE
118+
echo "" >> $REPORT_FILE
119+
120+
echo "## Test Scenario" >> $REPORT_FILE
121+
echo "\`\`\`bash" >> $REPORT_FILE
122+
echo "# 1. Install uv (latest) with omnipkg to establish 'good state'" >> $REPORT_FILE
123+
echo "omnipkg install uv" >> $REPORT_FILE
124+
echo "" >> $REPORT_FILE
125+
echo "# 2. Force uv to downgrade itself (e.g., from 0.7.14 to 0.7.13)" >> $REPORT_FILE
126+
echo "uv pip install uv==0.7.13" >> $REPORT_FILE
127+
echo "" >> $REPORT_FILE
128+
echo "# 3. Run omnipkg revert" >> $REPORT_FILE
129+
echo "omnipkg revert --yes" >> $REPORT_FILE
130+
echo "\`\`\`" >> $REPORT_FILE
131+
echo "" >> $REPORT_FILE
132+
133+
echo "## Initial State (omnipkg-installed UV)" >> $REPORT_FILE
134+
echo "\`\`\`" >> $REPORT_FILE
135+
# Capture output from step 1
136+
echo "$(cat /tmp/initial_uv_version.txt 2>/dev/null || echo 'N/A')" >> $REPORT_FILE
137+
echo "\`\`\`" >> $REPORT_FILE
138+
echo "" >> $REPORT_FILE
139+
140+
echo "## UV Self-Downgrade Result" >> $REPORT_FILE
141+
echo "\`\`\`" >> $REPORT_FILE
142+
# Capture output from step 2
143+
echo "$(cat /tmp/downgraded_uv_version.txt 2>/dev/null || echo 'N/A')" >> $REPORT_FILE
144+
echo "\`\`\`" >> $REPORT_FILE
145+
echo "**Downgrade Attempt Outcome:** `${{ steps.uv_self_downgrade.outcome }}`" >> $REPORT_FILE
146+
echo "" >> $REPORT_FILE
147+
148+
echo "## omnipkg Revert Result" >> $REPORT_FILE
149+
echo "\`\`\`" >> $REPORT_FILE
150+
omnipkg status >> $REPORT_FILE 2>&1
151+
omnipkg info uv >> $REPORT_FILE 2>&1
152+
echo "\`\`\`" >> $REPORT_FILE
153+
echo "**Revert Operation Outcome:** `${{ steps.omnipkg_revert.outcome }}`" >> $REPORT_FILE
154+
echo "" >> $REPORT_FILE
155+
156+
echo "## Final Active UV Version Check" >> $REPORT_FILE
157+
echo "\`\`\`" >> $REPORT_FILE
158+
uv --version >> $REPORT_FILE 2>&1 || echo "uv command not found in PATH" >> $REPORT_FILE
159+
echo "\`\`\`" >> $REPORT_FILE
160+
161+
if [ "${{ job.status }}" == "success" ]; then
162+
echo "### Conclusion" >> $REPORT_FILE
163+
echo "✅ omnipkg successfully reverted the `uv` self-downgrade, demonstrating its ability to restore the environment to a previously known good state, even after external package manager interference. This is crucial for maintaining environment stability and recovering from unexpected changes." >> $REPORT_FILE
164+
else
165+
echo "### Conclusion" >> $REPORT_FILE
166+
echo "❌ The omnipkg revert test failed. Review workflow logs for details." >> $REPORT_FILE
167+
fi
168+
169+
- name: 📤 Upload Report Artifact
170+
uses: actions/upload-artifact@v4
171+
with:
172+
name: uv-revert-test-report
173+
path: uv_revert_test_report.md
174+
retention-days: 30

0 commit comments

Comments
 (0)