forked from konveyor/editor-extensions
-
Notifications
You must be signed in to change notification settings - Fork 2
503 lines (434 loc) · 15.5 KB
/
ci-repo.yml
File metadata and controls
503 lines (434 loc) · 15.5 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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
name: CI (repo level)
on:
push:
branches:
- "main"
- "release-*"
tags:
- "v*"
pull_request:
paths-ignore:
- "docs/**"
branches:
- "main"
- "release-*"
workflow_dispatch:
workflow_call:
concurrency:
group: ci-repo-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: true
# https://typicode.github.io/husky/how-to.html#ci-server-and-docker
env:
HUSKY: 0
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "npm"
- name: Install workspace dependencies
run: |
npm ci
- name: Lint sources
run: |
npm run lint
build:
needs: lint
name: Build (${{ matrix.arch }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
arch: linux
- os: macos-latest
arch: macos
- os: windows-latest
arch: windows
max-parallel: 3
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "npm"
- name: Install workspace dependencies
run: |
npm ci
- name: Build
run: |
npm run build
test:
name: Test (${{ matrix.arch }})
runs-on: ${{ matrix.os }}
needs: build
strategy:
matrix:
include:
- os: ubuntu-latest
arch: linux
- os: macos-latest
arch: macos
- os: windows-latest
arch: windows
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "npm"
- name: Install workspace dependencies
run: |
npm ci
# Run tests on Linux
- name: Run tests (Linux)
if: matrix.arch == 'linux'
run: xvfb-run -a npm test
# Run tests on macOS
- name: Run tests (macOS)
if: matrix.arch == 'macos'
run: npm test
# Run tests on Windows
- name: Run tests (Windows)
if: matrix.arch == 'windows'
shell: cmd
run: npm test
package:
name: Package (${{ matrix.arch }})
runs-on: ${{ matrix.os }}
needs: test
outputs:
is_prerelease: ${{ steps.check_prerelease.outputs.is_prerelease }}
strategy:
matrix:
include:
- os: ubuntu-latest
arch: linux
max-parallel: 1
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "npm"
- name: Install dependencies and build
run: |
npm ci
npm run build
- name: Check if pre-release and collect runtime assets
id: check_prerelease
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
# Extract minor version to check if pre-release
TAG="${{ github.ref_name }}"
VERSION="${TAG#v}"
MINOR=$(echo "$VERSION" | cut -d'.' -f2)
if [ $((MINOR % 2)) -eq 1 ]; then
echo "Minor version $MINOR is odd - this is a pre-release"
echo "is_prerelease=true" >> $GITHUB_OUTPUT
# Pre-release: use main branch artifacts
npm run collect-assets -- --use-workflow-artifacts --branch=main
else
echo "Minor version $MINOR is even - this is a stable release"
echo "is_prerelease=false" >> $GITHUB_OUTPUT
# Stable release: use release artifacts
npm run collect-assets -- --use-release
fi
else
# Development build: use workflow artifacts from current branch
# We should never make it to publish if this is a development build
echo "is_prerelease=development" >> $GITHUB_OUTPUT
npm run collect-assets -- --use-workflow-artifacts --branch=main
fi
- name: Set version for build
id: set_version
run: |
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
# Tagged release: use tag version
VERSION="${{ github.ref_name }}"
VERSION="${VERSION#v}" # Strip 'v' prefix
echo "Setting release version: $VERSION"
npm version "$VERSION" --workspaces --include-workspace-root --no-git-tag-version --allow-same-version
else
# Development build: add timestamp and SHA
CURRENT_VERSION=$(npm pkg get version | tr -d '"')
TIMESTAMP=$(date +%Y%m%d%H%M%S)
SHA=$(git rev-parse --short HEAD)
VERSION="${CURRENT_VERSION}-dev.${TIMESTAMP}.${SHA}"
echo "Setting development version: $VERSION"
npm version "$VERSION" --workspaces --include-workspace-root --no-git-tag-version
fi
# Export version to be used in later steps
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "Build version: ${VERSION}"
- name: Build dist
run: npm run dist
- name: Package core extension
run: |
if [ "${{ steps.check_prerelease.outputs.is_prerelease }}" = "true" ]; then
npm run package-core -- --pre-release
else
npm run package-core
fi
- name: Package Java extension
run: |
if [ "${{ steps.check_prerelease.outputs.is_prerelease }}" = "true" ]; then
npm run package-java -- --pre-release
else
npm run package-java
fi
- name: Package JavaScript extension
run: |
if [ "${{ steps.check_prerelease.outputs.is_prerelease }}" = "true" ]; then
npm run package-javascript -- --pre-release
else
npm run package-javascript
fi
- name: Package Go extension
run: |
if [ "${{ steps.check_prerelease.outputs.is_prerelease }}" = "true" ]; then
npm run package-go -- --pre-release
else
npm run package-go
fi
- name: Upload VSIX artifacts
uses: actions/upload-artifact@v4
with:
name: vsix-artifacts
path: ./dist/*.vsix
test-e2e:
name: Test E2E
runs-on: ubuntu-latest
needs: package
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "npm"
- name: Install vscode dependencies
run: sudo apt-get update && sudo apt-get install -y wget
- uses: actions/setup-java@v4
with:
distribution: "oracle"
java-version: "17"
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.23"
- name: Download and Install VSCode
run: |
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg
echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" |sudo tee /etc/apt/sources.list.d/vscode.list > /dev/null
rm -f packages.microsoft.gpg
sudo apt install apt-transport-https -y
sudo apt update
sudo apt install code -y
- name: Set up virtual X11
run: |
sudo apt-get install -y \
xvfb \
x11-xserver-utils \
dbus-x11 \
xfonts-100dpi \
xfonts-75dpi \
libxrender1 \
libxext6 \
libx11-6 \
xfonts-base \
nickle cairo-5c \
xorg-docs-core
- name: Set DISPLAY environment variable
run: |
Xvfb :99 -screen 0 1920x1080x24 &
echo "DISPLAY=:99" >> "$GITHUB_ENV"
- name: Start Dbus
run: |
dbus-launch --exit-with-session &
sudo service dbus start
export XDG_RUNTIME_DIR=/run/user/$(id -u)
sudo chmod 700 $XDG_RUNTIME_DIR
sudo chown $(id -un):$(id -gn) $XDG_RUNTIME_DIR
export DBUS_SESSION_BUS_ADDRESS=unix:path=$XDG_RUNTIME_DIR/bus
dbus-daemon --session --address=$DBUS_SESSION_BUS_ADDRESS --nofork --nopidfile --syslog-only &
mkdir ~/.vscode && echo '{ "disable-hardware-acceleration": true }' > ~/.vscode/argv.json
- name: Verify Installation
run: code --version
- name: Ensure no VSCode instances are running
run: |
pkill -f code || true
- name: Install dependencies
run: npm ci
working-directory: ./tests
- name: Download VSIX artifacts
uses: actions/download-artifact@v4
with:
name: vsix-artifacts
path: ./dist
- name: Set VSIX paths
id: set_vsix_paths
run: |
# Read extension names from package.json files
CORE_NAME=$(node -p "require('./vscode/core/package.json').name")
JAVA_NAME=$(node -p "require('./vscode/java/package.json').name")
JS_NAME=$(node -p "require('./vscode/javascript/package.json').name")
GO_NAME=$(node -p "require('./vscode/go/package.json').name")
# Find the actual VSIX files using glob patterns
CORE_VSIX=$(ls ./dist/${CORE_NAME}-*.vsix | head -n 1)
JAVA_VSIX=$(ls ./dist/${JAVA_NAME}-*.vsix | head -n 1)
JS_VSIX=$(ls ./dist/${JS_NAME}-*.vsix | head -n 1)
GO_VSIX=$(ls ./dist/${GO_NAME}-*.vsix | head -n 1)
# Verify files exist
if [ ! -f "$CORE_VSIX" ]; then
echo "Error: Core VSIX not found for ${CORE_NAME}"
ls -la ./dist/
exit 1
fi
if [ ! -f "$JAVA_VSIX" ]; then
echo "Error: Java VSIX not found for ${JAVA_NAME}"
ls -la ./dist/
exit 1
fi
if [ ! -f "$JS_VSIX" ]; then
echo "Error: JavaScript VSIX not found for ${JS_NAME}"
ls -la ./dist/
exit 1
fi
if [ ! -f "$GO_VSIX" ]; then
echo "Error: Go VSIX not found for ${GO_NAME}"
ls -la ./dist/
exit 1
fi
# Output to GitHub Actions
echo "core_vsix=${CORE_VSIX}" >> $GITHUB_OUTPUT
echo "java_vsix=${JAVA_VSIX}" >> $GITHUB_OUTPUT
echo "javascript_vsix=${JS_VSIX}" >> $GITHUB_OUTPUT
echo "go_vsix=${GO_VSIX}" >> $GITHUB_OUTPUT
echo "VSIX files found:"
echo " Core: ${CORE_VSIX}"
echo " Java: ${JAVA_VSIX}"
echo " JavaScript: ${JS_VSIX}"
echo " Go: ${GO_VSIX}"
- name: Run e2e tests (Linux)
run: npx playwright test e2e/tests/base/configure-and-run-analysis.test.ts
working-directory: ./tests
env:
__TEST_EXTENSION_END_TO_END__: "true"
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
CORE_VSIX_FILE_PATH: ${{ github.workspace }}/${{ steps.set_vsix_paths.outputs.core_vsix }}
JAVA_VSIX_FILE_PATH: ${{ github.workspace }}/${{ steps.set_vsix_paths.outputs.java_vsix }}
# This is intentionally kept in a separate step to avoid passing in credentials
- name: Run e2e tests (Linux - Offline)
run: npx playwright test e2e/tests/agent_flow_coolstore.test.ts
working-directory: ./tests
env:
__TEST_EXTENSION_END_TO_END__: "true"
CORE_VSIX_FILE_PATH: ${{ github.workspace }}/${{ steps.set_vsix_paths.outputs.core_vsix }}
JAVA_VSIX_FILE_PATH: ${{ github.workspace }}/${{ steps.set_vsix_paths.outputs.java_vsix }}
OPENAI_API_KEY: <dummy> # this only exists to pass provider validation
- name: Collect test artifacts
if: always()
run: |
mkdir -p test-artifacts
if [ -d "test-data-dir" ]; then
cp -r test-data-dir test-artifacts/
fi
if [ -d "test-output" ]; then
cp -r test-output test-artifacts/
fi
# Collect extension logs from VSCode's log directory
if [ -d "test-data-dir/logs" ]; then
echo "Collecting extension logs..."
mkdir -p test-artifacts/extension-logs
cp -r test-data-dir/logs/* test-artifacts/extension-logs/
# List log files for debugging
echo "Extension log files found:"
find test-artifacts/extension-logs -type f -name "*.log" -ls || echo "No .log files found"
else
echo "Warning: test-data-dir/logs directory not found"
fi
working-directory: ./tests
- name: Upload test artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: e2e-test-artifacts
path: tests/test-artifacts/
retention-days: 7
publish:
name: Publish Development Build
runs-on: ubuntu-latest
needs: test-e2e
# Only publish development builds (not tagged releases)
if: ${{ ! (github.event_name == 'pull_request' && ! github.event.pull_request.merged) && ! startsWith(github.ref, 'refs/tags/v') }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download VSIX artifacts
uses: actions/download-artifact@v4
with:
name: vsix-artifacts
path: ./dist
- name: Deploy development builds
run: |
for vsix in ./dist/*.vsix; do
VSIX_NAME=$(basename "$vsix")
echo "Uploading $VSIX_NAME"
gh release upload development-builds "$vsix" --clobber
done
env:
GH_TOKEN: ${{ github.token }}
- name: Cleanup old development builds
run: |
# Keep last N builds per extension type
BUILDS_TO_KEEP=7
# Process each extension type
for ext in konveyor konveyor-java konveyor-javascript konveyor-go; do
echo "Processing ${ext}..."
# Match pattern: {ext}-{version} where version starts with a digit
# This handles "konveyor-0.4.0..." and "konveyor-java-0.4.0..." correctly
assets=$(gh release view -R ${{ github.repository }} development-builds --json assets | \
jq -r ".assets[].name | select(test(\"^${ext}-[0-9]\"))" | \
sort -r)
count=0
for asset in $assets; do
count=$((count + 1))
if [ "$count" -gt "$BUILDS_TO_KEEP" ]; then
echo "Deleting old asset: $asset"
gh release delete-asset -y -R ${{ github.repository }} development-builds "$asset"
else
echo "Keeping: $asset"
fi
done
done
env:
GH_TOKEN: ${{ github.token }}
release:
name: Create Release
needs: [test-e2e, package]
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: ./.github/workflows/release.yml
with:
tag_name: ${{ github.ref_name }}
prerelease: ${{ needs.package.outputs.is_prerelease == 'true' }}
vsix_artifact_name: "vsix-artifacts"
secrets: inherit