Skip to content

Commit 1253bce

Browse files
committed
ci: merge all the test case
1 parent db2c449 commit 1253bce

2 files changed

Lines changed: 70 additions & 176 deletions

File tree

.github/workflows/e2e-autotest.yml

Lines changed: 70 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: E2E AutoTest
22

33
on:
4+
pull_request:
5+
branches:
6+
- main
47
schedule:
58
# Every weekday (Mon–Fri) at 13:00 Shanghai time (05:00 UTC)
69
- cron: '0 5 * * 1-5'
@@ -22,28 +25,69 @@ on:
2225
default: true
2326
type: boolean
2427

28+
permissions:
29+
contents: read
30+
2531
jobs:
26-
# ── Job 1: Discover test plans ──────────────────────────
32+
# ── Job 1a: Build vscode-java-pack VSIX from the PR branch ───────
33+
build-pack:
34+
if: ${{ github.event_name == 'pull_request' }}
35+
runs-on: ubuntu-latest
36+
steps:
37+
- name: Checkout
38+
uses: actions/checkout@v4
39+
40+
- name: Setup Node.js
41+
uses: actions/setup-node@v4
42+
with:
43+
node-version: '22'
44+
cache: npm
45+
46+
- name: Install dependencies
47+
run: npm ci
48+
49+
- name: Build extension
50+
run: npm run build
51+
52+
- name: Package PR VSIX
53+
run: npx @vscode/vsce@latest package -o vscode-java-pack-pr.vsix
54+
55+
- name: Upload PR VSIX
56+
uses: actions/upload-artifact@v4
57+
with:
58+
name: pr-vsix
59+
path: vscode-java-pack-pr.vsix
60+
retention-days: 1
61+
62+
# ── Job 1b: Discover test plans ──────────────────────────
2763
discover:
28-
if: ${{ inputs.test_plan == '' }}
2964
runs-on: ubuntu-latest
3065
outputs:
3166
matrix: ${{ steps.scan.outputs.matrix }}
3267
steps:
3368
- name: Checkout
3469
uses: actions/checkout@v4
3570

36-
- name: Scan test plans
71+
- name: Resolve test plan matrix
3772
id: scan
73+
shell: bash
3874
run: |
39-
plans=$(ls test-plans/*.yaml | xargs -I{} basename {} .yaml | grep -v java-fresh-import | jq -R . | jq -sc .)
40-
echo "matrix=$plans" >> "$GITHUB_OUTPUT"
41-
echo "Found plans: $plans"
75+
requested="${{ inputs.test_plan }}"
76+
if [ -n "$requested" ]; then
77+
# Strip optional .yaml suffix and emit a single-entry matrix
78+
plan="${requested%.yaml}"
79+
matrix=$(printf '%s' "$plan" | jq -R . | jq -sc .)
80+
else
81+
matrix=$(ls test-plans/*.yaml | xargs -I{} basename {} .yaml | grep -v java-fresh-import | jq -R . | jq -sc .)
82+
fi
83+
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
84+
echo "Found plans: $matrix"
4285
4386
# ── Job 2: Run each test plan in parallel ───────────────
4487
e2e-test:
45-
if: ${{ inputs.test_plan == '' }}
46-
needs: discover
88+
needs: [discover, build-pack]
89+
# build-pack is skipped on schedule/workflow_dispatch — only require it on PRs
90+
if: ${{ always() && needs.discover.result == 'success' && (github.event_name != 'pull_request' || needs.build-pack.result == 'success') }}
4791
runs-on: windows-latest
4892
timeout-minutes: 30
4993
strategy:
@@ -88,8 +132,15 @@ jobs:
88132
- name: Install autotest CLI
89133
run: npm install -g @vscjava/vscode-autotest
90134

91-
- name: Download VSIX files
92-
if: ${{ inputs.vsix_urls != '' }}
135+
- name: Download PR VSIX (vscode-java-pack from branch)
136+
if: ${{ github.event_name == 'pull_request' }}
137+
uses: actions/download-artifact@v4
138+
with:
139+
name: pr-vsix
140+
path: vsix
141+
142+
- name: Download VSIX files (manual trigger)
143+
if: ${{ github.event_name == 'workflow_dispatch' && inputs.vsix_urls != '' }}
93144
shell: pwsh
94145
run: |
95146
New-Item -ItemType Directory -Path vsix -Force | Out-Null
@@ -148,136 +199,30 @@ jobs:
148199
$vsixFiles = (Get-ChildItem vsix -Filter "*.vsix" | ForEach-Object { $_.FullName }) -join ","
149200
if ($vsixFiles) { $autotestArgs += @("--vsix", $vsixFiles) }
150201
}
151-
if ("${{ inputs.pre_release }}" -ne "false") { $autotestArgs += "--pre-release" }
152-
Write-Host "Running: autotest $($autotestArgs -join ' ')"
153-
& autotest @autotestArgs
154-
155-
- name: Upload results
156-
if: always()
157-
uses: actions/upload-artifact@v4
158-
with:
159-
name: results-${{ matrix.plan }}
160-
path: test-results/
161-
retention-days: 30
162-
163-
# ── Job 2b: Run a single test plan (when specified) ─────
164-
e2e-single:
165-
if: ${{ inputs.test_plan != '' }}
166-
runs-on: windows-latest
167-
timeout-minutes: 30
168-
169-
steps:
170-
- name: Checkout
171-
uses: actions/checkout@v4
172-
173-
- name: Clone vscode-java
174-
run: git clone --depth 1 https://github.com/redhat-developer/vscode-java.git ../vscode-java
175-
176-
- name: Clone eclipse.jdt.ls
177-
run: git clone --depth 1 https://github.com/eclipse-jdtls/eclipse.jdt.ls.git ../eclipse.jdt.ls
178-
179-
- name: Setup Node.js
180-
uses: actions/setup-node@v4
181-
with:
182-
node-version: 20
183-
184-
- name: Setup Java 25
185-
if: contains(inputs.test_plan, 'java25')
186-
uses: actions/setup-java@v4
187-
with:
188-
distribution: temurin
189-
java-version: 25-ea
190-
191-
- name: Create JDK 25 path
192-
if: contains(inputs.test_plan, 'java25')
193-
shell: pwsh
194-
run: |
195-
New-Item -ItemType Junction -Path "C:\Program Files\Java\jdk-25" -Target $env:JAVA_HOME
196-
197-
- name: Setup Java 21
198-
uses: actions/setup-java@v4
199-
with:
200-
distribution: temurin
201-
java-version: 21
202-
203-
- name: Install autotest CLI
204-
run: npm install -g @vscjava/vscode-autotest
205-
206-
- name: Download VSIX files
207-
if: ${{ inputs.vsix_urls != '' }}
208-
shell: pwsh
209-
run: |
210-
New-Item -ItemType Directory -Path vsix -Force | Out-Null
211-
$urls = "${{ inputs.vsix_urls }}" -split "," | ForEach-Object { $_.Trim() } | Where-Object { $_ -ne "" }
212-
213-
# Map runner OS/arch to vscode-java platform identifiers
214-
$platformMap = @{ "Windows" = "win32"; "Linux" = "linux"; "macOS" = "darwin" }
215-
$archMap = @{ "X64" = "x64"; "ARM64" = "arm64" }
216-
$platform = $platformMap["${{ runner.os }}"]
217-
$arch = $archMap["${{ runner.arch }}"]
218-
$platformId = "$platform-$arch"
219-
Write-Host "Runner platform: $platformId (${{ runner.os }}/${{ runner.arch }})"
220-
221-
$resolvedUrls = @()
222-
foreach ($url in $urls) {
223-
if ($url -match '^https://github\.com/([^/]+)/([^/]+)/releases/tag/(.+)$') {
224-
$owner = $Matches[1]; $repo = $Matches[2]; $tag = $Matches[3]
225-
Write-Host "Resolving GitHub release: $owner/$repo@$tag for platform $platformId"
226-
$apiUrl = "https://api.github.com/repos/$owner/$repo/releases/tags/$tag"
227-
$release = Invoke-RestMethod -Uri $apiUrl -Headers @{ Accept = "application/vnd.github.v3+json" } -UseBasicParsing
228-
$platformAsset = $release.assets | Where-Object { $_.name -like "*-$platformId-*" -and $_.name -like "*.vsix" } | Select-Object -First 1
229-
if ($platformAsset) {
230-
Write-Host " Found platform-specific VSIX: $($platformAsset.name)"
231-
$resolvedUrls += $platformAsset.browser_download_url
232-
} else {
233-
$universalAsset = $release.assets | Where-Object { $_.name -notmatch '-(darwin|linux|win32)-' -and $_.name -like "*.vsix" } | Select-Object -First 1
234-
if ($universalAsset) {
235-
Write-Host " No platform-specific VSIX found, using universal: $($universalAsset.name)"
236-
$resolvedUrls += $universalAsset.browser_download_url
237-
} else {
238-
Write-Host "::warning::No matching VSIX found in release $owner/$repo@$tag for platform $platformId"
239-
}
240-
}
241-
} else {
242-
$resolvedUrls += $url
243-
}
244-
}
245202
246-
foreach ($url in $resolvedUrls) {
247-
$fileName = [System.IO.Path]::GetFileName(($url -split '\?')[0])
248-
Write-Host "Downloading: $url → vsix/$fileName"
249-
Invoke-WebRequest -Uri $url -OutFile "vsix/$fileName" -UseBasicParsing
203+
# PRs always test the branch-built VSIX against stable marketplace deps (no LLM, no pre-release).
204+
# Scheduled & manual runs default to --pre-release unless explicitly disabled.
205+
$isPR = "${{ github.event_name }}" -eq "pull_request"
206+
if ($isPR) {
207+
$autotestArgs += "--no-llm"
208+
} elseif ("${{ inputs.pre_release }}" -ne "false") {
209+
$autotestArgs += "--pre-release"
250210
}
251-
Write-Host "Downloaded VSIX files:"
252-
Get-ChildItem vsix -Filter "*.vsix" | ForEach-Object { Write-Host " $($_.Name) ($([math]::Round($_.Length/1MB, 1)) MB)" }
253211
254-
- name: Run ${{ inputs.test_plan }}
255-
shell: pwsh
256-
env:
257-
AZURE_OPENAI_ENDPOINT: ${{ secrets.AZURE_OPENAI_ENDPOINT }}
258-
AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }}
259-
AZURE_OPENAI_DEPLOYMENT: ${{ secrets.AZURE_OPENAI_DEPLOYMENT }}
260-
run: |
261-
$autotestArgs = @("run", "test-plans/${{ inputs.test_plan }}")
262-
if (Test-Path vsix) {
263-
$vsixFiles = (Get-ChildItem vsix -Filter "*.vsix" | ForEach-Object { $_.FullName }) -join ","
264-
if ($vsixFiles) { $autotestArgs += @("--vsix", $vsixFiles) }
265-
}
266-
if ("${{ inputs.pre_release }}" -ne "false") { $autotestArgs += "--pre-release" }
267212
Write-Host "Running: autotest $($autotestArgs -join ' ')"
268213
& autotest @autotestArgs
269214
270215
- name: Upload results
271216
if: always()
272217
uses: actions/upload-artifact@v4
273218
with:
274-
name: e2e-test-results
219+
name: results-${{ matrix.plan }}
275220
path: test-results/
276221
retention-days: 30
277222

278223
# ── Job 3: Aggregate analysis ───────────────────────────
279224
analyze:
280-
if: ${{ always() && inputs.test_plan == '' }}
225+
if: ${{ always() && needs.e2e-test.result != 'skipped' && github.event_name != 'pull_request' && inputs.test_plan == '' }}
281226
needs: e2e-test
282227
runs-on: ubuntu-latest
283228

.github/workflows/pr-ui-autotest.yml

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)