From b52f57c53b1da4e06b41076a5b7f4f04a1bb909d Mon Sep 17 00:00:00 2001 From: Andreas Heinrich Date: Wed, 18 Sep 2024 15:53:40 +0200 Subject: [PATCH] use anybadge Signed-off-by: Andreas Heinrich --- .github/workflows/continuous_integration.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index bd4ca8f..4d465d9 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -444,12 +444,24 @@ jobs: if-no-files-found: error name: coverage-xml path: coverage-xml + - name: Parse coverage report + id: parse_coverage_report + shell: python3 {0} + run: | + import xml.etree.ElementTree + import os + tree = xml.etree.ElementTree.parse("${{ github.workspace }}/coverage-xml/gcovr-coverage-xml.xml") + line_coverage = tree.getroot().get("line-rate") + + with open(os.environ["GITHUB_OUTPUT"], "a") as f: + f.write(f"line_coverage={line_coverage}\n") + f.write(f"line_coverage_percentage={line_coverage * 100}\n") - name: Generate coverage badge run: | # LTODO install in docker image - pip install genbadge[all] + pip install anybadge mkdir -p ${{ github.workspace }}/coverage-badge/ - genbadge coverage -i ${{ github.workspace }}/coverage-xml/gcovr-coverage-xml.xml -o ${{ github.workspace }}/coverage-badge/coverage-badge.svg -n "Total Code Coverage" --local -v + anybadge -o --label Coverage --value ${{ steps.parse_coverage_report.outputs.line_coverage_percentage }} -s "%" --file ${{ github.workspace }}/coverage-badge/coverage-badge.svg 20=red 40=orange 60=yellow 80=yellowgreen 100=green - name: Deploy coverage badge # LTODO update version uses: everest/everest-ci/github-actions/deploy-ci-artifact@feature/add-reusable-ci-workflow