Skip to content

Commit

Permalink
refactor: CI pipeline to build CPP SDKs
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaKasar committed Oct 15, 2024
1 parent e1f846a commit 382b02d
Show file tree
Hide file tree
Showing 2 changed files with 300 additions and 6 deletions.
194 changes: 194 additions & 0 deletions .github/workflows/cxx-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
name: CXX build
on:
workflow_dispatch:
pull_request:
branches:
- 'main'
- 'next'
types:
- opened

env:
HUSKY: 0
jobs:
thunder:
name: Build Thunder Libraries
runs-on: ubuntu-latest
container:
image: kevinshahfws/node-c:3.0
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Clone and Install Thunder
id: install_thunder
run: |
.github/workflows/utils.sh cloneAndInstallThunder
- name: Upload the library artifact
uses: actions/upload-artifact@v3
with:
name: thunder
path: /__w/firebolt-apis/install/

openrpc:
name: Build Openrpc Artifacts
runs-on: ubuntu-latest
container:
image: kevinshahfws/node-c:3.0
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
repo-token: ${{ secrets.SEMANTIC_RELEASE_BOT_PAT }}
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 'lts/*'
- name: Set up NPM token
env:
NPM_TOKEN: ${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }}
run: 'echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc'

- name: Cache npm dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: deps-node-modules-${{ hashFiles('package-lock.json') }}

- name: Install dependencies
run: npm ci

- name: Set file permissions
run: |
chmod -R 755 ./
chown -R $(id -u):$(id -g) ./
- name: Build Artifacts
run: |
npm run dist
- name: Upload Core SDK
uses: actions/upload-artifact@v3
with:
name: core-sdk
path: |
package.json
package-lock.json
dist
src/sdks/core
- name: Upload Manage SDK
uses: actions/upload-artifact@v3
with:
name: manage-sdk
path: |
package.json
package-lock.json
dist
src/sdks/manage
- name: Upload Discovery SDK
uses: actions/upload-artifact@v3
with:
name: discovery-sdk
path: |
package.json
package-lock.json
dist
src/sdks/discovery
core_sdk:
name: Build Core SDK
needs: [thunder, openrpc]
runs-on: ubuntu-latest
container:
image: kevinshahfws/node-c:3.0
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Download Core SDK
uses: actions/download-artifact@v3
with:
name: core-sdk
path: /__w/core-sdk/

- name: Download Thunder
uses: actions/download-artifact@v3
with:
name: thunder
path: /__w/thunder/install/

- name: Install npm dependencies
run: |
cd /__w/core-sdk/
npm ci
- name: Build CXX Core SDK
run: |
.github/workflows/utils.sh buildCoreCPPSDK
manage_sdk:
name: Build Manage SDK
needs: [thunder, openrpc]
runs-on: ubuntu-latest
container:
image: kevinshahfws/node-c:3.0
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Download Manage SDK
uses: actions/download-artifact@v3
with:
name: manage-sdk
path: /__w/manage-sdk/

- name: Download Thunder
uses: actions/download-artifact@v3
with:
name: thunder
path: /__w/thunder/install/

- name: Install npm dependencies
run: |
cd /__w/manage-sdk/
npm ci
- name: Build CXX manage SDK
run: |
.github/workflows/utils.sh buildManageCPPSDK
dicovery_sdk:
name: Build Discovery SDK
needs: [thunder, openrpc]
runs-on: ubuntu-latest
container:
image: kevinshahfws/node-c:3.0
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Download Discovery SDK
uses: actions/download-artifact@v3
with:
name: discovery-sdk
path: /__w/discovery-sdk/

- name: Download Thunder
uses: actions/download-artifact@v3
with:
name: thunder
path: /__w/thunder/install/

- name: Install npm dependencies
run: |
cd /__w/discovery-sdk/
npm ci
- name: Build CXX Discovery SDK
run: |
.github/workflows/utils.sh buildDiscoveryCPPSDK
112 changes: 106 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,113 @@ function unzipArtifact(){
echo "Failures=$failures" >> "$GITHUB_ENV"
}

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 buildCPPSDK() {
local sdk_name=$1

echo " ************ Build ${sdk_name^} CPP SDK ************"

FIREBOLT_VERSION=1.3.0-next.1
cd /__w/${sdk_name}-sdk/src/sdks/${sdk_name}/
npm run cpp

mkdir -p /__w/${sdk_name}-sdk/data
tar -zxvf build/cpp/src/firebolt-${sdk_name}-native-sdk-${FIREBOLT_VERSION}.tgz -C /__w/${sdk_name}-sdk/data
cd /__w/${sdk_name}-sdk/data/firebolt-${sdk_name}-native-sdk-${FIREBOLT_VERSION}/
chmod +x ./build.sh
sed -i -e 's/prefix=/prefix /g' build.sh

./build.sh -s "/__w/thunder/install/" || exit 9999
}

# 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
buildCPPSDK "core"
elif [ "$1" == "buildManageCPPSDK" ]; then
buildCPPSDK "manage"
elif [ "$1" == "buildDiscoveryCPPSDK" ]; then
buildCPPSDK "discovery"
else
echo "Invalid function specified."
exit 1
Expand Down

0 comments on commit 382b02d

Please sign in to comment.