diff --git a/.github/workflows/L1-tests.yml b/.github/workflows/L1-tests.yml index 4777b646..139bcdc9 100644 --- a/.github/workflows/L1-tests.yml +++ b/.github/workflows/L1-tests.yml @@ -31,24 +31,60 @@ jobs: run: | docker run -d --name native-platform -v ${{ github.workspace }}:/mnt/L1_CONTAINER_SHARED_VOLUME ghcr.io/rdkcentral/docker-device-mgt-service-test/native-platform:latest - - name: Run L1 Unit Tests inside container - run: docker exec -i native-platform /bin/bash -c "cd /mnt/L1_CONTAINER_SHARED_VOLUME/ && sh test/run_ut.sh" + - name: Run L1 Unit Tests inside container with coverage flags enabled + run: docker exec -i native-platform /bin/bash -c "cd /mnt/L1_CONTAINER_SHARED_VOLUME/ && sh test/run_ut.sh --enable-cov && lcov --list coverage.info > /tmp/coverage_summary.txt" + + - name: Copy coverage summary to runner + run: docker cp native-platform:/tmp/coverage_summary.txt /tmp/ - name: Copy L1 test results to runner run: | docker cp native-platform:/tmp/Gtest_Report /tmp/Gtest_Report ls -l /tmp/Gtest_Report + - 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: Upload test results as artifact + uses: actions/upload-artifact@v4 + with: + name: gtest-results + path: /tmp/Gtest_Report + retention-days: 1 + upload-test-results: name: Upload L1 test results to automatic test result management system needs: execute-L1-tests-on-pr runs-on: ubuntu-latest container: image: ghcr.io/rdkcentral/docker-rdk-ci:latest - volumes: - - /tmp/Gtest_Report:/tmp/Gtest_Report steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Download test results + uses: actions/download-artifact@v4 + with: + name: gtest-results + path: /tmp/Gtest_Report + - name: Upload results if: github.repository_owner == 'rdkcentral' env: diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 5ad3ac07..5d65271c 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -2,7 +2,7 @@ name: Code Coverage on: pull_request: - branches: [ main] + branches: [ main ] env: AUTOMATICS_UNAME: ${{ secrets.AUTOMATICS_UNAME }} @@ -32,7 +32,7 @@ jobs: docker run -d --name native-platform -v ${{ github.workspace }}:/mnt/L1_CONTAINER_SHARED_VOLUME ghcr.io/rdkcentral/docker-device-mgt-service-test/native-platform:latest - name: Run unit tests with coverage flags enabled and Caculate the code coverage summary - run: docker exec -i native-platform /bin/bash -c "cd /mnt/L1_CONTAINER_SHARED_VOLUME/ && sh test/run_ut.sh --enable-cov && lcov --list coverage.info | grep 'Lines\|Total' > /tmp/coverage_summary.txt" + run: docker exec -i native-platform /bin/bash -c "cd /mnt/L1_CONTAINER_SHARED_VOLUME/ && sh test/run_ut.sh --enable-cov && lcov --list coverage.info > /tmp/coverage_summary.txt" - name: Copy coverage summary to runner run: docker cp native-platform:/tmp/coverage_summary.txt /tmp/ diff --git a/test/run_ut.sh b/test/run_ut.sh index 363bbb15..795b24a4 100755 --- a/test/run_ut.sh +++ b/test/run_ut.sh @@ -44,6 +44,9 @@ autoreconf --install make -C source/test +# Create test results directory +mkdir -p /tmp/Gtest_Report + # List of 13 test binaries to run tests=" ./source/test/bulkdata/profile_gtest.bin