-
Notifications
You must be signed in to change notification settings - Fork 0
317 lines (266 loc) · 12.7 KB
/
dependency-update.yml
File metadata and controls
317 lines (266 loc) · 12.7 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
305
306
307
308
309
310
311
312
313
314
315
316
317
name: Dependency Update Check
on:
schedule:
- cron: '0 6 * * 1' # Every Monday at 06:00 UTC
workflow_dispatch:
inputs:
package:
description: 'Package to check (default: @lancedb/lancedb)'
required: false
default: '@lancedb/lancedb'
permissions:
contents: write
issues: write
pull-requests: write
jobs:
check-dependency-updates:
runs-on: ubuntu-latest
outputs:
lancedb-update: ${{ steps.lancedb.outputs.update-needed }}
lancedb-latest: ${{ steps.lancedb.outputs.latest }}
lancedb-current: ${{ steps.lancedb.outputs.current }}
opencode-plugin-update: ${{ steps.opencode-plugin.outputs.update-needed }}
opencode-plugin-latest: ${{ steps.opencode-plugin.outputs.latest }}
opencode-plugin-current: ${{ steps.opencode-plugin.outputs.current }}
opencode-sdk-update: ${{ steps.opencode-sdk.outputs.update-needed }}
opencode-sdk-latest: ${{ steps.opencode-sdk.outputs.latest }}
opencode-sdk-current: ${{ steps.opencode-sdk.outputs.current }}
any-update: ${{ steps.any-update.outputs.value }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Check LanceDB updates
id: lancedb
run: |
CURRENT=$(node -e "console.log(require('./package.json').dependencies['@lancedb/lancedb'])")
LATEST=$(npm view @lancedb/lancedb version)
CURRENT_CLEAN=$(echo "$CURRENT" | sed 's/[\^~]//')
echo "current=$CURRENT" >> $GITHUB_OUTPUT
echo "latest=$LATEST" >> $GITHUB_OUTPUT
echo "current-clean=$CURRENT_CLEAN" >> $GITHUB_OUTPUT
if [ "$CURRENT_CLEAN" != "$LATEST" ]; then
echo "update-needed=true" >> $GITHUB_OUTPUT
echo "::warning::LanceDB update available: $CURRENT -> $LATEST"
else
echo "update-needed=false" >> $GITHUB_OUTPUT
echo "::notice::LanceDB version is up to date: $CURRENT"
fi
- name: Check @opencode-ai/plugin updates
id: opencode-plugin
run: |
CURRENT=$(node -e "console.log(require('./package.json').dependencies['@opencode-ai/plugin'])")
LATEST=$(npm view @opencode-ai/plugin version)
echo "current=$CURRENT" >> $GITHUB_OUTPUT
echo "latest=$LATEST" >> $GITHUB_OUTPUT
if [ "$CURRENT" != "$LATEST" ]; then
echo "update-needed=true" >> $GITHUB_OUTPUT
echo "::warning::@opencode-ai/plugin update available: $CURRENT -> $LATEST"
else
echo "update-needed=false" >> $GITHUB_OUTPUT
echo "::notice::@opencode-ai/plugin version is up to date: $CURRENT"
fi
- name: Check @opencode-ai/sdk updates
id: opencode-sdk
run: |
CURRENT=$(node -e "console.log(require('./package.json').dependencies['@opencode-ai/sdk'])")
LATEST=$(npm view @opencode-ai/sdk version)
echo "current=$CURRENT" >> $GITHUB_OUTPUT
echo "latest=$LATEST" >> $GITHUB_OUTPUT
if [ "$CURRENT" != "$LATEST" ]; then
echo "update-needed=true" >> $GITHUB_OUTPUT
echo "::warning::@opencode-ai/sdk update available: $CURRENT -> $LATEST"
else
echo "update-needed=false" >> $GITHUB_OUTPUT
echo "::notice::@opencode-ai/sdk version is up to date: $CURRENT"
fi
- name: Determine if any updates needed
id: any-update
run: |
if [ "${{ steps.lancedb.outputs.update-needed }}" == "true" ] || \
[ "${{ steps.opencode-plugin.outputs.update-needed }}" == "true" ] || \
[ "${{ steps.opencode-sdk.outputs.update-needed }}" == "true" ]; then
echo "value=true" >> $GITHUB_OUTPUT
else
echo "value=false" >> $GITHUB_OUTPUT
fi
- name: Audit dependencies for vulnerabilities
run: npm audit --audit-level=moderate || true
- name: Check for outdated packages
run: npm outdated || true
test-with-latest-lancedb:
needs: check-dependency-updates
if: needs.check-dependency-updates.outputs.lancedb-update == 'true'
runs-on: ubuntu-latest
env:
COMPOSE_FILE: docker-compose.ci.yml
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get latest LanceDB version
run: |
echo "LATEST=${{ needs.check-dependency-updates.outputs.lancedb-latest }}" >> $GITHUB_ENV
- name: Update package.json
run: |
LATEST="${{ needs.check-dependency-updates.outputs.lancedb-latest }}"
sed -i "s/\"@lancedb\/lancedb\": \"[^\"]*\"/\"@lancedb\/lancedb\": \"^$LATEST\"/" package.json
cat package.json | grep lancedb
- name: Build and test with latest LanceDB
run: |
docker compose build --no-cache
docker compose up -d
docker compose exec -T app npm install
docker compose exec -T app npm run verify
- name: Report compatibility status
if: always()
run: |
echo "::notice::Completed compatibility test with LanceDB ${{ needs.check-dependency-updates.outputs.lancedb-latest }}"
- name: Tear down
if: always()
run: docker compose down -v --remove-orphans
test-with-latest-opencode-packages:
needs: check-dependency-updates
if: |
needs.check-dependency-updates.outputs.opencode-plugin-update == 'true' ||
needs.check-dependency-updates.outputs.opencode-sdk-update == 'true'
runs-on: ubuntu-latest
env:
COMPOSE_FILE: docker-compose.ci.yml
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- name: Get latest opencode-ai package versions
run: |
echo "PLUGIN_LATEST=${{ needs.check-dependency-updates.outputs.opencode-plugin-latest }}" >> $GITHUB_ENV
echo "SDK_LATEST=${{ needs.check-dependency-updates.outputs.opencode-sdk-latest }}" >> $GITHUB_ENV
- name: Update @opencode-ai/plugin in package.json
if: needs.check-dependency-updates.outputs.opencode-plugin-update == 'true'
run: |
sed -i "s/\"@opencode-ai\/plugin\": \"[^\"]*\"/\"@opencode-ai\/plugin\": \"$PLUGIN_LATEST\"/" package.json
- name: Update @opencode-ai/sdk in package.json
if: needs.check-dependency-updates.outputs.opencode-sdk-update == 'true'
run: |
sed -i "s/\"@opencode-ai\/sdk\": \"[^\"]*\"/\"@opencode-ai\/sdk\": \"$SDK_LATEST\"/" package.json
- name: Show updated package.json dependencies
run: |
echo "Updated dependencies:"
grep -E '@opencode-ai/plugin|@opencode-ai/sdk|@lancedb/lancedb' package.json || true
- name: Build and test with latest opencode-ai packages
run: |
docker compose build --no-cache
docker compose up -d
docker compose exec -T app npm install
docker compose exec -T app npm run verify
- name: Report compatibility status
if: always()
run: |
echo "::notice::Completed compatibility test with @opencode-ai/plugin ${{ needs.check-dependency-updates.outputs.opencode-plugin-latest }} and @opencode-ai/sdk ${{ needs.check-dependency-updates.outputs.opencode-sdk-latest }}"
- name: Tear down
if: always()
run: docker compose down -v --remove-orphans
create-update-pr:
needs: [check-dependency-updates, test-with-latest-opencode-packages]
if: |
needs.check-dependency-updates.outputs.any-update == 'true' &&
needs.test-with-latest-opencode-packages.result == 'success'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Get latest versions
run: |
echo "PLUGIN_LATEST=${{ needs.check-dependency-updates.outputs.opencode-plugin-latest }}" >> $GITHUB_ENV
echo "SDK_LATEST=${{ needs.check-dependency-updates.outputs.opencode-sdk-latest }}" >> $GITHUB_ENV
echo "PLUGIN_CURRENT=${{ needs.check-dependency-updates.outputs.opencode-plugin-current }}" >> $GITHUB_ENV
echo "SDK_CURRENT=${{ needs.check-dependency-updates.outputs.opencode-sdk-current }}" >> $GITHUB_ENV
echo "LANCEDB_LATEST=${{ needs.check-dependency-updates.outputs.lancedb-latest }}" >> $GITHUB_ENV
echo "LANCEDB_CURRENT=${{ needs.check-dependency-updates.outputs.lancedb-current }}" >> $GITHUB_ENV
- name: Update @opencode-ai/plugin in package.json
if: needs.check-dependency-updates.outputs.opencode-plugin-update == 'true'
run: |
sed -i "s/\"@opencode-ai\/plugin\": \"[^\"]*\"/\"@opencode-ai\/plugin\": \"$PLUGIN_LATEST\"/" package.json
- name: Update @opencode-ai/sdk in package.json
if: needs.check-dependency-updates.outputs.opencode-sdk-update == 'true'
run: |
sed -i "s/\"@opencode-ai\/sdk\": \"[^\"]*\"/\"@opencode-ai\/sdk\": \"$SDK_LATEST\"/" package.json
- name: Show updated dependencies
run: |
echo "=== Updated dependencies ==="
grep -E '@opencode-ai/plugin|@opencode-ai/sdk|@lancedb/lancedb' package.json || true
- name: Run npm install to update lock file
run: npm install
- name: Create update branch
id: create-branch
run: |
BRANCH_NAME="deps/update-opencode-packages-$(date +%Y%m%d-%H%M%S)"
git checkout -b "$BRANCH_NAME"
echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT
- name: Commit changes
run: |
git add package.json package-lock.json
git commit -m "chore: update @opencode-ai/plugin and/or @opencode-ai/sdk dependencies"
- name: Push branch
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ steps.create-branch.outputs.branch-name }}
- name: Create Pull Request
uses: actions/github-script@v7
with:
script: |
const pluginCurrent = '${{ needs.check-dependency-updates.outputs.opencode-plugin-current }}';
const pluginLatest = '${{ needs.check-dependency-updates.outputs.opencode-plugin-latest }}';
const sdkCurrent = '${{ needs.check-dependency-updates.outputs.opencode-sdk-current }}';
const sdkLatest = '${{ needs.check-dependency-updates.outputs.opencode-sdk-latest }}';
const pluginUpdate = '${{ needs.check-dependency-updates.outputs.opencode-plugin-update }}' === 'true';
const sdkUpdate = '${{ needs.check-dependency-updates.outputs.opencode-sdk-update }}' === 'true';
let title = 'chore: update opencode-ai dependencies';
let body = '## Dependency Updates\n\n';
if (pluginUpdate) {
body += `- **@opencode-ai/plugin**: ${pluginCurrent} → ${pluginLatest}\n`;
}
if (sdkUpdate) {
body += `- **@opencode-ai/sdk**: ${sdkCurrent} → ${sdkLatest}\n`;
}
body += '\n### Verification\n';
body += '- [x] Compatibility tests passed in CI\n';
body += '- [x] `npm run verify` passed\n';
body += '\n### Testing\n';
body += 'Automated tests were run with the latest versions inside Docker to verify compatibility.\n';
// Check for existing PR
const prs = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
head: `${context.repo.owner}:${'${{ steps.create-branch.outputs.branch-name }}'}`
});
if (prs.data.length === 0) {
await github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: title,
body: body,
base: 'main',
head: '${{ steps.create-branch.outputs.branch-name }}'
});
console.log('PR created successfully');
} else {
console.log('PR already exists:', prs.data[0].html_url);
}