Skip to content

Commit

Permalink
GitHub actions: save coverage data as artifacts
Browse files Browse the repository at this point in the history
Signed-off-by: flashdagger <flashdagger@googlemail.com>
  • Loading branch information
flashdagger committed Apr 1, 2024
1 parent 23dbd9d commit 078aa7e
Showing 1 changed file with 47 additions and 21 deletions.
68 changes: 47 additions & 21 deletions .github/workflows/core-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ jobs:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "pypy-3.10"]
env:
TOTAL_COVERAGE: "-"

steps:
- uses: actions/checkout@v3
Expand All @@ -40,26 +38,17 @@ jobs:
- name: Unit tests with pytest
run: |
poetry run pytest
- name: prepare coverage data
continue-on-error: true
run: |
poetry run coverage json
export TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])")
echo "TOTAL_COVERAGE=$TOTAL" >> $GITHUB_ENV
echo "### Total coverage: ${TOTAL}%" >> $GITHUB_STEP_SUMMARY
- name: create coverage badge
if : ${{ matrix.python-version == '3.11' }}
uses: schneegans/dynamic-badges-action@v1.7.0
env:
COVERAGE_FILE: .coverage.${{ matrix.python-version }}
- name: Upload coverage data
if: success() || failure()
uses: actions/upload-artifact@v4
with:
auth: ${{ secrets.GIST_TOKEN }}
gistID: 1a66c9e88a9e4267f7e0b1d185be98f4
filename: covbadge.json
label: coverage
message: ${{ env.TOTAL_COVERAGE }}%
minColorRange: 50
maxColorRange: 90
valColorRange: ${{ env.TOTAL_COVERAGE }}
isError: ${{ env.TOTAL_COVERAGE == '-' }}
name: coverage-data-${{ matrix.python-version }}
if-no-files-found: warn
path: ./.coverage*
compression-level: 0 # no compression
retention-days: 1
- name: Static typechecking with mypy
if: ${{ !startsWith(matrix.python-version, 'pypy') }}
run: |
Expand All @@ -68,3 +57,40 @@ jobs:
if: ${{ matrix.python-version != '3.8' }}
run: |
poetry run pylint ./zammadoo
process-test-data:
if: success() || failure()
runs-on: ubuntu-latest
needs: test
env:
TOTAL_COVERAGE: "-"
steps:
- run: pipx install coverage
- name: Download coverage data
uses: actions/download-artifact@v4
with:
merge-multiple: true
- name: Merge coverage data
continue-on-error: true
run: |
coverage combine .coverage.*
coverage report
- name: Compute total coverage
continue-on-error: true
run: |
coverage json
export TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])")
echo "TOTAL_COVERAGE=$TOTAL" >> $GITHUB_ENV
echo "### Total coverage: ${TOTAL}%" >> $GITHUB_STEP_SUMMARY
- name: create coverage badge
uses: schneegans/dynamic-badges-action@v1.7.0
with:
auth: ${{ secrets.GIST_TOKEN }}
gistID: 1a66c9e88a9e4267f7e0b1d185be98f4
filename: covbadge.json
label: coverage
message: ${{ env.TOTAL_COVERAGE }}%
minColorRange: 50
maxColorRange: 90
valColorRange: ${{ env.TOTAL_COVERAGE }}
isError: ${{ env.TOTAL_COVERAGE == '-' }}

0 comments on commit 078aa7e

Please sign in to comment.