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" 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: "17" distribution: "microsoft" cache: "maven" - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6 with: node-version: 22 - uses: ./.github/actions/setup-copilot id: setup-copilot - name: Install test harness dependencies working-directory: ./test/harness run: npm ci --ignore-scripts - name: Run spotless check 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: Verify Javadoc generation run: mvn compile javadoc:javadoc -q - name: Run Java SDK tests env: CI: "true" COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }} COPILOT_CLI_PATH: ${{ steps.setup-copilot.outputs.cli-path }} run: mvn verify - name: Upload test results for site generation if: success() && github.ref == 'refs/heads/main' 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' working-directory: . run: .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' 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 - name: Upload test results on failure if: failure() uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 with: name: java-test-results path: | java/target/surefire-reports/ java/target/surefire-reports-isolated/ retention-days: 7