From 2f43d1e2354b5ea1569b8b9c919ade40be7821b8 Mon Sep 17 00:00:00 2001 From: Pierre-antoine Comby Date: Sun, 21 Jan 2024 17:17:49 +0100 Subject: [PATCH] ci: add generation of coverage badge. --- .github/workflows/master-cd.yml | 7 +++++++ .github/workflows/test-ci.yml | 24 +++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/.github/workflows/master-cd.yml b/.github/workflows/master-cd.yml index beb653260..e62b394a9 100644 --- a/.github/workflows/master-cd.yml +++ b/.github/workflows/master-cd.yml @@ -50,6 +50,13 @@ jobs: run: | python -m sphinx docs docs_build + - name: Get the badge from CI + uses: actions/download-artifacts@v2 + continue-on-error: true + with: + name: coverage_build + path: docs_build/_static + - name: Upload artifact uses: actions/upload-pages-artifact@v1 with: diff --git a/.github/workflows/test-ci.yml b/.github/workflows/test-ci.yml index 2904ff93d..37f4220c3 100644 --- a/.github/workflows/test-ci.yml +++ b/.github/workflows/test-ci.yml @@ -201,9 +201,31 @@ jobs: python -m pip install -e . - name: Combine coverage - run: coverage combine -a coverage_data/* + run: | + export COVERAGE_FILE=coverage_combined + coverage combine -a coverage_data/* + + - name: Upload Combined coverage + uses: actions/upload-artifact@v3 + with: + name: coverage_combined + path: coverage_combined - name: Reports run: | + export COVERAGE_FILE=coverage_combined coverage xml coverage report + echo COVERAGE_PERC=$(coverage report | tail -n 1 | grep -oE [0-9\.]*?% | cut -d '%' -f1) >> $GITHUB_ENV + + - name: Create a Coverage Badge + if: ${{github.event_name == 'push'}} + run: | + wget https://img.shields.io/badge/coverage-${{env.COVERAGE_PERC}}%25-darkgreen -O coverage_badge.svg + + - name: Upload badge as artifact + if: ${{github.event_name == 'push'}} + uses: actions/upload-artifact@v3 + with: + name: coverage_badge + path: coverage_badge.svg