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:
|
||||
uses: ./.github/workflows/pytest.yml
|
||||
with:
|
||||
pr_number: ${{ github.event.pull_request.number }}
|
||||
secrets:
|
||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||
|
||||
unit-test-matrix:
|
||||
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
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
pr_number:
|
||||
description: 'Pull request number'
|
||||
required: false
|
||||
type: number
|
||||
inputs:
|
||||
pr_number:
|
||||
description: 'Pull request number'
|
||||
required: false
|
||||
type: number
|
||||
secrets:
|
||||
CODECOV_TOKEN:
|
||||
required: true
|
||||
|
||||
|
||||
|
||||
permissions:
|
||||
@ -52,44 +56,11 @@ jobs:
|
||||
- name: Run Pytest with Coverage
|
||||
id: coverage
|
||||
run: |
|
||||
pip install coverage pytest pytest-random-order
|
||||
coverage run --source=./bec_widgets -m pytest -v --junitxml=report.xml --maxfail=2 --random-order --full-trace ./tests/unit_tests
|
||||
pip install coverage pytest pytest-random-order pytest-cov
|
||||
pytest --cov --random-order --cov-branch --cov-report=xml tests/unit_tests/
|
||||
|
||||
full_report=$(coverage report)
|
||||
coverage xml -i -o coverage.cobertura.xml
|
||||
|
||||
# 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
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@v5
|
||||
with:
|
||||
filename: coverage.cobertura.xml
|
||||
format: 'markdown'
|
||||
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
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
slug: bec-project/bec_widgets
|
Reference in New Issue
Block a user