Skip to content

Commit 29888e9

Browse files
Add Java 21 GitHub Actions CI workflow
1 parent fa9f057 commit 29888e9

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

.github/workflows/java-21.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Java 21 CI with Maven
2+
name: Java 21 CI with Maven
3+
4+
on:
5+
push:
6+
branches: [ main ]
7+
pull_request:
8+
types: [ labeled, opened, synchronize, reopened ]
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Set up JDK 21
18+
uses: actions/setup-java@v4
19+
with:
20+
distribution: 'temurin'
21+
java-version: 21
22+
cache: maven
23+
24+
- name: Build with Maven
25+
run: mvn -B verify -P run-its
26+
27+
- name: Generate JaCoCo badge
28+
id: jacoco
29+
uses: cicirello/[email protected]
30+
with:
31+
badges-directory: .github/badges
32+
generate-branches-badge: true
33+
generate-summary: true
34+
summary-filename: coverage-summary_java-21.json
35+
coverage-badge-filename: jacoco_java-21.svg
36+
branches-badge-filename: branches_java-21.svg
37+
coverage-endpoint-filename: jacoco_java-21.json
38+
branches-endpoint-filename: branches_java-21.json
39+
40+
- name: Log coverage percentages to workflow output
41+
run: |
42+
echo "(java-21) coverage = ${{ steps.jacoco.outputs.coverage }}%"
43+
echo "(java-21) branches = ${{ steps.jacoco.outputs.branches }}%"
44+
45+
- name: Upload JaCoCo coverage report
46+
uses: actions/upload-artifact@v4
47+
with:
48+
name: jacoco-report-java-21
49+
path: target/site/jacoco/
50+
51+
- name: Deploy to Coverage Branch
52+
if: ${{ github.event_name != 'pull_request' }}
53+
uses: crazy-max/ghaction-github-pages@v4
54+
with:
55+
target_branch: coverage
56+
build_dir: .github/badges
57+
env:
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
60+
- name: Comment on PR with coverage percentages
61+
if: ${{ github.event_name == 'pull_request' }}
62+
run: |
63+
REPORT=$(<.github/badges/coverage-summary_java-21.json)
64+
COVERAGE=$(jq -r '.coverage' <<< "$REPORT")%
65+
BRANCHES=$(jq -r '.branches' <<< "$REPORT")%
66+
NEWLINE=$'\n'
67+
BODY="## JaCoCo Test Coverage Summary Statistics (java-21) ${NEWLINE}* __Coverage:__ ${COVERAGE}${NEWLINE}* __Branches:__ ${BRANCHES}"
68+
gh pr comment ${{github.event.pull_request.number}} -b "${BODY}"
69+
continue-on-error: true
70+
env:
71+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)