-
Notifications
You must be signed in to change notification settings - Fork 1.2k
151 lines (133 loc) · 4.85 KB
/
java-sdk-tests.yml
File metadata and controls
151 lines (133 loc) · 4.85 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
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/**"
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- "java/**"
- "test/**"
- ".github/workflows/java-sdk-tests.yml"
- ".github/actions/setup-copilot/**"
- ".github/actions/java-test-report/**"
- "!**/*.md"
- "!**/LICENSE*"
- "!**/.gitignore"
- "!**/.editorconfig"
- "!**/*.png"
- "!**/*.jpg"
- "!**/*.jpeg"
- "!**/*.gif"
- "!**/*.svg"
workflow_dispatch:
merge_group:
permissions:
contents: write
checks: write
pull-requests: write
jobs:
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: 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 target/copilot-sdk/nodejs/node_modules/@github/copilot/index.js --version
- name: Run spotless check
if: matrix.test-jdk == '25'
run: |
mvn spotless:check
if [ $? -ne 0 ]; then
echo "❌ spotless:check failed. Please run 'mvn spotless:apply' in java"
exit 1
fi
echo "✅ spotless:check passed"
- name: Run Java SDK tests (JDK 25)
if: matrix.test-jdk == '25'
env:
CI: "true"
run: mvn verify -Dskip.test.harness=true
- 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 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/target/jacoco-test-results/sdk-tests.exec
java/target/surefire-reports/
java/target/surefire-reports-isolated/
retention-days: 1
- name: Generate JaCoCo badge
if: success() && github.ref == 'refs/heads/main' && matrix.test-jdk == '25'
working-directory: .
run: bash .github/scripts/generate-java-coverage-badge.sh java/target/site/jacoco-coverage/jacoco.csv .github/badges
- name: Create PR for JaCoCo badge update
if: success() && github.ref == 'refs/heads/main' && matrix.test-jdk == '25'
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v7
with:
commit-message: "Update Java JaCoCo coverage badge"
title: "Update Java JaCoCo coverage badge"
body: "Automated Java JaCoCo coverage badge update from CI."
branch: auto/update-java-jacoco-badge
add-paths: .github/badges/
delete-branch: true
- 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/target/surefire-reports/
java/target/surefire-reports-isolated/
java/target/failsafe-reports/
retention-days: 7