forked from github/copilot-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
374 lines (334 loc) · 15 KB
/
Copy pathjava-sdk-tests.yml
File metadata and controls
374 lines (334 loc) · 15 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
name: "Java SDK Tests"
on:
push:
branches:
- main
paths:
- "java/**"
- "test/**"
- ".github/workflows/java-sdk-tests.yml"
- ".github/actions/setup-copilot/**"
- ".github/actions/java-test-report/**"
workflow_dispatch:
workflow_call:
permissions:
contents: read
jobs:
java-sdk-inprocess:
name: "Java SDK InProcess Tests (${{ matrix.classifier }})"
if: github.event.repository.fork == false
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
classifier: linux-x64
- os: windows-latest
classifier: win32-x64
- os: macos-26
classifier: darwin-arm64
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: ./java
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5
with:
java-version: "25"
distribution: "microsoft"
cache: "maven"
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with:
node-version: 22
- name: Validate native host
run: node copilot-native/scripts/validate-native-host.mjs ${{ matrix.classifier }}
- name: Run Java SDK tests (InProcess)
env:
CI: "true"
run: mvn clean verify -Pinprocess
- name: Generate Test Report Summary
if: always()
uses: ./.github/actions/java-test-report
with:
title: "Copilot Java SDK :: Test Results InProcess"
- name: Upload test results on failure
if: failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: java-test-results-inprocess-${{ matrix.classifier }}
path: |
java/sdk/target/surefire-reports/
java/sdk/target/surefire-reports-isolated/
java/sdk/target/failsafe-reports/
retention-days: 7
java-native-publication-windows:
name: "Java Native Publication Input (win32-x64)"
if: github.event.repository.fork == false
runs-on: windows-latest
permissions:
contents: read
outputs:
source_sha: ${{ steps.build.outputs.source_sha }}
version: ${{ steps.build.outputs.version }}
defaults:
run:
shell: pwsh
working-directory: ./java
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5
with:
java-version: "25"
distribution: "microsoft"
cache: "maven"
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with:
node-version: 22
- name: Build and validate win32-x64 classifier
id: build
run: |
node copilot-native/scripts/validate-native-host.mjs win32-x64
mvn -B -pl copilot-native package -DskipTests
$version = mvn help:evaluate "-Dexpression=project.version" -q "-DforceStdout"
$jar = "copilot-native/target/copilot-sdk-java-runtime-$version-win32-x64.jar"
$primaryJar = "copilot-native/target/copilot-sdk-java-runtime-$version.jar"
if (-not (Test-Path -LiteralPath $jar -PathType Leaf)) {
throw "Expected Windows classifier was not produced: $jar"
}
node copilot-native/scripts/validate-native-artifact.mjs classifier win32-x64 $jar ([IO.Path]::GetFileName($jar)) ..
node copilot-native/scripts/validate-native-artifact.mjs placeholder $primaryJar
$manifest = "copilot-native/target/win32-x64-$version.sha256"
$hash = (Get-FileHash -Algorithm SHA256 -LiteralPath $jar).Hash.ToLowerInvariant()
"$hash $([IO.Path]::GetFileName($jar))" | Set-Content -NoNewline -Encoding ascii $manifest
node copilot-native/scripts/validate-native-artifact.mjs checksum $jar $manifest ([IO.Path]::GetFileName($jar))
echo "source_sha=$(git rev-parse HEAD)" >> $env:GITHUB_OUTPUT
echo "version=$version" >> $env:GITHUB_OUTPUT
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: java-native-publication-win32-x64-${{ github.run_id }}-${{ github.run_attempt }}
path: |
java/copilot-native/target/copilot-sdk-java-runtime-${{ steps.build.outputs.version }}-win32-x64.jar
java/copilot-native/target/win32-x64-${{ steps.build.outputs.version }}.sha256
if-no-files-found: error
retention-days: 1
java-native-publication-darwin:
name: "Java Native Publication Input (darwin-arm64)"
if: github.event.repository.fork == false
runs-on: macos-26
permissions:
contents: read
outputs:
source_sha: ${{ steps.build.outputs.source_sha }}
version: ${{ steps.build.outputs.version }}
defaults:
run:
shell: bash
working-directory: ./java
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5
with:
java-version: "25"
distribution: "microsoft"
cache: "maven"
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with:
node-version: 22
- name: Build and validate darwin-arm64 classifier
id: build
run: |
set -euo pipefail
node copilot-native/scripts/validate-native-host.mjs darwin-arm64
mvn -B -pl copilot-native package -DskipTests
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
JAR="copilot-native/target/copilot-sdk-java-runtime-$VERSION-darwin-arm64.jar"
PRIMARY_JAR="copilot-native/target/copilot-sdk-java-runtime-$VERSION.jar"
test -f "$JAR"
node copilot-native/scripts/validate-native-artifact.mjs \
classifier darwin-arm64 "$JAR" "$(basename "$JAR")" ..
node copilot-native/scripts/validate-native-artifact.mjs placeholder "$PRIMARY_JAR"
MANIFEST="copilot-native/target/darwin-arm64-$VERSION.sha256"
HASH=$(shasum -a 256 "$JAR" | cut -d ' ' -f 1)
printf '%s %s' "$HASH" "$(basename "$JAR")" > "$MANIFEST"
node copilot-native/scripts/validate-native-artifact.mjs \
checksum "$JAR" "$MANIFEST" "$(basename "$JAR")"
echo "source_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: java-native-publication-darwin-arm64-${{ github.run_id }}-${{ github.run_attempt }}
path: |
java/copilot-native/target/copilot-sdk-java-runtime-${{ steps.build.outputs.version }}-darwin-arm64.jar
java/copilot-native/target/darwin-arm64-${{ steps.build.outputs.version }}.sha256
if-no-files-found: error
retention-days: 1
java-native-publication-assembly:
name: "Java Native Publication Assembly"
if: github.event.repository.fork == false
needs: [java-native-publication-windows, java-native-publication-darwin]
runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: ./java
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ github.sha }}
persist-credentials: false
- uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5
with:
java-version: "25"
distribution: "microsoft"
cache: "maven"
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with:
node-version: 22
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: java-native-publication-win32-x64-${{ github.run_id }}-${{ github.run_attempt }}
path: ${{ github.workspace }}/java/native-publication-input/windows
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: java-native-publication-darwin-arm64-${{ github.run_id }}-${{ github.run_attempt }}
path: ${{ github.workspace }}/java/native-publication-input/darwin
- name: Verify native inputs and deploy the complete local release
run: |
set -euo pipefail
test "$(git rev-parse HEAD)" = "${{ needs.java-native-publication-windows.outputs.source_sha }}"
test "$(git rev-parse HEAD)" = "${{ needs.java-native-publication-darwin.outputs.source_sha }}"
VERSION="${{ needs.java-native-publication-windows.outputs.version }}"
test "$VERSION" = "${{ needs.java-native-publication-darwin.outputs.version }}"
WINDOWS_DIRECTORY="$GITHUB_WORKSPACE/java/native-publication-input/windows"
DARWIN_DIRECTORY="$GITHUB_WORKSPACE/java/native-publication-input/darwin"
WINDOWS_JAR="$WINDOWS_DIRECTORY/copilot-sdk-java-runtime-$VERSION-win32-x64.jar"
WINDOWS_MANIFEST="$WINDOWS_DIRECTORY/win32-x64-$VERSION.sha256"
DARWIN_JAR="$DARWIN_DIRECTORY/copilot-sdk-java-runtime-$VERSION-darwin-arm64.jar"
DARWIN_MANIFEST="$DARWIN_DIRECTORY/darwin-arm64-$VERSION.sha256"
node copilot-native/scripts/validate-native-artifact.mjs \
checksum "$WINDOWS_JAR" "$WINDOWS_MANIFEST" "$(basename "$WINDOWS_JAR")"
node copilot-native/scripts/validate-native-artifact.mjs \
classifier win32-x64 "$WINDOWS_JAR" "$(basename "$WINDOWS_JAR")" ..
node copilot-native/scripts/validate-native-artifact.mjs \
checksum "$DARWIN_JAR" "$DARWIN_MANIFEST" "$(basename "$DARWIN_JAR")"
node copilot-native/scripts/validate-native-artifact.mjs \
classifier darwin-arm64 "$DARWIN_JAR" "$(basename "$DARWIN_JAR")" ..
export GNUPGHOME="$GITHUB_WORKSPACE/java/copilot-native/target/local-publication-gpg"
rm -rf "$GNUPGHOME"
mkdir -p "$GNUPGHOME"
chmod 700 "$GNUPGHOME"
gpg --batch --pinentry-mode loopback --passphrase '' \
--quick-generate-key 'Copilot SDK local validation <local-validation@example.invalid>' rsa2048 sign 1d
LOCAL_REPOSITORY="$GITHUB_WORKSPACE/java/copilot-native/target/local-publication-repository"
rm -rf "$LOCAL_REPOSITORY"
mvn -B -pl copilot-native deploy -Prelease -DskipTests \
-Dcopilot.native.libc=glibc \
-Dcopilot.native.test.local.publication=true \
"-Dcopilot.native.external.win32.classifier.path=$WINDOWS_JAR" \
"-Dcopilot.native.external.darwin.classifier.path=$DARWIN_JAR" \
"-Dmaven.repo.local=$LOCAL_REPOSITORY"
node copilot-native/scripts/validate-local-publication.mjs \
"$LOCAL_REPOSITORY" copilot-sdk-java-runtime "$VERSION" .. --signatures
java-sdk:
name: "Java SDK Tests (JDK ${{ matrix.test-jdk }})"
if: github.event.repository.fork == false
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test-jdk: ["25", "17"]
defaults:
run:
shell: bash
working-directory: ./java
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5
with:
java-version: "25"
distribution: "microsoft"
cache: "maven"
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with:
node-version: 22
- name: Test documentation version updater
if: matrix.test-jdk == '25'
run: ./scripts/test-update-documentation-versions.sh
- name: Build SDK and set up test harness
run: mvn test-compile jar:jar
- name: Verify Javadoc generation
if: matrix.test-jdk == '25'
run: mvn javadoc:javadoc -q
- name: Verify CLI works
run: node ../nodejs/node_modules/@github/copilot/npm-loader.js --version
- name: Run spotless check
if: matrix.test-jdk == '25'
run: |
max_attempts=3
for ((attempt=1; attempt<=max_attempts; attempt++)); do
if mvn spotless:check; then
echo "✅ spotless:check passed"
exit 0
fi
if [ "$attempt" -lt "$max_attempts" ]; then
echo "⚠️ spotless:check failed (attempt $attempt/$max_attempts), retrying in 10s..."
sleep 10
fi
done
echo "❌ spotless:check failed after $max_attempts attempts. Please run 'mvn spotless:apply' in java/"
exit 1
- name: Run Java SDK tests (JDK 25)
if: matrix.test-jdk == '25'
env:
CI: "true"
run: |
node copilot-native/scripts/validate-native-host.mjs linux-x64
mvn verify -Dskip.test.harness=true -Dcopilot.native.libc=glibc -Dcopilot.native.skip.download=false
- name: Switch to JDK 17
if: matrix.test-jdk == '17'
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5
with:
java-version: "17"
distribution: "microsoft"
- name: Run Java SDK tests (JDK 17, no recompilation)
if: matrix.test-jdk == '17'
env:
CI: "true"
run: |
echo "Running tests against JDK 25-built classes using JDK 17 runtime..."
java -version
mvn -pl sdk jacoco:prepare-agent@wire-up-coverage-instrumentation antrun:run@print-test-jdk-banner surefire:test failsafe:integration-test failsafe:verify jacoco:report@build-coverage-report-from-tests -Denforcer.skip=true
- name: Upload test results for site generation
if: success() && github.ref == 'refs/heads/main' && matrix.test-jdk == '25'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: test-results-for-site
path: |
java/sdk/target/jacoco-test-results/sdk-tests.exec
java/sdk/target/surefire-reports/
java/sdk/target/surefire-reports-isolated/
retention-days: 1
- name: Generate Test Report Summary
if: always()
uses: ./.github/actions/java-test-report
with:
title: "Copilot Java SDK :: Test Results JDK ${{ matrix.test-jdk }}"
- name: Upload test results on failure
if: failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: java-test-results-jdk-${{ matrix.test-jdk }}
path: |
java/sdk/target/surefire-reports/
java/sdk/target/surefire-reports-isolated/
java/sdk/target/failsafe-reports/
retention-days: 7