From 605b1cb9894142ea69d1036b2586e25bd36cb50f Mon Sep 17 00:00:00 2001 From: Brijeshthummar02 Date: Tue, 18 Feb 2025 18:15:41 +0530 Subject: [PATCH] Enhance Java 11 CI workflow with improved logging and coverage reporting - Added better logging for coverage percentages - Improved error handling for missing coverage report - Standardized PR comment format with Java 21 CI - Ensured proper workflow consistency Signed-off-by: Brijeshthummar02 --- .github/workflows/java-11.yml | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/.github/workflows/java-11.yml b/.github/workflows/java-11.yml index 3b19a6c..311f5a7 100644 --- a/.github/workflows/java-11.yml +++ b/.github/workflows/java-11.yml @@ -26,14 +26,15 @@ on: # build execution pull_request: types: [ labeled, opened, synchronize, reopened ] - + jobs: build: - runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: Checkout Repository + uses: actions/checkout@v4 + - name: Set up JDK 11 uses: actions/setup-java@v4 with: @@ -59,8 +60,8 @@ jobs: - name: Log coverage percentages to workflow output run: | - echo "(java-11) coverage = ${{ steps.jacoco.outputs.coverage }}" - echo "(java-11) branches = ${{ steps.jacoco.outputs.branches }}" + echo "(java-11) coverage = ${{ steps.jacoco.outputs.coverage }}%" + echo "(java-11) branches = ${{ steps.jacoco.outputs.branches }}%" - name: Upload JaCoCo coverage report uses: actions/upload-artifact@v4 @@ -81,11 +82,17 @@ jobs: if: ${{ github.event_name == 'pull_request' }} run: | REPORT=$(<.github/badges/coverage-summary_java-11.json) + if [[ -z "$REPORT" ]]; then + echo "Coverage report not found!" >&2 + exit 1 + fi + COVERAGE=$(jq -r '.coverage' <<< "$REPORT")% BRANCHES=$(jq -r '.branches' <<< "$REPORT")% NEWLINE=$'\n' - BODY="## JaCoCo Test Coverage Summary Statistics (java-11) ${NEWLINE}* __Coverage:__ ${COVERAGE}${NEWLINE}* __Branches:__ ${BRANCHES}" - gh pr comment ${{github.event.pull_request.number}} -b "${BODY}" + BODY="## JaCoCo Test Coverage Summary Statistics (Java 11) ${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 }}