Skip to content

Commit

Permalink
add test coverage to PR comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Hlamallama committed Oct 17, 2024
1 parent 7f0660e commit 6cf4bb4
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,20 @@ jobs:
git diff origin/develop --unified=0 > diff.txt
grep '^@@' diff.txt | awk '{print $2}' > changed_lines.txt
- name: Extract untested new lines
id: untested_new_code
- name: Check for untested lines
id: check_coverage
run: |
COVERAGE_FILE=coverage.txt
DIFF_FILE=changed_lines.txt
UNTTESTED_LINES=""
# Loop through the changed lines to find untested lines
while IFS= read -r LINE; do
LINE_NUM=$(echo "$LINE" | grep -oP '\d+')
UNTTESTED_LINE=$(grep -E "^ *$LINE_NUM " $COVERAGE_FILE | grep 'missed')
if [ -n "$UNTTESTED_LINE" ]; then
UNTTESTED_LINES="$UNTTESTED_LINES\n$UNTTESTED_LINE"
while IFS= read -r line; do
line_number=$(echo $line | grep -oP '\d+')
coverage_info=$(grep -E "^ *$line_number " coverage.txt)
if [[ $coverage_info == *"missed"* ]]; then
UNTTESTED_LINES="$UNTTESTED_LINES\nLine $line_number is not covered by tests."
fi
done < $DIFF_FILE
done < changed_lines.txt
echo "UNTTESTED_LINES=$UNTTESTED_LINES" >> $GITHUB_ENV
- name: Post coverage comment on PR
uses: actions/github-script@v6
with:
Expand Down

0 comments on commit 6cf4bb4

Please sign in to comment.