[Java] Clean-up: make it so interim time during implementation produc… #1344
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | |
| if: github.event.repository.fork == false | |
| runs-on: ubuntu-latest | |
| 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: Validate Linux glibc native host | |
| run: node copilot-native/scripts/validate-native-host.mjs linux-x64 | |
| - name: Run Java SDK tests (InProcess) | |
| env: | |
| CI: "true" | |
| run: mvn clean verify -Pinprocess -Dcopilot.native.skip.download=false | |
| - 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 | |
| path: | | |
| java/sdk/target/surefire-reports/ | |
| java/sdk/target/surefire-reports-isolated/ | |
| java/sdk/target/failsafe-reports/ | |
| retention-days: 7 | |
| 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 |