-
-
Notifications
You must be signed in to change notification settings - Fork 1
256 lines (214 loc) · 10.6 KB
/
Copy pathbasic_package_upgrade.yml
File metadata and controls
256 lines (214 loc) · 10.6 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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
name: "⬆️ LIVE - Package Upgrade Test"
on:
push:
branches: [ development ]
pull_request:
branches: [ development ]
workflow_dispatch:
jobs:
test-package-upgrade:
runs-on: ubuntu-latest
services:
redis:
image: redis:7
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install pip==24.0
pip install -e . redis
- name: Configure omnipkg and Establish Authoritative ENV_ID
id: setup_omnipkg
run: |
python - << 'EOF'
import json
import os
from pathlib import Path
from omnipkg.core import ConfigManager
config_dir = Path.home() / '.config' / 'omnipkg'
config_dir.mkdir(parents=True, exist_ok=True)
config = {
"interactive": False,
"auto_confirm": True,
"redis_url": "redis://localhost:6379"
}
with open(config_dir / 'config.json', 'w') as f:
json.dump(config, f, indent=2)
print("✅ Omnipkg configured for non-interactive use")
main_env_id = ConfigManager().env_id
print(f"Authoritative Environment ID for this job: {main_env_id}")
with open(os.environ['GITHUB_ENV'], 'a') as f:
f.write(f"OMNIPKG_ENV_ID_OVERRIDE={main_env_id}\n")
EOF
- name: Set Install Strategy to Latest-Active
env:
OMNIPKG_ENV_ID_OVERRIDE: ${{ env.OMNIPKG_ENV_ID_OVERRIDE }}
run: |
echo "--- Setting install strategy to latest-active ---"
omnipkg config set install_strategy latest-active
- name: Install Older Version of Package
env:
OMNIPKG_ENV_ID_OVERRIDE: ${{ env.OMNIPKG_ENV_ID_OVERRIDE }}
run: |
echo "--- Installing older version of requests (2.28.0) ---"
mkdir -p /tmp/omnipkg-artifacts
# This is the first command requiring a daemon.
# It will trigger the auto-start and relaunch logic.
# We use -y for non-interactive mode.
omnipkg install requests==2.28.0 2>&1 | tee /tmp/omnipkg-artifacts/install_old_version.txt
# Capture the exit code of omnipkg, not tee
INSTALL_EXIT_CODE=${PIPESTATUS[0]}
echo "## Install requests 2.28.0 Output" >> $GITHUB_STEP_SUMMARY
# Verify installation and handle relaunch logs
if [ $INSTALL_EXIT_CODE -eq 0 ] && grep -q "All package operations complete" /tmp/omnipkg-artifacts/install_old_version.txt; then
echo "✅ requests 2.28.0 installed successfully"
else
echo "❌ Failed to install requests 2.28.0"
exit 1
fi
- name: Verify Initial Version
env:
OMNIPKG_ENV_ID_OVERRIDE: ${{ env.OMNIPKG_ENV_ID_OVERRIDE }}
run: |
echo "--- Verifying initial requests version ---"
omnipkg info requests 2>&1 | tee /tmp/omnipkg-artifacts/info_before_upgrade.txt
echo "## requests Info Before Upgrade" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
cat /tmp/omnipkg-artifacts/info_before_upgrade.txt >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
# Check that 2.28.0 is active
if grep -q "Active Version: 2.28.0" /tmp/omnipkg-artifacts/info_before_upgrade.txt; then
echo "✅ Confirmed: requests 2.28.0 is active"
else
echo "❌ requests 2.28.0 is not active as expected"
exit 1
fi
- name: Run Package Upgrade
env:
OMNIPKG_ENV_ID_OVERRIDE: ${{ env.OMNIPKG_ENV_ID_OVERRIDE }}
run: |
echo "--- Running omnipkg upgrade requests ---"
# Use -y for non-interactive mode.
# PIPESTATUS[0] ensures we get the exit code of the upgrade command.
timeout 900 bash -c 'omnipkg upgrade requests -y' 2>&1 | tee /tmp/omnipkg-artifacts/upgrade_output.txt
UPGRADE_EXIT_CODE=${PIPESTATUS[0]}
echo "## Package Upgrade Output" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
cat /tmp/omnipkg-artifacts/upgrade_output.txt >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
# Verify upgrade completed
if grep -q "All package operations complete" /tmp/omnipkg-artifacts/upgrade_output.txt; then
echo "✅ Package upgrade completed successfully!"
else
echo "❌ Package upgrade did not complete successfully"
exit 1
fi
# Verify bubble was created for old version
if grep -q "Creating isolated bubble for requests v2.28.0" /tmp/omnipkg-artifacts/upgrade_output.txt || \
grep -q "Bubbled requests v2.28.0" /tmp/omnipkg-artifacts/upgrade_output.txt || \
grep -q "LATEST-ACTIVE STRATEGY: Preserving replaced versions" /tmp/omnipkg-artifacts/upgrade_output.txt; then
echo "✅ Old version (2.28.0) was bubbled!"
else
echo "⚠️ Could not verify bubble creation from output"
fi
- name: Verify Upgraded Version
env:
OMNIPKG_ENV_ID_OVERRIDE: ${{ env.OMNIPKG_ENV_ID_OVERRIDE }}
run: |
echo "--- Verifying upgraded requests version ---"
omnipkg info requests 2>&1 | tee /tmp/omnipkg-artifacts/info_after_upgrade.txt
echo "## requests Info After Upgrade" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
cat /tmp/omnipkg-artifacts/info_after_upgrade.txt >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
# Extract active version (should be latest, not 2.28.0)
ACTIVE_VERSION=$(grep "Active Version:" /tmp/omnipkg-artifacts/info_after_upgrade.txt | awk '{print $3}')
echo "Active version after upgrade: $ACTIVE_VERSION"
# Verify it's not 2.28.0 anymore
if [[ "$ACTIVE_VERSION" != "2.28.0" ]]; then
echo "✅ Confirmed: requests upgraded from 2.28.0 to $ACTIVE_VERSION"
else
echo "❌ requests is still on version 2.28.0, upgrade failed"
exit 1
fi
# Verify old version is bubbled
if grep -q "Bubbled Versions:" /tmp/omnipkg-artifacts/info_after_upgrade.txt && \
grep -q "2.28.0" /tmp/omnipkg-artifacts/info_after_upgrade.txt; then
echo "✅ Old version (2.28.0) is preserved in bubble"
else
echo "⚠️ Could not verify bubble presence for old version"
fi
- name: Test Package Functionality
env:
OMNIPKG_ENV_ID_OVERRIDE: ${{ env.OMNIPKG_ENV_ID_OVERRIDE }}
run: |
echo "--- Testing upgraded requests package ---"
# Test that requests can be imported and used
python -c "import requests; print(f'requests version: {requests.__version__}'); r = requests.get('https://httpbin.org/json'); print(f'Status: {r.status_code}')" 2>&1 | tee /tmp/omnipkg-artifacts/import_test.txt
if [ $? -eq 0 ]; then
echo "✅ Upgraded requests package works correctly!"
else
echo "❌ Failed to use upgraded requests package"
exit 1
fi
- name: Verify Bubble Swapping Works
env:
OMNIPKG_ENV_ID_OVERRIDE: ${{ env.OMNIPKG_ENV_ID_OVERRIDE }}
run: |
echo "--- Testing bubble swap back to old version ---"
# Get the active version number
ACTIVE_VERSION=$(omnipkg info requests 2>/dev/null | grep "Active Version:" | awk '{print $3}')
# Try to swap to the bubbled version (2.28.0) using -y
omnipkg install requests==2.28.0 -y 2>&1 | tee /tmp/omnipkg-artifacts/swap_to_old.txt
# Verify swap worked
NEW_ACTIVE=$(omnipkg info requests 2>/dev/null | grep "Active Version:" | awk '{print $3}')
if [[ "$NEW_ACTIVE" == "2.28.0" ]]; then
echo "✅ Successfully swapped back to bubbled version 2.28.0"
echo "✅ Bubble swapping works correctly!"
else
echo "⚠️ Swap to old version may not have worked as expected"
fi
echo "## Bubble Swap Test" >> $GITHUB_STEP_SUMMARY
echo "- Original active: $ACTIVE_VERSION" >> $GITHUB_STEP_SUMMARY
echo "- Swapped to: 2.28.0" >> $GITHUB_STEP_SUMMARY
echo "- Current active: $NEW_ACTIVE" >> $GITHUB_STEP_SUMMARY
- name: Generate Test Summary
if: always()
run: |
echo "## ⬆️ Package Upgrade Test Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Test Scenario" >> $GITHUB_STEP_SUMMARY
echo "1. Set install strategy to 'latest-active'" >> $GITHUB_STEP_SUMMARY
echo "2. Installed older version of requests (2.28.0)" >> $GITHUB_STEP_SUMMARY
echo "3. Ran \`omnipkg upgrade requests\` command" >> $GITHUB_STEP_SUMMARY
echo "4. Verified upgrade to latest version (with bubbling)" >> $GITHUB_STEP_SUMMARY
echo "5. Tested bubble swapping back to old version" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Key Verifications" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Install strategy set to 'latest-active'" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Old version (2.28.0) installed correctly" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Upgrade command executed successfully" >> $GITHUB_STEP_SUMMARY
echo "- ✅ New version became active" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Old version preserved in bubble" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Package works correctly after upgrade" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Bubble swapping works (can revert to old version)" >> $GITHUB_STEP_SUMMARY
- name: Archive Test Outputs
if: always()
uses: actions/upload-artifact@v4
with:
name: omnipkg-package-upgrade-test-output
path: /tmp/omnipkg-artifacts/
retention-days: 7
compression-level: 6