mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-14 03:31:50 +02:00
ci: coverage
This commit is contained in:
7
.github/workflows/ci.yml
vendored
7
.github/workflows/ci.yml
vendored
@ -1,5 +1,8 @@
|
|||||||
name: Full CI
|
name: Full CI
|
||||||
on: [push]
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
formatter:
|
formatter:
|
||||||
@ -7,6 +10,8 @@ jobs:
|
|||||||
|
|
||||||
unit-test:
|
unit-test:
|
||||||
uses: ./.github/workflows/pytest.yml
|
uses: ./.github/workflows/pytest.yml
|
||||||
|
with:
|
||||||
|
pr_number: ${{ github.event.pull_request.number }}
|
||||||
|
|
||||||
unit-test-matrix:
|
unit-test-matrix:
|
||||||
uses: ./.github/workflows/pytest-matrix.yml
|
uses: ./.github/workflows/pytest-matrix.yml
|
||||||
|
57
.github/workflows/pytest.yml
vendored
57
.github/workflows/pytest.yml
vendored
@ -1,5 +1,15 @@
|
|||||||
name: Run Pytest with Coverage
|
name: Run Pytest with Coverage
|
||||||
on: [workflow_call]
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
pr_number:
|
||||||
|
description: 'Pull request number'
|
||||||
|
required: false
|
||||||
|
type: number
|
||||||
|
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
pytest:
|
pytest:
|
||||||
@ -40,13 +50,46 @@ jobs:
|
|||||||
pip install -e .[dev,pyside6]
|
pip install -e .[dev,pyside6]
|
||||||
|
|
||||||
- name: Run Pytest with Coverage
|
- name: Run Pytest with Coverage
|
||||||
|
id: coverage
|
||||||
run: |
|
run: |
|
||||||
pip install coverage pytest pytest-random-order
|
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
|
coverage run --source=./bec_widgets -m pytest -v --junitxml=report.xml --maxfail=2 --random-order --full-trace ./tests/unit_tests
|
||||||
coverage report
|
|
||||||
coverage xml
|
full_report=$(coverage report)
|
||||||
- name: Upload coverage reports 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:
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
filename: coverage.cobertura.xml
|
||||||
slug: bec-project/bec_widgets
|
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
|
Reference in New Issue
Block a user