Skip to content

Commit

Permalink
ci: add generation of coverage badge.
Browse files Browse the repository at this point in the history
  • Loading branch information
paquiteau committed Jan 21, 2024
1 parent 732db51 commit 0d40152
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
11 changes: 11 additions & 0 deletions .github/workflows/master-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ jobs:
run: |
python -m sphinx docs docs_build
- name: Get the badge from CI
uses: actions/download-artifact@v4
with:
name: coverage_badge
path: docs_build/_static
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}

- name: Display data
run: ls -R
working-directory: docs_build/_static
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
Expand Down
24 changes: 23 additions & 1 deletion .github/workflows/test-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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@v4
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-green -O coverage_badge.svg
- name: Upload badge as artifact
if: ${{github.event_name == 'push'}}
uses: actions/upload-artifact@v4
with:
name: coverage_badge
path: coverage_badge.svg

0 comments on commit 0d40152

Please sign in to comment.