Merge pull request #34 from Brijeshthummar02/Issue-Template #14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Java 21 CI with Maven | |
name: Java 21 CI with Maven | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
types: [ labeled, opened, synchronize, reopened ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: 21 | |
cache: maven | |
- name: Build with Maven | |
run: mvn -B verify -P run-its | |
- name: Generate JaCoCo badge | |
id: jacoco | |
uses: cicirello/jacoco-badge-generator@v2.11.0 | |
with: | |
badges-directory: .github/badges | |
generate-branches-badge: true | |
generate-summary: true | |
summary-filename: coverage-summary_java-21.json | |
coverage-badge-filename: jacoco_java-21.svg | |
branches-badge-filename: branches_java-21.svg | |
coverage-endpoint-filename: jacoco_java-21.json | |
branches-endpoint-filename: branches_java-21.json | |
- name: Log coverage percentages to workflow output | |
run: | | |
echo "(java-21) coverage = ${{ steps.jacoco.outputs.coverage }}%" | |
echo "(java-21) branches = ${{ steps.jacoco.outputs.branches }}%" | |
- name: Upload JaCoCo coverage report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: jacoco-report-java-21 | |
path: target/site/jacoco/ | |
- name: Deploy to Coverage Branch | |
if: ${{ github.event_name != 'pull_request' }} | |
uses: crazy-max/ghaction-github-pages@v4 | |
with: | |
target_branch: coverage | |
build_dir: .github/badges | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Comment on PR with coverage percentages | |
if: ${{ github.event_name == 'pull_request' }} | |
run: | | |
REPORT=$(<.github/badges/coverage-summary_java-21.json) | |
COVERAGE=$(jq -r '.coverage' <<< "$REPORT")% | |
BRANCHES=$(jq -r '.branches' <<< "$REPORT")% | |
NEWLINE=$'\n' | |
BODY="## JaCoCo Test Coverage Summary Statistics (java-21) ${NEWLINE}* __Coverage:__ ${COVERAGE}${NEWLINE}* __Branches:__ ${BRANCHES}" | |
gh pr comment ${{github.event.pull_request.number}} -b "${BODY}" | |
continue-on-error: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |