mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-13 19:21:50 +02:00
ci: add codecov upload
and remove other coverage solution
This commit is contained in:
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@ -10,8 +10,8 @@ jobs:
|
|||||||
|
|
||||||
unit-test:
|
unit-test:
|
||||||
uses: ./.github/workflows/pytest.yml
|
uses: ./.github/workflows/pytest.yml
|
||||||
with:
|
secrets:
|
||||||
pr_number: ${{ github.event.pull_request.number }}
|
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
|
||||||
unit-test-matrix:
|
unit-test-matrix:
|
||||||
uses: ./.github/workflows/pytest-matrix.yml
|
uses: ./.github/workflows/pytest-matrix.yml
|
||||||
|
59
.github/workflows/pytest.yml
vendored
59
.github/workflows/pytest.yml
vendored
@ -1,11 +1,15 @@
|
|||||||
name: Run Pytest with Coverage
|
name: Run Pytest with Coverage
|
||||||
on:
|
on:
|
||||||
workflow_call:
|
workflow_call:
|
||||||
inputs:
|
inputs:
|
||||||
pr_number:
|
pr_number:
|
||||||
description: 'Pull request number'
|
description: 'Pull request number'
|
||||||
required: false
|
required: false
|
||||||
type: number
|
type: number
|
||||||
|
secrets:
|
||||||
|
CODECOV_TOKEN:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
@ -52,44 +56,11 @@ jobs:
|
|||||||
- name: Run Pytest with Coverage
|
- name: Run Pytest with Coverage
|
||||||
id: coverage
|
id: coverage
|
||||||
run: |
|
run: |
|
||||||
pip install coverage pytest pytest-random-order
|
pip install coverage pytest pytest-random-order pytest-cov
|
||||||
coverage run --source=./bec_widgets -m pytest -v --junitxml=report.xml --maxfail=2 --random-order --full-trace ./tests/unit_tests
|
pytest --cov --random-order --cov-branch --cov-report=xml tests/unit_tests/
|
||||||
|
|
||||||
full_report=$(coverage report)
|
- name: Upload coverage to Codecov
|
||||||
coverage xml -i -o coverage.cobertura.xml
|
uses: codecov/codecov-action@v5
|
||||||
|
|
||||||
# Extract total coverage %
|
|
||||||
COVERAGE=$(echo "$full_report" | grep TOTAL | awk '{print $4}' | sed 's/%//')
|
|
||||||
echo "coverage=$COVERAGE" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Code Coverage Summary Report
|
|
||||||
uses: irongut/CodeCoverageSummary@v1.3.0
|
|
||||||
with:
|
with:
|
||||||
filename: coverage.cobertura.xml
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
format: 'markdown'
|
slug: bec-project/bec_widgets
|
||||||
output: 'both'
|
|
||||||
|
|
||||||
- name: Format Coverage Report
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
tmpfile=$(cat code-coverage-results.md)
|
|
||||||
echo "## Code Coverage Report" > code-coverage-results-formatted.md
|
|
||||||
echo "" >> code-coverage-results-formatted.md
|
|
||||||
echo "<details>" >> code-coverage-results-formatted.md
|
|
||||||
echo "<summary>Code Coverage</summary>" >> code-coverage-results-formatted.md
|
|
||||||
echo >> code-coverage-results-formatted.md
|
|
||||||
echo >> code-coverage-results-formatted.md
|
|
||||||
echo "$tmpfile" >> code-coverage-results-formatted.md
|
|
||||||
echo "</details>" >> code-coverage-results-formatted.md
|
|
||||||
|
|
||||||
- name: Add Coverage PR Comment
|
|
||||||
if: ${{ github.event_name == 'pull_request' }}
|
|
||||||
uses: marocchino/sticky-pull-request-comment@v2
|
|
||||||
with:
|
|
||||||
number: ${{ github.event.pull_request.number }}
|
|
||||||
recreate: true
|
|
||||||
path: code-coverage-results-formatted.md
|
|
||||||
|
|
||||||
- name: Write Coverage to Job Summary
|
|
||||||
shell: bash
|
|
||||||
run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY
|
|
Reference in New Issue
Block a user