Skip to content

Commit

Permalink
Make unit test coverage decrease more significant (#90)
Browse files Browse the repository at this point in the history
Summary: Make unit test coverage decrease more significant -
rialto-gstreamer
Type: Feature
Test Plan: Unit tests
Jira: RIALTO-421
  • Loading branch information
skyshaha1 authored Jan 18, 2024
1 parent 4a8649b commit a2822a8
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
34 changes: 29 additions & 5 deletions .github/workflows/build_ut.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,29 @@ jobs:
name: coverage_report_stats
path: build/coverage_statistics.txt

checks-the-cov-report:
name: Checks the Coverage Report

# Runs on ubuntu
runs-on: ubuntu-22.04

# Timeout after
timeout-minutes: 2

# # Define the dependencies on the previous coverage jobs
needs: [build-test]

steps:
- name: Checkout repo
uses: actions/checkout@v3

# Download the current coverage statistics
- name: Download Current Coverage Statistics
uses: actions/download-artifact@v2
with:
name: coverage_report_stats
path: build

# Download current master coverage statistics
- name: Download Master Coverage Statistics
uses: dawidd6/action-download-artifact@v2
Expand All @@ -118,26 +141,27 @@ jobs:
branch: master
name: coverage_report_stats
path: master_artifacts

# Run the process_coverage_stats script
- name: Process Coverage Statistics
if: ${{ success() && github.ref != 'refs/heads/master' }}
run: python scripts/coverage/process_coverage_stats.py ./master_artifacts/coverage_statistics.txt build/coverage_statistics.txt

# Get process_coverage_stats script output
- id: get-comment-body
if: ${{ success() && github.ref != 'refs/heads/master' }}
if: ${{ (success() || failure()) && github.ref != 'refs/heads/master' }}
run: |
body="$(cat comparison_output.txt)"
body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}"
echo "::set-output name=body::$body"
# Create comment with coverage info
- name: Create Coverage Comment
if: ${{ success() && github.ref != 'refs/heads/master' }}
if: ${{ (success() || failure()) && github.ref != 'refs/heads/master' }}
uses: peter-evans/create-or-update-comment@v2
with:
issue-number: ${{ github.event.pull_request.number }}
body: ${{ steps.get-comment-body.outputs.body }}

8 changes: 8 additions & 0 deletions scripts/coverage/process_coverage_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ def main():
comparison_output = compare_coverage(master_stats, current_stats)
write_output(comparison_output)

# If line coverage, funtion coverage individually or both decrease, it should exit
if current_stats[0] < master_stats[0] and current_stats[1] < master_stats[1]:
sys.exit("Line coverage and function coverage have both decreased. Exiting...")
elif current_stats[0] < master_stats[0]:
sys.exit("Line coverage has decreased. Exiting...")
elif current_stats[1] < master_stats[1]:
sys.exit("Function coverage has decreased. Exiting...")

def parse_statistics(file_path):
try:
file = open(file_path, "r")
Expand Down

0 comments on commit a2822a8

Please sign in to comment.