Skip to content

Commit

Permalink
Merge pull request #502 from Sunbird-Knowlg/release-5.1.0
Browse files Browse the repository at this point in the history
Merge Release 5.1.0 into Master
  • Loading branch information
pallakartheekreddy authored Sep 11, 2023
2 parents 9fc06f8 + e4a020d commit 7aa6fd8
Show file tree
Hide file tree
Showing 655 changed files with 226,563 additions and 52,627 deletions.
69 changes: 41 additions & 28 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,55 @@ jobs:
build:
working_directory: ~/content-player/player
docker:
- image: circleci/node:6.10-browsers
environment:
player_version_number: $CIRCLE_BRANCH
build_number: $CIRCLE_BUILD_NUM
filter_plugins: false

- image: circleci/node:12.0.0
steps:
- checkout:
path: ~/content-player
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}

- run:
name: clone plugins
command: |
prnumber=$(echo $CI_PULL_REQUEST | awk -F'/' '{print $NF}')
prdata=$(curl -X GET -u $GITHUB_USER_TOKEN:x-oauth-basic https://api.github.com/repos/project-sunbird/sunbird-content-player/pulls/$prnumber)
target_branch=$(echo "${prdata}" | jq -r '.base.ref')
git clone https://github.com/project-sunbird/sunbird-content-plugins.git plugins -b $target_branch
#- run: git clone https://github.com/project-sunbird/sunbird-content-plugins.git plugins -b $CIRCLE_BRANCH
- run: sudo npm install -g [email protected] codacy-coverage

- run: sudo npm install -g [email protected]
- run: git config --global url."https://".insteadOf git://
- run: npm install
- run: npm run build-preview ekstep
- run: grunt compress:preview
- run: grunt generate-libs
- run: grunt build-jsdoc

#- store_artifacts:
#path: /tmp
#destination:

- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths: ./node_modules
# - run: grunt build-jsdoc

#
# - run:
# name: running test cases
# command: npm run test-player

- run:
name: Install NVM
command: 'curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh|bash'

- run:
name: alter node version
command: 'source ~/.nvm/nvm.sh && nvm install 8 && nvm use 8 && nvm alias default 8 && node -v'

- run:
name: Install sonar scanner
command: 'source ~/.nvm/nvm.sh && sudo npm install -g sonarqube-scanner'

- run:
name: Sonar scanner
command: source ~/.nvm/nvm.sh |
sonar-scanner -Dsonar.projectKey=project-sunbird_sunbird-content-player -Dsonar.organization=project-sunbird -Dsonar.sources=. -Dsonar.host.url=https://sonarcloud.io -Dsonar.language=js

- run:
name: Publish to NPM
command: |
if [ -z $CIRCLE_PR_NUMBER ]; then
commit_hash=$(echo $CIRCLE_SHA1 | cut -c 1-7)
npm version prerelease --preid=alpha-${commit_hash}
npm run build-npm-package
npm set //registry.npmjs.org/:_authToken=$NPM_TOKEN
npm pack ./www/preview
npm publish project-sunbird-content-player-*
else
npm run build-npm-package
fi
workflows:
version: 2.1
build_and_test:
Expand Down
70 changes: 70 additions & 0 deletions .github/workflows/functionaltest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Github action configuration runs functional test cases and generate artifact's
# Author: Rahul Shukla <[email protected]>


name: Sunbird-Content-Player-Functional-Test

# Trigger the workflow on push or pull request
on: [push, pull_request]
jobs:
build:
runs-on: macOS-latest
strategy:
matrix:
node-version: [10.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Install player dependencies
run: |
(git config --global url."https://".insteadOf git:// && cd player && npm install && npm install -g forever)
# - name: Build player preview
# run: |
# (cd player && npm run package-coreplugins -- --env.channel=sunbird && npm run build-preview sunbird)

- name: Start player with fixture stories
run: |
(cd player && forever start app.js)

- name: Install test framework dependencies
run: |
(cd player/public/test/functional_test && yarn install)
- name: Start functional test cases
run: |
(cd player/public/test/functional_test && yarn test)
# - name: Visual regression artifact generation
# uses: actions/upload-artifact@v1
# with:
# name: Visual changes on UI
# path: player/public/test/functional_test/__tests__/__image_snapshots__

# - name: Screenshots artifact generation
# uses: actions/upload-artifact@v1
# with:
# name: Screenshots
# path: player/public/test/functional_test/__tests__/screenshots

- name: Report artifact generation
uses: actions/upload-artifact@v1
with:
name: Report HTML
path: player/public/test/functional_test/testReport

# - name: Player preview artifact generation
# uses: actions/upload-artifact@v1
# with:
# name: Generated Player preview
# path: player/www

env:
CI: true

34 changes: 11 additions & 23 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,23 @@ node() {
ansiColor('xterm') {
stage('Checkout') {
cleanWs()
if (params.github_release_tag == "") {
checkout scm
commit_hash = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
branch_name = sh(script: 'git name-rev --name-only HEAD | rev | cut -d "/" -f1| rev', returnStdout: true).trim()
artifact_version = branch_name + "_" + commit_hash
println(ANSI_BOLD + ANSI_YELLOW + "github_release_tag not specified, using the latest commit hash: " + commit_hash + ANSI_NORMAL)
} else {
def scmVars = checkout scm
checkout scm: [$class: 'GitSCM', branches: [[name: "refs/tags/${params.github_release_tag}"]], userRemoteConfigs: [[url: scmVars.GIT_URL]]]
artifact_version = params.github_release_tag
commit_hash = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
branch_name = params.github_release_tag
println(ANSI_BOLD + ANSI_YELLOW + "github_release_tag specified, building from github_release_tag: " + params.github_release_tag + ANSI_NORMAL)
sh "git clone https://github.com/project-sunbird/sunbird-content-plugins.git plugins"
sh """
cd plugins
checkout_tag=\$(git ls-remote --tags origin release-* | grep -o 'release-.*' | sort -V | tail -n1)
git checkout tags/\${checkout_tag} -b \${checkout_tag}
"""
}
checkout scm
commit_hash = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
branch_name = sh(script: 'git name-rev --name-only HEAD | rev | cut -d "/" -f1| rev', returnStdout: true).trim()
artifact_version = sh(script: "echo " + params.github_release_tag.split('/')[-1] + "_" + commit_hash + "_" + env.BUILD_NUMBER, returnStdout: true).trim()
echo "artifact_version: " + artifact_version

stage('Build') {
sh """
#s3 preview deployment
sh """#!/bin/bash
export NVM_DIR="\$HOME/.nvm"
[ -s "\$NVM_DIR/nvm.sh" ] && source "\$NVM_DIR/nvm.sh" # This loads nvm
[ -s "\$NVM_DIR/bash_completion" ] && source "\$NVM_DIR/bash_completion" # This loads nvm bash_completion
nvm install 10.16.3
export player_version_number=${branch_name}
export build_number=${commit_hash}
export filter_plugins=false # For the preview build generation dont split the plugins.
git config --global url."https://".insteadOf git://
sudo npm i -g grunt
cd player
npm install
npm run build-preview ekstep
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ var previewObj = {

},
"config": {
"whiteListUrl": ["contentProviderPath"], // The URLs that passed as this config only will allow from player, other URLs will be blocked. eg. 'https://obj.stage.sunbirded.org/**', 'https://*.blob.core.windows.net/**' etc.
"repos": ["s3path"], // plugins repo path where all the plugins are pushed s3 or absolute folder path
"plugins": [{ id: "org.sunbird.telemtryPlugin", "ver": "1.0", "type": "plugin" }], //Inject external custom plugins into content (for externl telemetry sync)
"overlay": { // Configuarable propeties of overlay showing by GenieCanvas on top of the content
Expand Down Expand Up @@ -118,6 +119,7 @@ var previewObj = {
| `context` | It is an `object` it contains the `uid`,`did`,`sid`,`mode` etc., these will be logged inside the telemetry | ```{}``` |
| `config` | It is an `object` it contains the `repo`,`plugins`,`overlay`,`splash` etc., these will be used to configure the canvas | ```{}```
| `apislug` | It is `string` which defines proxy setup to make a api request | ```/action```
| `whiteListUrl`| It is an `Array` which defines whiteList URLs which should allows from player| ```['self']```


1. **How to render in Web**
Expand Down
66 changes: 66 additions & 0 deletions auto_build_deploy
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
@Library('deploy-conf') _
node() {
try {
String ANSI_GREEN = "\u001B[32m"
String ANSI_NORMAL = "\u001B[0m"
String ANSI_BOLD = "\u001B[1m"
String ANSI_RED = "\u001B[31m"
String ANSI_YELLOW = "\u001B[33m"

ansiColor('xterm') {
stage('Checkout') {
tag_name = env.JOB_NAME.split("/")[-1]
pre_checks()
cleanWs()
def scmVars = checkout scm
checkout scm: [$class: 'GitSCM', branches: [[name: "refs/tags/$tag_name"]], userRemoteConfigs: [[url: scmVars.GIT_URL]]]
commit_hash = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
artifact_version = tag_name
branch_name = tag_name.split('_')[0].split('\\.')[0] + "." + tag_name.split('_')[0].split('\\.')[1]
}
echo "artifact_version: " + artifact_version

// stage Build
sh """#!/bin/bash
export NVM_DIR="\$HOME/.nvm"
[ -s "\$NVM_DIR/nvm.sh" ] && source "\$NVM_DIR/nvm.sh" # This loads nvm
[ -s "\$NVM_DIR/bash_completion" ] && source "\$NVM_DIR/bash_completion" # This loads nvm bash_completion
nvm install 10.16.3
export player_version_number=${branch_name}
export build_number=${commit_hash}
export filter_plugins=false # For the preview build generation dont split the plugins.
cd player
npm install
npm run build-preview ekstep
grunt compress:preview
grunt generate-libs
#grunt renderer-test
#grunt build-jsdoc
"""

// stage ArchiveArtifacts
sh """
mkdir CR_Preview_Artifacts
cp player/preview.zip CR_Preview_Artifacts
#cp player/libs.zip CR_Preview_Artifacts
zip -j CR_Preview_Artifacts.zip:${artifact_version} CR_Preview_Artifacts/*
"""
archiveArtifacts "CR_Preview_Artifacts.zip:${artifact_version}"
sh """echo {\\"artifact_name\\" : \\"CR_Preview_Artifacts.zip\\", \\"artifact_version\\" : \\"${artifact_version}\\", \\"node_name\\" : \\"${env.NODE_NAME}\\"} > metadata.json"""
archiveArtifacts artifacts: 'metadata.json', onlyIfSuccessful: true
currentBuild.description = "${artifact_version}"

}
currentBuild.result = "SUCCESS"
slack_notify(currentBuild.result, tag_name)
email_notify()
auto_build_deploy()
}
catch (err) {
currentBuild.result = "FAILURE"
slack_notify(currentBuild.result, tag_name)
email_notify()
throw err
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ public boolean execute(final String action, JSONArray args, CallbackContext call
} else if(action.equals("getRelevantContent")) {
String request = args.getString(0);
contentService.getRelevantContent(request, new GenieServicesResponse(callbackContext));
} else if(action.equals("checkMaxLimit")) {
String request = args.getString(0);
contentService.checkMaxLimit(request, new GenieServicesResponse(callbackContext));
} else if(action.equals("getRelatedContent")) {
JSONObject contentExtras = null;
if(!args.getString(0).equals("null")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ genieservice.prototype.getRelevantContent = function(req) {
return this.handleAction("getRelevantContent", [req]);
}

// get max litmit content of particular content
genieservice.prototype.checkMaxLimit = function(req) {
return this.handleAction("checkMaxLimit", [req]);
}

genieservice.prototype.getLearnerAssessment = function(uid, id, contentExtras) {
return this.handleAction("getLearnerAssessment", [uid, id, contentExtras]);
}
Expand Down
11 changes: 9 additions & 2 deletions js-libs/renderer/manager/AudioManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ AudioManager = {
return action.stageId + ':' + action.asset;
},
play: function(action, instance) {

if (("undefined" != typeof action) && ("undefined" != typeof action.asset) && (null != action.asset)) {
var isAsset = typeof (AssetManager.getAsset(Renderer.theme._currentStage, action.asset)) === "string" ? false : true;
if (isAsset && ("undefined" != typeof action) && ("undefined" != typeof action.asset) && (null != action.asset)) {
instance = instance || AudioManager.instances[AudioManager.uniqueId(action)] || {};
if (instance.object) {
instance.object.volume = 1;
Expand All @@ -22,9 +22,16 @@ AudioManager = {
// Reclaim a space if necessary
AudioManager.reclaim();
// Instantiate the current audio to play
if(action.asset == RecorderManager.recordedAsset){ //Recorded Audio use CordovaAudioPlugin to play
RecorderManager.switchToCordova();
}
instance.object = createjs.Sound.play(action.asset, {
interrupt: createjs.Sound.INTERRUPT_ANY
});
if(action.asset == RecorderManager.recordedAsset){ //Normal audio need WebAudioPlugin to play in online play
RecorderManager.switchBackToDefault();
}

instance.object.muted = this.muted;
instance._data = {
id: AudioManager.uniqueId(action)
Expand Down
29 changes: 16 additions & 13 deletions js-libs/renderer/manager/LoadByStageStrategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@ LoadByStageStrategy = Class.extend({
init: function(themeData, basePath) {
//console.info('createjs.CordovaAudioPlugin.isSupported()', createjs.CordovaAudioPlugin.isSupported());
var instance = this;
var regex = new RegExp("^(http|https)://", "i");
if(regex.test(basePath)){
createjs.Sound.registerPlugins([createjs.WebAudioPlugin, createjs.CordovaAudioPlugin, createjs.HTMLAudioPlugin]);
}else{
createjs.Sound.registerPlugins([createjs.CordovaAudioPlugin, createjs.WebAudioPlugin, createjs.HTMLAudioPlugin]);
}
createjs.Sound.registerPlugins([createjs.WebAudioPlugin, createjs.CordovaAudioPlugin, createjs.HTMLAudioPlugin]);
createjs.Sound.alternateExtensions = ["mp3"];
this.destroy();
this.loadAppAssets();
Expand All @@ -34,11 +29,11 @@ LoadByStageStrategy = Class.extend({
media.src = basePath + media.src;
}
}
if (createjs.CordovaAudioPlugin.isSupported()) { // Only supported in mobile
if (media.type !== 'sound' && media.type !== 'audiosprite' && !regex.test(media.src)) {
media.src = 'file:///' + media.src;
}
}
// if (createjs.CordovaAudioPlugin.isSupported()) { // Only supported in mobile
// if (media.type !== 'sound' && media.type !== 'audiosprite' && !regex.test(media.src)) {
// media.src = 'file:///' + media.src;
// }
// }
if (media.type == 'json') {
instance.commonAssets.push(_.clone(media));
} else if (media.type == 'spritesheet') {
Expand Down Expand Up @@ -329,7 +324,13 @@ LoadByStageStrategy = Class.extend({
}
},
_createLoader: function() {
return "undefined" == typeof cordova ? new createjs.LoadQueue(true, null, true) : new createjs.LoadQueue(false);
var regex = new RegExp("^(http|https)://", "i");
var globalConfig = EkstepRendererAPI.getGlobalConfig();
if(regex.test(globalConfig.basepath)){
return new createjs.LoadQueue(true, null, true);
}else{
return new createjs.LoadQueue(false);
}
},
isStageAssetsLoaded : function(stageId) {
// Show weather stage manifest are loaded or not.
Expand Down Expand Up @@ -385,7 +386,9 @@ LoadByStageStrategy = Class.extend({
}
progressPercent = loader.progress;
if (progressPercent < 1){
bar.animate(loader.progress);
if(document.body.contains(bar.path) ){
bar.animate(loader.progress);
}
}
});
}
Expand Down
Loading

0 comments on commit 7aa6fd8

Please sign in to comment.