|
1 | | ---- |
| 1 | +# SPDX-License-Identifier: Apache-2.0 |
2 | 2 | name: Java CI |
3 | 3 |
|
4 | | -on: [push] |
| 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' }} |
5 | 22 |
|
6 | 23 | jobs: |
7 | 24 | test: |
8 | 25 | runs-on: ${{ matrix.os }} |
9 | 26 | strategy: |
10 | 27 | matrix: |
11 | | - os: [ubuntu-18.04, macOS-latest, windows-2016] |
12 | | - java: [7, 8, 11, 17, 20] |
| 28 | + os: [ubuntu-latest, windows-latest, macos-latest] |
| 29 | + java-version: [17, 21, 25] |
| 30 | + distribution: [temurin] |
13 | 31 | fail-fast: false |
14 | | - max-parallel: 4 |
15 | | - name: Test JDK ${{ matrix.java }}, ${{ matrix.os }} |
| 32 | + name: Test JDK ${{ matrix.java-version }}, ${{ matrix.os }} |
16 | 33 |
|
| 34 | + # Actions from the `actions` and `github` organizations are pinned to a major version tag rather than a commit SHA. |
| 35 | + # This is a deliberate decision: |
| 36 | + # |
| 37 | + # - Those organizations have strong expertise in securing GitHub Actions. |
| 38 | + # - A compromise of either organization would likely also compromise the GitHub Actions service itself, so pinning would not help. |
| 39 | + # - These actions release frequently. |
| 40 | + # |
| 41 | + # The residual risk is deemed acceptable in exchange for less Dependabot churn across the maintained branches. |
17 | 42 | steps: |
18 | | - - uses: actions/checkout@v1 |
| 43 | + |
| 44 | + - name: Checkout repository |
| 45 | + uses: actions/checkout@v6 |
| 46 | + with: |
| 47 | + # Don't persist the GitHub token used to check out the repository. |
| 48 | + persist-credentials: false |
| 49 | + |
19 | 50 | - name: Set up JDK |
20 | | - uses: actions/setup-java@v1 |
| 51 | + uses: actions/setup-java@v5 |
21 | 52 | with: |
22 | | - java-version: ${{ matrix.java }} |
| 53 | + java-version: ${{ matrix.java-version }} |
| 54 | + distribution: ${{ matrix.distribution }} |
| 55 | + cache: maven |
| 56 | + |
23 | 57 | - name: Test with Maven |
24 | | - run: mvn test -B --file pom.xml |
| 58 | + shell: bash |
| 59 | + run: | |
| 60 | + mvn verify \ |
| 61 | + -Pserial \ |
| 62 | + --show-version --batch-mode --errors --no-transfer-progress |
25 | 63 |
|
26 | | -... |
| 64 | + # Upload the test results, even when the build failed. |
| 65 | + - name: Upload test reports |
| 66 | + if: always() |
| 67 | + uses: actions/upload-artifact@v7 |
| 68 | + with: |
| 69 | + name: "test-report-${{matrix.os}}-${{matrix.distribution}}-${{matrix.java-version}}-${{github.run_number}}-${{github.run_attempt}}" |
| 70 | + # Don't warn or fail when no tests ran (e.g. a compilation failure). |
| 71 | + if-no-files-found: ignore |
| 72 | + path: | |
| 73 | + **/target/surefire-reports |
0 commit comments