|
| 1 | +# SPDX-License-Identifier: Apache-2.0 |
| 2 | +name: Java CI |
| 3 | + |
| 4 | +on: |
| 5 | + # Build only the production branches on push, so internal feature branches do not trigger a build twice (once on push, once on the pull request). |
| 6 | + push: |
| 7 | + # Restricts push builds to these branches, even if the workflow is copied to another branch. |
| 8 | + branches: |
| 9 | + - 2.0.X |
| 10 | + - 2.1.X |
| 11 | + - 2.2.X |
| 12 | + # Build every pull request targeting the branch this workflow lives on. |
| 13 | + pull_request: |
| 14 | + |
| 15 | +# Permissions are granted per job. |
| 16 | +permissions: { } |
| 17 | + |
| 18 | +# Check all pushes to production branches, but interrupt a PR job if a new commit is pushed. |
| 19 | +concurrency: |
| 20 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 21 | + cancel-in-progress: ${{ github.event_name == 'pull_request' }} |
| 22 | + |
| 23 | +jobs: |
| 24 | + test: |
| 25 | + runs-on: ${{ matrix.os }} |
| 26 | + strategy: |
| 27 | + matrix: |
| 28 | + os: [ubuntu-latest, windows-latest] |
| 29 | + # Enforce Java 8 only, branches 2.0.X and 2.1.X won't build with any other versions |
| 30 | + java-version: [8] |
| 31 | + distribution: [temurin] |
| 32 | + include: |
| 33 | + # There is no Temurin JDK 8 release for macOS ARM. |
| 34 | + - os: macos-latest |
| 35 | + java-version: 8 |
| 36 | + distribution: zulu |
| 37 | + fail-fast: false |
| 38 | + name: Test JDK ${{ matrix.java-version }}, ${{ matrix.os }} |
| 39 | + |
| 40 | + # Actions from the `actions` and `github` organizations are pinned to a major version tag rather than a commit SHA. |
| 41 | + # This is a deliberate decision: |
| 42 | + # |
| 43 | + # - Those organizations have strong expertise in securing GitHub Actions. |
| 44 | + # - A compromise of either organization would likely also compromise the GitHub Actions service itself, so pinning would not help. |
| 45 | + # - These actions release frequently. |
| 46 | + # |
| 47 | + # The residual risk is deemed acceptable in exchange for less Dependabot churn across the maintained branches. |
| 48 | + steps: |
| 49 | + |
| 50 | + - name: Checkout repository |
| 51 | + uses: actions/checkout@v6 |
| 52 | + with: |
| 53 | + # Don't persist the GitHub token used to check out the repository. |
| 54 | + persist-credentials: false |
| 55 | + |
| 56 | + - name: Set up JDK |
| 57 | + uses: actions/setup-java@v5 |
| 58 | + with: |
| 59 | + java-version: ${{ matrix.java-version }} |
| 60 | + distribution: ${{ matrix.distribution }} |
| 61 | + cache: maven |
| 62 | + |
| 63 | + - name: Test with Maven |
| 64 | + shell: bash |
| 65 | + run: | |
| 66 | + mvn verify \ |
| 67 | + -Pserial \ |
| 68 | + --show-version --batch-mode --errors --no-transfer-progress |
| 69 | +
|
| 70 | + # Upload the test results, even when the build failed. |
| 71 | + - name: Upload test reports |
| 72 | + if: always() |
| 73 | + uses: actions/upload-artifact@v7 |
| 74 | + with: |
| 75 | + name: "test-report-${{matrix.os}}-${{matrix.distribution}}-${{matrix.java-version}}-${{github.run_number}}-${{github.run_attempt}}" |
| 76 | + # Don't warn or fail when no tests ran (e.g. a compilation failure). |
| 77 | + if-no-files-found: ignore |
| 78 | + path: | |
| 79 | + **/target/surefire-reports |
0 commit comments