diff --git a/.github/workflows/cxx-build.yml b/.github/workflows/cxx-build.yml
index b87ed6c6f..31e5b5a2b 100644
--- a/.github/workflows/cxx-build.yml
+++ b/.github/workflows/cxx-build.yml
@@ -11,6 +11,10 @@ on:
- opened
- synchronize
+defaults:
+ run:
+ shell: bash
+
env:
HUSKY: 0
jobs:
@@ -18,16 +22,20 @@ jobs:
name: Build Thunder Libraries
runs-on: ubuntu-latest
container:
- image: kevinshahfws/node-c:3.0
+ image: node:23.3.0
steps:
- - name: Checkout
+ - name: Checkout firebolt-apis
uses: actions/checkout@v2
- name: Clone and Install Thunder
- id: install_thunder
run: |
+ apt update
+ apt install -y cmake ninja-build python3-pip python3.11-venv
+ python3 -m venv firebolt-env
+ source firebolt-env/bin/activate
+ pip install jsonref
.github/workflows/utils.sh cloneAndInstallThunder
-
+
- name: Upload the library artifact
uses: actions/upload-artifact@v3
with:
@@ -36,9 +44,12 @@ jobs:
openrpc:
name: Build Openrpc Artifacts
+ needs: thunder
runs-on: ubuntu-latest
container:
- image: kevinshahfws/node-c:3.0
+ image: node:23.3.0
+ permissions:
+ pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v2
@@ -62,7 +73,7 @@ jobs:
key: deps-node-modules-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
- run: npm ci
+ run: npm install
- name: Set file permissions
run: |
@@ -84,19 +95,19 @@ jobs:
with:
name: manage
path: src/sdks/manage
-
+
- name: Upload Discovery SDK
uses: actions/upload-artifact@v3
with:
name: discovery
- path: src/sdks/discovery
+ path: src/sdks/discovery
core_sdk:
name: Build Core SDK
needs: [thunder, openrpc]
runs-on: ubuntu-latest
container:
- image: kevinshahfws/node-c:3.0
+ image: node:23.3.0
steps:
- name: Checkout
uses: actions/checkout@v2
@@ -107,7 +118,6 @@ jobs:
name: core
path: /__w/firebolt-apis/firebolt-apis/src/sdks/core
-
- name: Download Thunder
uses: actions/download-artifact@v3
with:
@@ -121,27 +131,58 @@ jobs:
key: deps-node-modules-${{ hashFiles('package-lock.json') }}
- name: Install npm dependencies
- run: npm ci
+ run: |
+ apt update
+ apt install -y cmake
+ npm install
- name: Generate core SDK source code
run: |
.github/workflows/utils.sh generate_cpp_core_sdk_source_code
- - name: Build CXX Core SDK
+ - name: Build CXX Core SDK
run: |
+ apt install -y python3-pip python3.11-venv
+ python3 -m venv firebolt-env
+ source firebolt-env/bin/activate
+ pip install gcovr
+
.github/workflows/utils.sh build_core_cpp_sdk
+ - name: Test and Generate coverage report
+ run: .github/workflows/utils.sh generate_core_sdk_coverage_report
+
+ - name: Display coverage report
+ uses: irongut/CodeCoverageSummary@v1.3.0
+ with:
+ filename: coverage/coverage.cobertura.xml
+ badge: true
+ fail_below_min: false
+ format: markdown
+ hide_branch_rate: false
+ hide_complexity: true
+ indicators: true
+ output: both
+ thresholds: '80 40'
+
+ - name: Add coverage PR comment
+ uses: marocchino/sticky-pull-request-comment@v2
+ with:
+ recreate: true
+ path: code-coverage-results.md
+
+
manage_sdk:
name: Build Manage SDK
needs: [thunder, openrpc]
runs-on: ubuntu-latest
container:
- image: kevinshahfws/node-c:3.0
+ image: node:23.3.0
steps:
- name: Checkout
uses: actions/checkout@v2
- - name: Download Manage SDK
+ - name: Download Manage SDK
uses: actions/download-artifact@v3
with:
name: manage
@@ -160,22 +201,52 @@ jobs:
key: deps-node-modules-${{ hashFiles('package-lock.json') }}
- name: Install npm dependencies
- run: npm ci
+ run: |
+ apt update
+ apt install -y cmake
+ npm install
- name: Generate manage SDK source code
run: |
.github/workflows/utils.sh generate_cpp_manage_sdk_source_code
- - name: Build CXX manage SDK
+ - name: Build CXX Manage SDK
run: |
+ apt install -y python3-pip python3.11-venv
+ python3 -m venv firebolt-env
+ source firebolt-env/bin/activate
+ pip install gcovr
+
.github/workflows/utils.sh build_manage_cpp_sdk
- dicovery_sdk:
+ - name: Test and Generate coverage report
+ run: .github/workflows/utils.sh generate_manage_sdk_coverage_report
+
+ - name: Display coverage report
+ uses: irongut/CodeCoverageSummary@v1.3.0
+ with:
+ filename: coverage/coverage.cobertura.xml
+ badge: true
+ fail_below_min: false
+ format: markdown
+ hide_branch_rate: false
+ hide_complexity: true
+ indicators: true
+ output: both
+ thresholds: '80 40'
+
+ - name: Add coverage PR comment
+ uses: marocchino/sticky-pull-request-comment@v2
+ with:
+ recreate: true
+ path: code-coverage-results.md
+
+ discovery_sdk:
name: Build Discovery SDK
needs: [thunder, openrpc]
runs-on: ubuntu-latest
container:
- image: kevinshahfws/node-c:3.0
+ image: node:23.3.0
steps:
- name: Checkout
uses: actions/checkout@v2
@@ -199,12 +270,43 @@ jobs:
key: deps-node-modules-${{ hashFiles('package-lock.json') }}
- name: Install npm dependencies
- run: npm ci
+ run: |
+ apt update
+ apt install -y cmake
+ npm install
- name: Generate discovery SDK source code
run: |
.github/workflows/utils.sh generate_cpp_discovery_sdk_source_code
- - name: Build CXX Discovery SDK
+ - name: Build CXX Discovery SDK
run: |
- .github/workflows/utils.sh build_discovery_cpp_sdk
\ No newline at end of file
+ apt install -y python3-pip python3.11-venv
+ python3 -m venv firebolt-env
+ source firebolt-env/bin/activate
+ pip install gcovr
+
+ .github/workflows/utils.sh build_discovery_cpp_sdk
+
+ - name: Test and Generate coverage report
+ run: .github/workflows/utils.sh generate_discovery_sdk_coverage_report
+
+ - name: Display coverage report
+ uses: irongut/CodeCoverageSummary@v1.3.0
+ with:
+ filename: coverage/coverage.cobertura.xml
+ badge: true
+ fail_below_min: false
+ format: markdown
+ hide_branch_rate: false
+ hide_complexity: true
+ indicators: true
+ output: both
+ thresholds: '80 40'
+
+ - name: Add coverage PR comment
+ uses: marocchino/sticky-pull-request-comment@v2
+ with:
+ recreate: true
+ path: code-coverage-results.md
+
diff --git a/.github/workflows/utils.sh b/.github/workflows/utils.sh
index b385fe38d..c61f3b10f 100755
--- a/.github/workflows/utils.sh
+++ b/.github/workflows/utils.sh
@@ -182,6 +182,8 @@ function unzipArtifact(){
}
function cloneAndInstallThunder() {
+ printenv
+
cd ..
git clone https://github.com/rdkcentral/Thunder.git
@@ -269,12 +271,27 @@ function build_cpp_sdk() {
echo " ************ Build ${sdk_name^} CPP SDK ************"
- cd /__w/firebolt-apis/firebolt-apis/src/sdks/${sdk_name}/build/cpp/src/firebolt-${sdk_name}-native-sdk-${FIREBOLT_VERSION}/
+ tar -xvf /__w/firebolt-apis/firebolt-apis/src/sdks/${sdk_name}/build/cpp/src/firebolt-${sdk_name}-native-sdk-${FIREBOLT_VERSION}.tgz -C /__w/firebolt-apis/firebolt-apis/
+ cd /__w/firebolt-apis/firebolt-apis/firebolt-${sdk_name}-native-sdk-${FIREBOLT_VERSION}
chmod +x ./build.sh
./build.sh -s "/__w/thunder/install/" || exit 9999
}
+
+function generate_coverage_report(){
+ FIREBOLT_VERSION=$(node -p "require('./package.json').version")
+ echo "The version from package.json is $FIREBOLT_VERSION"
+ local sdk_name=$1
+
+ echo " ************ Generate coverage report for ${sdk_name^} CPP SDK ************"
+
+ cd /__w/firebolt-apis/firebolt-apis/firebolt-${sdk_name}-native-sdk-${FIREBOLT_VERSION}
+ cmake --build build --target coverage
+
+ mv /__w/firebolt-apis/firebolt-apis/firebolt-${sdk_name}-native-sdk-${FIREBOLT_VERSION}/build/test/coverage /__w/firebolt-apis/firebolt-apis/
+}
+
# Check argument and call corresponding function
case "$1" in
runTests) runTests ;;
@@ -288,6 +305,9 @@ case "$1" in
build_core_cpp_sdk) build_cpp_sdk "core" ;;
build_manage_cpp_sdk) build_cpp_sdk "manage" ;;
build_discovery_cpp_sdk) build_cpp_sdk "discovery" ;;
+ generate_core_sdk_coverage_report) generate_coverage_report "core" ;;
+ generate_manage_sdk_coverage_report) generate_coverage_report "manage" ;;
+ generate_discovery_sdk_coverage_report) generate_coverage_report "discovery" ;;
*)
echo "Invalid function specified."
exit 1
diff --git a/src/sdks/core/src/cpp/sdk/cpptest/CMakeLists.txt b/src/sdks/core/src/cpp/sdk/cpptest/CMakeLists.txt
index 4b1b6a8f6..7b3ebb13e 100644
--- a/src/sdks/core/src/cpp/sdk/cpptest/CMakeLists.txt
+++ b/src/sdks/core/src/cpp/sdk/cpptest/CMakeLists.txt
@@ -105,6 +105,35 @@ if(ENABLE_UNIT_TESTS)
$
)
+ set_target_properties(${UNIT_TESTS_APP} PROPERTIES
+ CXX_STANDARD 17
+ CXX_STANDARD_REQUIRED YES
+ )
+
include(GoogleTest)
gtest_discover_tests(${UNIT_TESTS_APP})
endif()
+
+if(ENABLE_COVERAGE)
+ include(${CMAKE_SOURCE_DIR}/cmake/CodeCoverage.cmake)
+
+ set(COVERAGE_MAIN "coverage")
+ set(COVERAGE_EXCLUDES
+ "${CMAKE_SOURCE_DIR}/build/*"
+ "${CMAKE_SOURCE_DIR}/cmake/*"
+ "${CMAKE_SOURCE_DIR}/include/*"
+ "${CMAKE_SOURCE_DIR}/test/*"
+ "/usr/include/*")
+
+ set(COVERAGE_EXTRA_FLAGS)
+ set(COVERAGE_DEPENDENCIES ${UNIT_TESTS_APP})
+
+ setup_target_for_coverage_gcovr_html(
+ NAME ${COVERAGE_MAIN}
+ BASE_DIRECTORY ${CMAKE_SOURCE_DIR}
+ EXECUTABLE ctest
+ EXECUTABLE_ARGS "--test-dir ../build/ --output-on-failure"
+ DEPENDENCIES ${COVERAGE_DEPENDENCIES}
+ )
+
+endif()
diff --git a/src/sdks/discovery/src/cpp/sdk/cpptest/CMakeLists.txt b/src/sdks/discovery/src/cpp/sdk/cpptest/CMakeLists.txt
index e2fc88793..52bf0ee1f 100644
--- a/src/sdks/discovery/src/cpp/sdk/cpptest/CMakeLists.txt
+++ b/src/sdks/discovery/src/cpp/sdk/cpptest/CMakeLists.txt
@@ -52,15 +52,21 @@ target_link_libraries(${TESTAPP}
PRIVATE
${NAMESPACE}Core::${NAMESPACE}Core
${FIREBOLT_NAMESPACE}SDK::${FIREBOLT_NAMESPACE}SDK
+ nlohmann_json_schema_validator
+ gtest_main
)
target_include_directories(${TESTAPP}
PRIVATE
- $
- $
- $
+ $
)
+if (POLYMORPHICS_REDUCER_METHODS)
+ target_compile_definitions(${TESTAPP}
+ PUBLIC
+ POLYMORPHICS_REDUCER_METHODS=1)
+endif()
+
set_target_properties(${TESTAPP} PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
diff --git a/src/sdks/manage/src/cpp/sdk/cpptest/CMakeLists.txt b/src/sdks/manage/src/cpp/sdk/cpptest/CMakeLists.txt
index 9ca7094cc..371e3c517 100644
--- a/src/sdks/manage/src/cpp/sdk/cpptest/CMakeLists.txt
+++ b/src/sdks/manage/src/cpp/sdk/cpptest/CMakeLists.txt
@@ -102,6 +102,35 @@ if(ENABLE_UNIT_TESTS)
$
)
+ set_target_properties(${UNIT_TESTS_APP} PROPERTIES
+ CXX_STANDARD 17
+ CXX_STANDARD_REQUIRED YES
+ )
+
include(GoogleTest)
gtest_discover_tests(${UNIT_TESTS_APP})
-endif()
\ No newline at end of file
+endif()
+
+if(ENABLE_COVERAGE)
+ include(${CMAKE_SOURCE_DIR}/cmake/CodeCoverage.cmake)
+
+ set(COVERAGE_MAIN "coverage")
+ set(COVERAGE_EXCLUDES
+ "${CMAKE_SOURCE_DIR}/build/*"
+ "${CMAKE_SOURCE_DIR}/cmake/*"
+ "${CMAKE_SOURCE_DIR}/include/*"
+ "${CMAKE_SOURCE_DIR}/test/*"
+ "/usr/include/*")
+
+ set(COVERAGE_EXTRA_FLAGS)
+ set(COVERAGE_DEPENDENCIES ${UNIT_TESTS_APP})
+
+ setup_target_for_coverage_gcovr_html(
+ NAME ${COVERAGE_MAIN}
+ BASE_DIRECTORY ${CMAKE_SOURCE_DIR}
+ EXECUTABLE ctest
+ EXECUTABLE_ARGS "--test-dir ../build/ --output-on-failure"
+ DEPENDENCIES ${COVERAGE_DEPENDENCIES}
+ )
+
+endif()