Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RDK-46982] Integrate L1/L2 test cases with CI/CD pipeline - Container #346

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
237 changes: 128 additions & 109 deletions .github/workflows/L1-tests.yml
Original file line number Diff line number Diff line change
@@ -1,109 +1,128 @@
name: DobbyL1Test
on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
env:
# For CI, build all optional plugins. Newly developed plugins should be added to this list
optional_plugins: "-DPLUGIN_TESTPLUGIN=ON -DPLUGIN_GPU=ON -DPLUGIN_LOCALTIME=ON -DPLUGIN_RTSCHEDULING=ON -DPLUGIN_HTTPPROXY=ON -DPLUGIN_APPSERVICES=ON -DPLUGIN_IONMEMORY=ON -DPLUGIN_DEVICEMAPPER=ON -DPLUGIN_OOMCRASH=ON"
optional_flags: "-DLEGACY_COMPONENTS=ON -DRDK=ON -DUSE_SYSTEMD=ON -DDOBBY_HIBERNATE_MEMCR_IMPL=ON"
strategy:
fail-fast: false
matrix:
compiler: [ gcc, clang ]
coverage: [ with-coverage, without-coverage ]
exclude:
- compiler: clang
coverage: with-coverage
- compiler: clang
coverage: without-coverage
- compiler: gcc
coverage: without-coverage
# The matrix will try all possible combinations of the below arrays
# If adding a new cmake option, include both the ON and OFF version to ensure the
# If adding a RUN_TESTS cmake option, it will build with enabling optional_flags and run the L1 tests
# matrix runs both versions
build_type: ["Release", "Debug"]
extra_flags: [ "RUN_TESTS", "-DLEGACY_COMPONENTS=ON", "-DLEGACY_COMPONENTS=OFF", "-DUSE_SYSTEMD=ON", "-DUSE_SYSTEMD=OFF", "-DDOBBY_HIBERNATE_MEMCR_IMPL=ON", "-DDOBBY_HIBERNATE_MEMCR_IMPL=OFF"]
name: Build in ${{ matrix.build_type }} Mode (${{ matrix.extra_flags }})
steps:
- name: checkout
uses: actions/checkout@v4

- name: install-dependencies
run: |
sudo apt-get update -y -q
sudo apt-get install -q -y automake libtool autotools-dev software-properties-common build-essential cmake libsystemd-dev libctemplate-dev libjsoncpp-dev libdbus-1-dev libnl-3-dev libnl-route-3-dev libsystemd-dev libyajl-dev libcap-dev libboost-dev lcov clang valgrind
sudo pip3 install xmltodict
sudo pip3 install requests

- name: Set clang toolchain
if: ${{ matrix.compiler == 'clang' }}
run: echo "TOOLCHAIN_FILE=${GITHUB_WORKSPACE}/tests/clang.cmake" >> $GITHUB_ENV

- name: Set gcc/with-coverage toolchain
if: ${{ matrix.compiler == 'gcc' && matrix.coverage == 'with-coverage' }}
run: echo "TOOLCHAIN_FILE=${GITHUB_WORKSPACE}/tests/gcc-with-coverage.cmake" >> $GITHUB_ENV

- name: Install gmock
run: |
cd $GITHUB_WORKSPACE
git clone https://github.com/google/googletest.git -b release-1.11.0
cd googletest
mkdir build
cd build
cmake ..
make
sudo make install

- name: build dobby
run: |
cd $GITHUB_WORKSPACE
mkdir build
cd build
if [ ${{ matrix.extra_flags }} = "RUN_TESTS" ]
then
cmake -DCMAKE_TOOLCHAIN_FILE="${{ env.TOOLCHAIN_FILE }}" -DRDK_PLATFORM=DEV_VM -DCMAKE_INSTALL_PREFIX:PATH=/usr -DENABLE_DOBBYL1TEST=ON -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} ${{ env.optional_flags }} ${{ env.optional_plugins }} ..
else
cmake -DCMAKE_TOOLCHAIN_FILE="${{ env.TOOLCHAIN_FILE }}" -DRDK_PLATFORM=DEV_VM -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} ${{ matrix.extra_flags }} ${{ env.optional_plugins }} ..
fi
make -j $(nproc)

- name: run l1-tests
if: ${{ matrix.extra_flags == 'RUN_TESTS' && matrix.build_type == 'Debug' }}
run: |
sudo valgrind --tool=memcheck --leak-check=yes --show-reachable=yes --track-fds=yes --fair-sched=try $GITHUB_WORKSPACE/build/tests/L1_testing/tests/DobbyTest/DobbyL1Test --gtest_output="json:$(pwd)/DobbyL1TestResults.json"
sudo $GITHUB_WORKSPACE/build/tests/L1_testing/tests/DobbyUtilsTest/DobbyUtilsL1Test --gtest_output="json:$(pwd)/DobbyUtilsL1TestResults.json"
sudo valgrind --tool=memcheck --leak-check=yes --show-reachable=yes --track-fds=yes --fair-sched=try $GITHUB_WORKSPACE/build/tests/L1_testing/tests/DobbyManagerTest/DobbyManagerL1Test --gtest_output="json:$(pwd)/DobbyManagerL1TestResults.json"

- name: Generate coverage
if: ${{ matrix.coverage == 'with-coverage' && matrix.extra_flags == 'RUN_TESTS' && matrix.build_type == 'Debug' }}
run: >
lcov -c
-o coverage.info
-d $GITHUB_WORKSPACE
&&
lcov
-r coverage.info
'11/*'
'/usr/include/*'
'*/tests/L1_testing/tests/*'
-o filtered_coverage.info
&&
genhtml
-o coverage/${{ matrix.build_type }}/${{ matrix.extra_flags }}/coverage
-t "dobby coverage"
filtered_coverage.info

- name: Upload artifacts
if: ${{ !env.ACT && matrix.coverage == 'with-coverage' && matrix.extra_flags == 'RUN_TESTS' && matrix.build_type == 'Debug' }}
uses: actions/upload-artifact@v4
with:
name: artifacts
path: |
DobbyL1TestResults.json
DobbyUtilsL1TestResults.json
DobbyManagerL1TestResults.json
coverage
if-no-files-found: warn
name: DobbyL1Test
on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
env:
# For CI, build all optional plugins. Newly developed plugins should be added to this list
optional_plugins: "-DPLUGIN_TESTPLUGIN=ON -DPLUGIN_GPU=ON -DPLUGIN_LOCALTIME=ON -DPLUGIN_RTSCHEDULING=ON -DPLUGIN_HTTPPROXY=ON -DPLUGIN_APPSERVICES=ON -DPLUGIN_IONMEMORY=ON -DPLUGIN_DEVICEMAPPER=ON -DPLUGIN_OOMCRASH=ON"
optional_flags: "-DLEGACY_COMPONENTS=ON -DRDK=ON -DUSE_SYSTEMD=ON -DDOBBY_HIBERNATE_MEMCR_IMPL=ON"
AUTOMATICS_UNAME: ${{ secrets.AUTOMATICS_UNAME}}
AUTOMATICS_PASSCODE: ${{ secrets. AUTOMATICS_PASSCODE}}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

strategy:
fail-fast: false
matrix:
compiler: [ gcc, clang ]
coverage: [ with-coverage, without-coverage ]
exclude:
- compiler: clang
coverage: with-coverage
- compiler: clang
coverage: without-coverage
- compiler: gcc
coverage: without-coverage
# The matrix will try all possible combinations of the below arrays
# If adding a new cmake option, include both the ON and OFF version to ensure the
# If adding a RUN_TESTS cmake option, it will build with enabling optional_flags and run the L1 tests
# matrix runs both versions
build_type: ["Release", "Debug"]
extra_flags: [ "RUN_TESTS", "-DLEGACY_COMPONENTS=ON", "-DLEGACY_COMPONENTS=OFF", "-DUSE_SYSTEMD=ON", "-DUSE_SYSTEMD=OFF", "-DDOBBY_HIBERNATE_MEMCR_IMPL=ON", "-DDOBBY_HIBERNATE_MEMCR_IMPL=OFF"]

name: Build in ${{ matrix.build_type }} Mode (${{ matrix.extra_flags }})
steps:
- name: checkout
uses: actions/checkout@v4

- name: install-dependencies
run: |
sudo apt-get update -y -q
sudo apt-get install -q -y automake libtool autotools-dev software-properties-common build-essential cmake libsystemd-dev libctemplate-dev libjsoncpp-dev libdbus-1-dev libnl-3-dev libnl-route-3-dev libsystemd-dev libyajl-dev libcap-dev libboost-dev lcov clang valgrind
sudo pip3 install xmltodict
sudo pip3 install requests

- name: Set clang toolchain
if: ${{ matrix.compiler == 'clang' }}
run: echo "TOOLCHAIN_FILE=${GITHUB_WORKSPACE}/tests/clang.cmake" >> $GITHUB_ENV

- name: Set gcc/with-coverage toolchain
if: ${{ matrix.compiler == 'gcc' && matrix.coverage == 'with-coverage' }}
run: echo "TOOLCHAIN_FILE=${GITHUB_WORKSPACE}/tests/gcc-with-coverage.cmake" >> $GITHUB_ENV

- name: Install gmock
run: |
cd $GITHUB_WORKSPACE
git clone https://github.com/google/googletest.git -b release-1.11.0
cd googletest
mkdir build
cd build
cmake ..
make
sudo make install

- name: Checkout docker-rdk-ci
run: |
cd $GITHUB_WORKSPACE
git clone https://github.com/rdkcentral/docker-rdk-ci

- name: build dobby
run: |
cd $GITHUB_WORKSPACE
mkdir build
cd build
if [ ${{ matrix.extra_flags }} = "RUN_TESTS" ]
then
cmake -DCMAKE_TOOLCHAIN_FILE="${{ env.TOOLCHAIN_FILE }}" -DRDK_PLATFORM=DEV_VM -DCMAKE_INSTALL_PREFIX:PATH=/usr -DENABLE_DOBBYL1TEST=ON -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} ${{ env.optional_flags }} ${{ env.optional_plugins }} ..
else
cmake -DCMAKE_TOOLCHAIN_FILE="${{ env.TOOLCHAIN_FILE }}" -DRDK_PLATFORM=DEV_VM -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} ${{ matrix.extra_flags }} ${{ env.optional_plugins }} ..
fi
make -j $(nproc)

- name: run l1-tests
if: ${{ matrix.extra_flags == 'RUN_TESTS' && matrix.build_type == 'Debug' }}
run: |
mkdir -p /tmp/Gtest_Report/
sudo valgrind --tool=memcheck --leak-check=yes --show-reachable=yes --track-fds=yes --fair-sched=try $GITHUB_WORKSPACE/build/tests/L1_testing/tests/DobbyTest/DobbyL1Test --gtest_output="json:/tmp/Gtest_Report/DobbyL1TestResults.json"
sudo $GITHUB_WORKSPACE/build/tests/L1_testing/tests/DobbyUtilsTest/DobbyUtilsL1Test --gtest_output="json:/tmp/Gtest_Report/DobbyUtilsL1TestResults.json"
sudo valgrind --tool=memcheck --leak-check=yes --show-reachable=yes --track-fds=yes --fair-sched=try $GITHUB_WORKSPACE/build/tests/L1_testing/tests/DobbyManagerTest/DobbyManagerL1Test --gtest_output="json:/tmp/Gtest_Report/DobbyManagerL1TestResults.json"

- name: Generate coverage
if: ${{ matrix.coverage == 'with-coverage' && matrix.extra_flags == 'RUN_TESTS' && matrix.build_type == 'Debug' }}
run: >
lcov -c
-o coverage.info
-d $GITHUB_WORKSPACE
&&
lcov
-r coverage.info
'11/*'
'/usr/include/*'
'*/tests/L1_testing/tests/*'
-o filtered_coverage.info
&&
genhtml
-o coverage/${{ matrix.build_type }}/${{ matrix.extra_flags }}/coverage
-t "dobby coverage"
filtered_coverage.info

- name: Upload artifacts
if: ${{ !env.ACT && matrix.coverage == 'with-coverage' && matrix.extra_flags == 'RUN_TESTS' && matrix.build_type == 'Debug' }}
uses: actions/upload-artifact@v4
with:
name: artifacts
path: |
coverage
/tmp/Gtest_Report/DobbyL1TestResults.json
/tmp/Gtest_Report/DobbyUtilsL1TestResults.json
/tmp/Gtest_Report/DobbyManagerL1TestResults.json
if-no-files-found: warn

- name: Publishing the artifacts to automatics
if: ${{ matrix.extra_flags == 'RUN_TESTS' && matrix.build_type == 'Debug' }}
run: >
export http_proxy=http://96.102.165.62:80 &&
export https_proxy=http://96.102.165.62:80 &&
git config --global --add safe.directory $GITHUB_WORKSPACE &&
$GITHUB_WORKSPACE/docker-rdk-ci/gtest-json-result-push.py /tmp/Gtest_Report/ http://rdkeorchestrationservice.apps.cloud.comcast.net/rdke_orchestration_api/push_unit_test_results $GITHUB_WORKSPACE
Loading