Skip to content

Commit

Permalink
feat(core): CI pipeline to build and test CPP SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaKasar committed Oct 8, 2024
1 parent dd5ecc4 commit ad5df08
Show file tree
Hide file tree
Showing 2 changed files with 267 additions and 6 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/cxx-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: CXX build
on:
workflow_dispatch:
push:
branches:
- 'main'
- 'next'

env:
HUSKY: 0
jobs:
release:
name: Release
runs-on: ubuntu-latest
container:
image: kevinshahfws/node-c:3.0
steps:
# Checkout/install project
- name: Checkout
uses: actions/checkout@v2

- name: Install Gcovr
run: |
apt remove --purge gcovr -y
pip install --upgrade gcovr
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 'lts/*'

- name: Install dependencies
run: npm ci

- name: Clone and Install Thunder
id: install_thunder
run: |
.github/workflows/utils.sh cloneAndInstallThunder
- name: Build Artifacts
run: |
npm run dist
- name: Build CXX
run: |
cd src/sdks/core/
ls
npm run cpp
- name: Build SDK
run: |
tar -zxvf src/sdks/core/build/cpp/src/firebolt-core-native-sdk-1.3.0-next.1.tgz -C ../
cd ../firebolt-core-native-sdk-1.3.0-next.1
cp -f ../firebolt-apis/external/CMakeLists.txt ./
cp -f ../firebolt-apis/external/include/json_engine.h ./include/
cp -f ../firebolt-apis/external/src/CMakeLists.txt ./src/
cp -f ../firebolt-apis/external/src/Transport.h ./src/
./build.sh -s ${pwd}/../install
ls build/test/
ctest --test-dir build/
213 changes: 207 additions & 6 deletions .github/workflows/utils.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#!/bin/bash
set -o pipefail

FIREBOLT_VERSION=1.0.0-next.0
current_apis_dir=$(pwd)

cd ..
current_dir=$(pwd)
cd $current_apis_dir

function runTests(){
echo "Clone firebolt-apis repo with pr branch"
PR_BRANCH=$(echo "$EVENT_NAME" | tr '[:upper:]' '[:lower:]')
Expand Down Expand Up @@ -36,12 +43,7 @@ function runTests(){
echo "clone fca repo and start it in the background"
git clone --branch main https://github.com/rdkcentral/firebolt-certification-app.git
cd firebolt-certification-app
echo "Updating Core SDK dependency"
jq '.dependencies["@firebolt-js/sdk"] = "file:../firebolt-apis/src/sdks/core"' package.json > package.json.tmp && mv package.json.tmp package.json
echo "Updating Manage SDK dependency"
jq '.dependencies["@firebolt-js/manage-sdk"] = "file:../firebolt-apis/src/sdks/manage"' package.json > package.json.tmp && mv package.json.tmp package.json
echo "Updating Discovery SDK dependency"
jq '.dependencies["@firebolt-js/discovery-sdk"] = "file:../firebolt-apis/src/sdks/discovery"' package.json > package.json.tmp && mv package.json.tmp package.json
npm install
npm start &
sleep 5s
Expand Down Expand Up @@ -152,15 +154,214 @@ function unzipArtifact(){
echo "Failures=$failures" >> "$GITHUB_ENV"
}

function generateSource() {
echo " ************ Generating CPP SDK Source ************"

echo "Generating source for Core SDK"
cd src/sdks/core
npm run cpp

if [ $? -eq 0 ]
then
echo "Native Core SDK generated successfully"
echo " Core SDK Location"
cd build/cpp/src/
ls -la
echo " ************ Source Generation Completed for Core SDK ************"
else
echo "Native Core SDK generation failed"
exit 1
fi

echo "Generating source for Manage SDK"
cd ../../../../manage
npm run cpp

if [ $? -eq 0 ]
then
echo "Native Manage SDK generated successfully"
echo " Manage SDK Location"
cd build/cpp/src/
ls -la
echo " ************ Source Generation Completed for Manage SDK ************"
else
echo "Native Manage SDK generation failed"
exit 1
fi

echo "Generate source for Discovery SDK"
cd ../discovery
npm run cpp

if [ $? -eq 0 ]
then
echo "Native Discovery SDK generated successfully"
else
echo "Native Discovery SDK generation failed"
exit 1
fi
}

function cloneAndInstallThunder() {
cd ..

git clone https://github.com/rdkcentral/Thunder.git

cd Thunder

git checkout 283b3d54334010403d85a4e69b3835de23e42331

cd ..

git clone https://github.com/rdkcentral/ThunderTools.git

cd ThunderTools

git checkout 64b72b5ed491436b0e6bc2327d8a7b0e75ee2870

cd ..

echo "current_dir is $current_dir"

mkdir -p $current_dir/data

if [ ! -d "$(pwd)/Thunder" ]
then
echo "Directory Thunder DOES NOT exist."
exit 9999
fi

if [ ! -d "$(pwd)/ThunderTools" ]
then
echo "Directory ThunderTools DOES NOT exist."
exit 9999
fi

if [ ! -d "$current_dir/firebolt-apis" ]
then
echo "Directory $current_dir/firebolt-apis DOES NOT exist."
exit 9999
fi

cd $current_dir

[ -d "$current_dir/build" ] && rm -rf $current_dir/build

echo "Building Thunder";

cmake -G Ninja -S ThunderTools -B build/ThunderTools -DCMAKE_INSTALL_PREFIX="install/usr" && echo "Tools Setup" || exit 9999

cmake --build build/ThunderTools --target install && echo "Thunder Tools Build succeeded" || exit 9999

#-G Ninja is the "Build system generator"
#-S is the source path
#-B is the output directory
cmake -G Ninja -S Thunder -B build/Thunder \
-DBUILD_SHARED_LIBS=ON \
-DBINDING="127.0.0.1" \
-DCMAKE_BUILD_TYPE="Debug" \
-DCMAKE_INSTALL_PREFIX="install/usr" \
-DCMAKE_MODULE_PATH="${PWD}/install/usr/include/WPEFramework/Modules" \
-DDATA_PATH="${PWD}/install/usr/share/WPEFramework" \
-DPERSISTENT_PATH="${PWD}/install/var/wpeframework" \
-DPORT="55555" \
-DPROXYSTUB_PATH="${PWD}/install/usr/lib/wpeframework/proxystubs" \
-DSYSTEM_PATH="${PWD}/install/usr/lib/wpeframework/plugins" \
-DVOLATILE_PATH="tmp" && echo "Thunder configure succeeded" || exit 9999

cmake --build build/Thunder --target install && echo "Thunder Build succeeded" || exit 9999
}

function buildCoreCPPSDK() {
echo " ************ Building Core CPP SDK ************"

FIREBOLT_VERSION=$(node -p "require('./package.json').version")
echo "The version from package.json is $FIREBOLT_VERSION"

cd src/sdks/core
ls -la build/cpp/src
cp build/cpp/src/firebolt-core-native-sdk-${FIREBOLT_VERSION}.tgz $current_dir/data
cd $current_dir/data
tar -zxvf firebolt-core-native-sdk-${FIREBOLT_VERSION}.tgz
cd firebolt-core-native-sdk-${FIREBOLT_VERSION}/
chmod +x ./build.sh
sed -i -e 's/prefix=/prefix /g' build.sh
cat ./build.sh

echo "***************** firebolt.h *****************"
cat include/firebolt.h

./build.sh -s "$current_dir/install" || exit 9999
./build.sh -f "$current_dir/data/firebolt-core-native-sdk-${FIREBOLT_VERSION}/build/Firebolt" -s "$current_dir/install"

cd $current_apis_dir
}

function buildManageCPPSDK() {
echo " ************ Build Manage CPP SDK ************"
FIREBOLT_VERSION=$(node -p "require('./package.json').version")
echo "The version from package.json is $FIREBOLT_VERSION"

cd $current_apis_dir
cd src/sdks/manage
ls -la build/cpp/src
cp build/cpp/src/firebolt-manage-native-sdk-${FIREBOLT_VERSION}.tgz $current_dir/data
cd $current_dir/data
tar -zxvf firebolt-manage-native-sdk-${FIREBOLT_VERSION}.tgz
cd firebolt-manage-native-sdk-${FIREBOLT_VERSION}/
chmod +x ./build.sh
sed -i -e 's/prefix=/prefix /g' build.sh
cat ./build.sh

echo "***************** firebolt.h *****************"
cat include/firebolt.h

./build.sh -s "$current_dir/install" || exit 9999
./build.sh -f "$current_dir/data/firebolt-manage-native-sdk-${FIREBOLT_VERSION}/build/Firebolt" -s "$current_dir/install"
}

function buildDiscoveryCPPSDK() {
echo " ************ Build Discovery CPP SDK ************"
FIREBOLT_VERSION=$(node -p "require('./package.json').version")
echo "The version from package.json is $FIREBOLT_VERSION"

cd $current_apis_dir
cd src/sdks/discovery
ls -la build/cpp/src
cp build/cpp/src/firebolt-discovery-native-sdk-${FIREBOLT_VERSION}.tgz $current_dir/data
cd $current_dir/data
tar -zxvf firebolt-discovery-native-sdk-${FIREBOLT_VERSION}.tgz
cd firebolt-discovery-native-sdk-${FIREBOLT_VERSION}/
chmod +x ./build.sh
sed -i -e 's/prefix=/prefix /g' build.sh
cat ./build.sh

echo "***************** firebolt.h *****************"
cat include/firebolt.h

./build.sh -s "$current_dir/install" || exit 9999
./build.sh -f "$current_dir/data/firebolt-discovery-native-sdk-${FIREBOLT_VERSION}/build/Firebolt" -s "$current_dir/install"
}

# Check argument and call corresponding function
if [ "$1" == "runTests" ]; then
runTests
runTests
elif [ "$1" == "getResults" ]; then
getResults
elif [ "$1" == "getArtifactData" ]; then
getArtifactData
elif [ "$1" == "unzipArtifact" ]; then
unzipArtifact
elif [ "$1" == "generateSource" ]; then
generateSource
elif [ "$1" == "cloneAndInstallThunder" ]; then
cloneAndInstallThunder
elif [ "$1" == "buildCoreCPPSDK" ]; then
buildCoreCPPSDK
elif [ "$1" == "buildManageCPPSDK" ]; then
buildManageCPPSDK
elif [ "$1" == "buildDiscoveryCPPSDK" ]; then
buildDiscoveryCPPSDK
else
echo "Invalid function specified."
exit 1
Expand Down

0 comments on commit ad5df08

Please sign in to comment.