From 833950c7c122dd9b8ab19c2aeef17270ad9ad90b Mon Sep 17 00:00:00 2001 From: "Mark S. Lewis" Date: Tue, 13 Aug 2024 17:42:00 +0200 Subject: [PATCH] Use GitHub action for Jacoco coverage summary Signed-off-by: Mark S. Lewis --- .github/scripts/jacoco2markdown.sh | 70 ------------------------------ .github/workflows/test.yml | 6 +-- 2 files changed, 3 insertions(+), 73 deletions(-) delete mode 100755 .github/scripts/jacoco2markdown.sh diff --git a/.github/scripts/jacoco2markdown.sh b/.github/scripts/jacoco2markdown.sh deleted file mode 100755 index 6d8723787..000000000 --- a/.github/scripts/jacoco2markdown.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env bash - -set -eu -o pipefail - -csv_to_markdown() { - awk 'function percentage(missed, covered, total) { - total = missed + covered - if (total == 0) { - return "-" - } - return sprintf("%d", covered / total * 100) - } - - BEGIN { - missed_instructions = 0 - covered_instructions = 0 - missed_branches = 0 - covered_branches = 0 - missed_lines = 0 - covered_lines = 0 - missed_methods = 0 - covered_methods = 0 - - printf("
\nDetails\n\n") - print("| Class | % Instruction | % Branch | % Line | % Method |") - print("| --- | ---: | ---: | ---: | ---: |") - } - - { - split($0, cols, ",") - - instructions = percentage(cols[4], cols[5]) - missed_instructions += cols[4] - covered_instructions += cols[5] - - branches = percentage(cols[6], cols[7]) - missed_branches += cols[6] - covered_branches += cols[7] - - lines = percentage(cols[8], cols[9]) - missed_lines += cols[8] - covered_lines += cols[9] - - methods = percentage(cols[12], cols[13]) - missed_methods += cols[12] - covered_methods += cols[13] - - printf("| %s.%s | %s | %s | %s | %s |\n", - cols[2], cols[3], instructions, branches, lines, methods) - } - - END { - instructions = percentage(missed_instructions, covered_instructions) - branches = percentage(missed_branches, covered_branches) - lines = percentage(missed_lines, covered_lines) - methods = percentage(missed_methods, covered_methods) - - printf("
\n\n") - print("| | % Instruction | % Branch | % Line | % Method |") - print("| --- | ---: | ---: | ---: | ---: |") - printf("| **All classes** | %s | %s | %s | %s |\n", - instructions, branches, lines, methods) - }' -} - -if [[ $# == 0 ]] || [[ $1 == - ]]; then - tail -n +2 | sort | csv_to_markdown -else - ( tail -n +2 | sort | csv_to_markdown ) < "$1" -fi diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 51bb42a60..1a9b58f38 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -180,9 +180,9 @@ jobs: run: make unit-test-java - name: Coverage report if: ${{ matrix.coverage }} - run: | - echo '### Unit test coverage' >> ${GITHUB_STEP_SUMMARY} - ${{ github.workspace }}/.github/scripts/jacoco2markdown.sh java/target/site/jacoco/jacoco.csv >> ${GITHUB_STEP_SUMMARY} + uses: bestbeforetoday/jacoco-summary-action@v1 + with: + coverage-file: java/target/site/jacoco/jacoco.csv java_scenario: needs: verify-versions