Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/L1-Test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: L1 Unit Tests Remote Debugger

on:
pull_request:
branches: [ develop, main, feature/RDK-49894 ]
branches: [ develop ]

env:
AUTOMATICS_UNAME: ${{ secrets.AUTOMATICS_UNAME }}
Expand Down
54 changes: 54 additions & 0 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Code Coverage

on:
pull_request:
branches: [ main ]

jobs:
execute-unit-code-coverage-report-on-release:
name: Test coverage report for release
runs-on: ubuntu-latest
container:
image: ghcr.io/rdkcentral/docker-rdk-ci:latest

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

- name: Run unit tests with coverage flags enabled
run: |
sh run_ut.sh --enable-cov
- name: Caculate the code coverage summary
run: |
cd ./src/unittest
lcov --list coverage.info | grep "Lines\|Total" > /tmp/coverage_summary.txt
cd -

- name: Update the coverage report to Pull request using actions
uses: actions/github-script@v4
with:
script: |
const fs = require('fs');
const lcov_result = fs.readFileSync('/tmp/coverage_summary.txt', 'utf8');

github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body:
'## Code Coverage Summary \n' +
' ' +
'```' +
lcov_result +
'```'
});
- name: Generate the html report
run: |
cd ./src/unittest
genhtml coverage.info --output-directory /tmp/coverage_report
cd -
- name: Upload the coverage report to Pull request using actions
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: /tmp/coverage_report
21 changes: 18 additions & 3 deletions run_ut.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@
# SPDX-License-Identifier: Apache-2.0
#

ENABLE_COV=false

if [ "x$1" = "x--enable-cov" ]; then
echo "Enabling coverage options"
export CXXFLAGS="-g -O0 -fprofile-arcs -ftest-coverage"
export CFLAGS="-g -O0 -fprofile-arcs -ftest-coverage"
export LDFLAGS="-lgcov --coverage"
ENABLE_COV=true
fi

export TOP_DIR=`pwd`
cd ./src/unittest/

echo "********************"
Expand Down Expand Up @@ -44,10 +55,14 @@ fi
echo "********************"
echo "**** CAPTURE RDK REMOTE DEBUGGER COVERAGE DATA ****"
echo "********************"
lcov --capture --directory . --output-file coverage.info
lcov --remove coverage.info '/usr/*' --output-file coverage.filtered.info
genhtml coverage.filtered.info --output-directory out
if [ "$ENABLE_COV" = true ]; then
echo "Generating coverage report"
lcov --capture --directory . --output-file coverage.info
lcov --remove coverage.info '/usr/*' --output-file coverage.info
lcov --list coverage.info
fi

cd $TOP_DIR
echo "********************"
echo "**** RUNNING UT ENDS ****"
echo "********************"