Skip to content

Commit d3af7f2

Browse files
authored
Merge pull request #53 from ppkarwasz/feat/actions-2.2.X
[DIRMINA-1197] Modernize Java CI workflow
2 parents 1069e94 + c7819ca commit d3af7f2

1 file changed

Lines changed: 58 additions & 11 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,73 @@
1-
---
1+
# SPDX-License-Identifier: Apache-2.0
22
name: Java CI
33

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' }}
522

623
jobs:
724
test:
825
runs-on: ${{ matrix.os }}
926
strategy:
1027
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]
1331
fail-fast: false
14-
max-parallel: 4
15-
name: Test JDK ${{ matrix.java }}, ${{ matrix.os }}
32+
name: Test JDK ${{ matrix.java-version }}, ${{ matrix.os }}
1633

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.
1742
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+
1950
- name: Set up JDK
20-
uses: actions/setup-java@v1
51+
uses: actions/setup-java@v5
2152
with:
22-
java-version: ${{ matrix.java }}
53+
java-version: ${{ matrix.java-version }}
54+
distribution: ${{ matrix.distribution }}
55+
cache: maven
56+
2357
- 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
2563
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

Comments
 (0)