Compare commits

...

2 Commits

Author SHA1 Message Date
Ray Myers
70fb1dd450 Updatre coverage enforcement calculation 2025-10-29 01:27:12 -05:00
Ray Myers
475664e62b chore - Enforce python test coverage 2025-10-28 17:59:53 -05:00

View File

@@ -176,7 +176,6 @@ jobs:
coverage-comment:
name: Coverage Comment
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
needs: [test-on-linux, test-enterprise, test-cli-python]
@@ -196,8 +195,23 @@ jobs:
run: ln -sf openhands-cli/openhands_cli openhands_cli
- name: Coverage comment
# In PR mode leaves a comment, otherwise records coverage in branch python-coverage-comment-action-data.
id: coverage_comment
uses: py-cov-action/python-coverage-comment-action@v3
with:
GITHUB_TOKEN: ${{ github.token }}
MERGE_COVERAGE_FILES: true
- name: Enforce coverage
# Fail if on PR AND there are uncovered lines AND diff coverage is less than total coverage.
# To debug, try a step to log outputs like: `echo ${{ toJSON(steps.coverage_comment.outputs) }}`
# Once we track base branch, reference_percent_covered will be better to use than new_percent_covered.
if: ${{ github.event_name == 'pull_request' && fromJSON(steps.coverage_comment.outputs.diff_total_num_violations) > 0 && steps.coverage_comment.outputs.diff_total_percent_covered < steps.coverage_comment.outputs.new_percent_covered }}
run: |
echo "Coverage decreased, which is not allowed."
echo "Please add some unit tests for the modified code."
echo
echo " diff_total_num_violations: ${{ steps.coverage_comment.outputs.diff_total_num_violations }}"
echo " diff_total_percent_covered: ${{ steps.coverage_comment.outputs.diff_total_percent_covered}}"
echo " new_percent_covered: ${{ steps.coverage_comment.outputs.new_percent_covered}}"
exit 1