-
Notifications
You must be signed in to change notification settings - Fork 86
304 lines (236 loc) · 13.4 KB
/
update-vscode-versions.yml
File metadata and controls
304 lines (236 loc) · 13.4 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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
name: 🔄 Update VS Code Version Window
on:
schedule:
- cron: "0 9 * * 1" # Weekly on Monday at 9 AM UTC
workflow_dispatch: # Allow manual trigger
jobs:
update-versions:
runs-on: ubuntu-latest
steps:
- name: 👷🏻 Checkout Repository
uses: actions/checkout@v6
- name: ⚙️ Setup Node.js
uses: actions/setup-node@v6
with:
node-version: "lts/*"
- name: 🔍 Fetch VS Code versions with retry
id: versions
uses: nick-fields/retry@v4
with:
timeout_minutes: 5
max_attempts: 3
retry_wait_seconds: 30
command: |
# Fetch all stable releases
RELEASES=$(curl -sf https://update.code.visualstudio.com/api/releases/stable)
if [[ -z "$RELEASES" ]]; then
echo "❌ Failed to fetch VS Code releases"
exit 1
fi
# Get unique major.minor versions and find latest patch for each
# This gives us the latest 3 major versions with their latest patches
MAJOR_VERSIONS=$(echo $RELEASES | jq -r '.[]' | sed -E 's/([0-9]+\.[0-9]+)\..*/\1/' | uniq | head -3)
# Validate we have at least 3 major versions
COUNT=$(echo "$MAJOR_VERSIONS" | wc -l | tr -d ' ')
if [[ "$COUNT" -lt 3 ]]; then
echo "❌ Not enough major versions available (found $COUNT, need 3)"
exit 1
fi
# Get the latest patch version for each of the 3 major versions
MAJOR_1=$(echo "$MAJOR_VERSIONS" | sed -n '1p')
MAJOR_2=$(echo "$MAJOR_VERSIONS" | sed -n '2p')
MAJOR_3=$(echo "$MAJOR_VERSIONS" | sed -n '3p')
LATEST=$(echo $RELEASES | jq -r ".[] | select(startswith(\"$MAJOR_1\"))" | head -1)
MIDDLE=$(echo $RELEASES | jq -r ".[] | select(startswith(\"$MAJOR_2\"))" | head -1)
OLDEST=$(echo $RELEASES | jq -r ".[] | select(startswith(\"$MAJOR_3\"))" | head -1)
# Validate version format (x.y.z)
for VERSION in $LATEST $MIDDLE $OLDEST; do
if ! [[ $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "❌ Invalid version format: $VERSION"
exit 1
fi
done
echo "✅ Found valid versions:"
echo " Latest: $LATEST"
echo " Middle: $MIDDLE"
echo " Oldest: $OLDEST"
echo "latest=$LATEST" >> $GITHUB_OUTPUT
echo "middle=$MIDDLE" >> $GITHUB_OUTPUT
echo "oldest=$OLDEST" >> $GITHUB_OUTPUT
# Get current values
CURRENT_MAX=$(jq -r '.supportedVersions["vscode-max"]' packages/extester/package.json)
CURRENT_MIN=$(jq -r '.supportedVersions["vscode-min"]' packages/extester/package.json)
CURRENT_MIDDLE=$(grep 'version: \[min,' .github/workflows/main.yml | sed -E 's/.*version: \[min, ([^,]+),.*/\1/' | tr -d ' ')
echo "current_max=$CURRENT_MAX" >> $GITHUB_OUTPUT
echo "current_min=$CURRENT_MIN" >> $GITHUB_OUTPUT
echo "current_middle=$CURRENT_MIDDLE" >> $GITHUB_OUTPUT
- name: 🔎 Check if update needed
id: check
run: |
NEEDS_UPDATE=false
CHANGES=""
if [[ "${{ steps.versions.outputs.latest }}" != "${{ steps.versions.outputs.current_max }}" ]]; then
echo "📌 Max version changed: ${{ steps.versions.outputs.current_max }} → ${{ steps.versions.outputs.latest }}"
NEEDS_UPDATE=true
CHANGES="${CHANGES}- Max: ${{ steps.versions.outputs.current_max }} → ${{ steps.versions.outputs.latest }}\n"
fi
if [[ "${{ steps.versions.outputs.oldest }}" != "${{ steps.versions.outputs.current_min }}" ]]; then
echo "📌 Min version changed: ${{ steps.versions.outputs.current_min }} → ${{ steps.versions.outputs.oldest }}"
NEEDS_UPDATE=true
CHANGES="${CHANGES}- Min: ${{ steps.versions.outputs.current_min }} → ${{ steps.versions.outputs.oldest }}\n"
fi
if [[ "${{ steps.versions.outputs.middle }}" != "${{ steps.versions.outputs.current_middle }}" ]]; then
echo "📌 Middle version changed: ${{ steps.versions.outputs.current_middle }} → ${{ steps.versions.outputs.middle }}"
NEEDS_UPDATE=true
CHANGES="${CHANGES}- Middle: ${{ steps.versions.outputs.current_middle }} → ${{ steps.versions.outputs.middle }}\n"
fi
if [[ "$NEEDS_UPDATE" = "false" ]]; then
echo "✅ No updates needed - versions are current"
fi
echo "needs_update=$NEEDS_UPDATE" >> $GITHUB_OUTPUT
echo "changes<<EOF" >> $GITHUB_OUTPUT
echo -e "$CHANGES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: 📝 Update package.json
if: steps.check.outputs.needs_update == 'true'
run: |
echo "Updating package.json..."
jq --arg min "${{ steps.versions.outputs.oldest }}" \
--arg max "${{ steps.versions.outputs.latest }}" \
'.supportedVersions["vscode-min"] = $min | .supportedVersions["vscode-max"] = $max' \
packages/extester/package.json > tmp.json
mv tmp.json packages/extester/package.json
# Verify the update
NEW_MIN=$(jq -r '.supportedVersions["vscode-min"]' packages/extester/package.json)
NEW_MAX=$(jq -r '.supportedVersions["vscode-max"]' packages/extester/package.json)
if [[ "$NEW_MIN" != "${{ steps.versions.outputs.oldest }}" ]] || \
[[ "$NEW_MAX" != "${{ steps.versions.outputs.latest }}" ]]; then
echo "❌ Failed to update package.json correctly"
exit 1
fi
echo "✅ package.json updated successfully"
- name: 📝 Update CI workflow matrix
if: steps.check.outputs.needs_update == 'true'
run: |
echo "Updating .github/workflows/main.yml..."
# Update the version matrix in main.yml
sed -i "s/version: \[min, [0-9.]\+, max\]/version: [min, ${{ steps.versions.outputs.middle }}, max]/" \
.github/workflows/main.yml
# Verify the update
UPDATED_MIDDLE=$(grep 'version: \[min,' .github/workflows/main.yml | sed -E 's/.*version: \[min, ([^,]+),.*/\1/' | tr -d ' ')
if [[ "$UPDATED_MIDDLE" != "${{ steps.versions.outputs.middle }}" ]]; then
echo "❌ Failed to update main.yml correctly"
echo "Expected: ${{ steps.versions.outputs.middle }}"
echo "Got: $UPDATED_MIDDLE"
exit 1
fi
echo "✅ main.yml updated successfully"
- name: 🔀 Create Pull Request
if: steps.check.outputs.needs_update == 'true'
id: create_pr
uses: peter-evans/create-pull-request@v8.1.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: |
chore: update VS Code version window to latest 3 releases
- vscode-min: ${{ steps.versions.outputs.current_min }} → ${{ steps.versions.outputs.oldest }}
- vscode-middle: ${{ steps.versions.outputs.current_middle }} → ${{ steps.versions.outputs.middle }}
- vscode-max: ${{ steps.versions.outputs.current_max }} → ${{ steps.versions.outputs.latest }}
branch: auto-update-vscode-versions
delete-branch: true
title: "Update VS Code version window (${{ steps.versions.outputs.oldest }} - ${{ steps.versions.outputs.latest }})"
body: |
## 🔄 VS Code Version Window Update
This PR updates the supported VS Code version window to the latest 3 stable releases.
### 📊 Version Changes
| Position | Before | After | Status |
|----------|--------|-------|--------|
| **Min (Oldest)** | `${{ steps.versions.outputs.current_min }}` | `${{ steps.versions.outputs.oldest }}` | ${{ steps.versions.outputs.current_min != steps.versions.outputs.oldest && '✅ Updated' || '➖ No change' }} |
| **Middle** | `${{ steps.versions.outputs.current_middle }}` | `${{ steps.versions.outputs.middle }}` | ${{ steps.versions.outputs.current_middle != steps.versions.outputs.middle && '✅ Updated' || '➖ No change' }} |
| **Max (Latest)** | `${{ steps.versions.outputs.current_max }}` | `${{ steps.versions.outputs.latest }}` | ${{ steps.versions.outputs.current_max != steps.versions.outputs.latest && '✅ Updated' || '➖ No change' }} |
### 📝 Files Modified
- ✅ [`packages/extester/package.json`](https://github.com/${{ github.repository }}/blob/${{ github.head_ref || github.ref_name }}/packages/extester/package.json) - Updated `vscode-min` and `vscode-max`
- ✅ [`.github/workflows/main.yml`](https://github.com/${{ github.repository }}/blob/${{ github.head_ref || github.ref_name }}/.github/workflows/main.yml) - Updated CI test matrix middle version
### 🧪 Testing
CI will automatically test against all 3 versions:
- ✅ Min: `${{ steps.versions.outputs.oldest }}`
- ✅ Middle: `${{ steps.versions.outputs.middle }}`
- ✅ Max: `${{ steps.versions.outputs.latest }}`
### ✅ Review Checklist
- [ ] All CI tests pass for all 3 versions
- [ ] No breaking changes detected in test results
- [ ] Page objects still work across all versions
- [ ] Ready to merge and release
### 📦 Next Steps After Merge
1. ✅ Verify all tests passed
2. 🚀 Trigger release workflow if needed
3. 📚 Update documentation if there are breaking changes
---
🤖 *This PR was automatically created by the [version update workflow](https://github.com/${{ github.repository }}/actions/workflows/update-vscode-versions.yml)*
labels: |
automation
maintenance
dependencies
- name: 💬 Comment on PR with test instructions
if: steps.check.outputs.needs_update == 'true' && steps.create_pr.outputs.pull-request-number
uses: actions/github-script@v8
with:
script: |
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: ${{ steps.create_pr.outputs.pull-request-number }},
body: `## 🧪 Testing Instructions
The CI pipeline will automatically test all 3 versions. Monitor the test results in the checks below.
### 🔍 What to Review
- ✅ Check that all CI tests pass
- ⚠️ Look for any failures or warnings in test output
- 📸 Review screenshots if any tests fail
- 🐛 Check for breaking changes in page objects
### 🛠️ Manual Testing (Optional)
If you want to test locally before merging:
\`\`\`bash
# Test with min version
CODE_VERSION=min npm test
# Test with middle version
CODE_VERSION=${{ steps.versions.outputs.middle }} npm test
# Test with max version
CODE_VERSION=max npm test
\`\`\`
### ✅ Ready to Merge?
If all tests pass and there are no breaking changes, this PR is ready to merge! 🎉
After merging, consider:
1. Creating a new release with the updated version support
2. Updating documentation if needed
3. Announcing the new supported versions`
})
- name: ⚠️ Notify on failure
if: failure()
uses: actions/github-script@v8
with:
script: |
github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: '⚠️ VS Code version update workflow failed',
body: `## ⚠️ Automated Version Update Failed
The automated VS Code version update workflow encountered an error.
### 📋 Details
- **Workflow Run**: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
- **Triggered**: ${{ github.event_name }}
- **Branch**: ${{ github.ref_name }}
### 🔧 Action Required
Please investigate the workflow failure and update versions manually if needed.
### 📝 Manual Update Steps
1. Check the latest 3 VS Code stable versions at https://code.visualstudio.com/updates
2. Update \`packages/extester/package.json\`:
- \`vscode-min\`: oldest of the 3 versions
- \`vscode-max\`: newest of the 3 versions
3. Update \`.github/workflows/main.yml\`:
- Update the middle version in the test matrix
4. Run tests and create a release
---
🤖 *This issue was automatically created by the version update workflow*`,
labels: ['automation', 'bug', 'maintenance']
})
# Made with Bob