Files
amq-adapter-python/.forgejo/workflows/coverage-check.yaml
T
hurui200320 234ae9f175
CI for pypl publish / publish-lib (push) Failing after 52s
Unit test coverage / pytest (push) Failing after 54s
fix(General): fix broken pipeline
2025-03-27 21:12:52 +08:00

47 lines
1.6 KiB
YAML

name: "Unit test coverage"
on:
push:
pull_request:
env:
MIN_COVERAGE_PERCENTAGE: 85
DEBIAN_FRONTEND: noninteractive
TZ: UTC
jobs:
# gradle test for modules
pytest:
runs-on: default
container:
image: ubuntu:24.04
steps:
# need to setup node and git
- run: |
apt-get update
apt-get install -y nodejs git curl libsqlite3-0
# check out code and set up python
- uses: actions/checkout@v4
- uses: https://github.com/actions/setup-python@v5
with:
python-version: '3.11'
# install dependencies
- run: pip install -e .[dev]
# run pytest with coverage
- run: pytest --cov=amqp --cov-report=xml
# process coverage report
- name: Collect coverage report
id: coverage
run: |
COVERAGE_PERCENTAGE=$(coverage report --format=total)
echo "Code coverage: ${COVERAGE_PERCENTAGE}%"
echo "Minimal coverage: ${MIN_COVERAGE_PERCENTAGE}%"
echo "percentage=${COVERAGE_PERCENTAGE}" >> $GITHUB_OUTPUT
- name: Post coverage to RP
if: github.event_name == 'pull_request'
run: |
curl --fail \
-X POST '${{github.api_url}}/repos/${{github.repository}}/issues/${{github.event.number}}/comments' \
-H "Content-Type: application/json" \
-H "Authorization: token ${{github.token}}" \
-d '{"body":"Coverage for module ${{ matrix.submodule }} is ${{steps.coverage.outputs.percentage}}%"}'
- name: Check coverage rate
run: |
coverage report --fail-under=${MIN_COVERAGE_PERCENTAGE}