Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 0 additions & 48 deletions .eslintrc

This file was deleted.

53 changes: 53 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// this plugin is used to make all rules default to warnings
require('eslint-plugin-only-warn');

module.exports = {
extends: 'standard',
plugins: ['only-warn'], // makes all rules default to warnings
ignorePatterns: ['gulpfile.js', 'webpack.config.js', 'app/bower_components/**'],
globals: {
org: true,
CryptoJS: true,
_: true,
$: true,
angular: true,
ecEditor: true,
EkTelemetry: true,
EkstepEditor: true,
EkstepEditorAPI: true,
Class: true,
UUID: true,
WebFontConfig: true,
TextWYSIWYG: true,
ManifestGenerator: true,
WebFont: true,
fabric: true,
ServiceConstants: true,
async: true,
Fingerprint2: true,
describe: true,
jasmine: true,
afterAll: true,
beforeAll: true,
it: true,
spyOn: true,
expect: true,
xit: true,
EventBus: true,
beforeEach: true,
canvas: true,
Plugin: true,
createjs: true,
p: true,
basePlugin: true,
Mousetrap: true,
afterEach: true,
location: true,
X2JS: true
},
rules: {
indent: [2, 'tab'],
'no-tabs': 0,
'no-throw-literal': 'error',
}
}
109 changes: 109 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Publish Sunbird-generic-editor to blob

on:
push:
tags:
- '*'

env:
NODE_VERSION: 10.24.1
version_number: ${{ github.ref_name }}
build_number: ${{ github.run_number }}
CLOUD_PROVIDER: ${{ vars.CLOUD_PROVIDER }}
GCP_BUCKET: ${{ vars.GCP_BUCKET }}
AZURE_CONTAINER: ${{ vars.AZURE_CONTAINER }}

jobs:
publish:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Cache node modules
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('package.json') }}

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: 'https://registry.npmjs.org/'

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential libpng-dev

- name: Clone content plugins
Comment on lines +40 to +41
Copy link

Copilot AI Jul 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow assumes that every tag pushed to this repository has a corresponding branch with the same name in the sunbird-content-plugins repository, which may not always be true and could cause the workflow to fail.

Suggested change
- name: Clone content plugins
- name: Check if branch exists in sunbird-content-plugins
run: |
if git ls-remote --heads https://github.com/Sunbird-Knowlg/sunbird-content-plugins.git ${{ github.ref_name }} | grep -q ${{ github.ref_name }}; then
echo "Branch ${{ github.ref_name }} exists in sunbird-content-plugins."
echo "true" > branch_exists.txt
else
echo "Branch ${{ github.ref_name }} does not exist in sunbird-content-plugins."
echo "false" > branch_exists.txt
fi
- name: Clone content plugins
if: ${{ steps.check-branch.outputs.branch_exists == 'true' }}

Copilot uses AI. Check for mistakes.
run: |
git clone https://github.com/sanketika-labs/sunbird-content-plugins.git plugins -b ${{ github.ref_name }}

- name: Install global dependencies
run: |
npm install -g [email protected] [email protected] [email protected]

- name: Install dependencies
run: npm install --legacy-peer-deps
env:
PHANTOMJS_PLATFORM: linux
PHANTOMJS_ARCH: x64
TMPDIR: /tmp

- name: Install bower dependencies
working-directory: app
run: |
bower cache clean --allow-root
bower install --force --allow-root

- name: Build and package
run: |
npm install gulp-gzip --save-dev
npm run build-npm-pkg

- name: Setup Google Cloud SDK
if: env.CLOUD_PROVIDER == 'gcp'
uses: google-github-actions/setup-gcloud@v1
with:
install_components: 'gsutil'

- name: Authenticate and Upload to Google Cloud Storage
if: env.CLOUD_PROVIDER == 'gcp'
run: |
echo "${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}" | base64 -d > /tmp/service-account-key.json
gcloud auth activate-service-account --key-file=/tmp/service-account-key.json
gsutil -m cp -r generic-editor/* gs://${{ env.GCP_BUCKET }}/generic-editor/
rm -f /tmp/service-account-key.json

- name: Upload to Azure Blob Storage
if: env.CLOUD_PROVIDER == 'azure'
uses: azure/CLI@v1
with:
azcliversion: latest
inlineScript: |
az storage blob upload-batch \
--account-name "${{ secrets.AZURE_STORAGE_ACCOUNT }}" \
--account-key "${{ secrets.AZURE_STORAGE_KEY }}" \
--destination "${{ vars.AZURE_CONTAINER }}/generic-editor" \
--source generic-editor \
--overwrite

# Note: Publishing to AWS S3 is not tested.

# - name: Configure AWS credentials
# if: env.CLOUD_PROVIDER == 'aws'
# uses: aws-actions/configure-aws-credentials@v4
# with:
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# aws-region: ${{ vars.AWS_REGION || 'us-east-1' }}

# - name: Upload to Amazon S3
# if: env.CLOUD_PROVIDER == 'aws'
# env:
# S3_BUCKET: ${{ vars.S3_BUCKET }}
# run: |
# aws s3 sync generic-editor s3://${{ env.S3_BUCKET }}/generic-editor/
101 changes: 101 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Build and Test on Pull Request

on:
pull_request:
branches:
- '**'

env:
CONTENT_PLUGIN_VERSION: ${{ vars.CONTENT_PLUGIN_VERSION || 'release-8.0.0' }}

jobs:
build-test:
runs-on: ubuntu-latest
env:
version_number: ${{ github.ref_name }}
build_number: ${{ github.run_number }}
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Node.js 10
uses: actions/setup-node@v3
with:
node-version: 10.24.1

- name: Cache node modules
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('package.json') }}

- name: Clone plugins (from fork)
run: |
git clone --branch ${{ env.CONTENT_PLUGIN_VERSION }} https://github.com/Sunbird-Knowlg/sunbird-content-plugins.git plugins

- name: Install dependencies
run: |
which bower || sudo npm install -g [email protected]
which grunt || sudo npm install -g [email protected]
which gulp || sudo npm install -g [email protected]
sudo apt-get install build-essential libpng-dev

- name: Bower cache clean
working-directory: app
run: bower cache clean --allow-root

- name: Bower install
working-directory: app
run: bower install --force --allow-root

- name: Install global npm packages
run: npm install --legacy-peer-deps

- name: Gulp packageCorePlugins
run: gulp packageCorePlugins

- name: Plugin build
run: npm run plugin-build

- name: Run build
run: npm run build

- name: Test
run: npm run test
continue-on-error: true
Copy link

Copilot AI Jul 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are allowed to fail without stopping the workflow. This defeats the purpose of running tests in CI/CD and could allow broken code to pass validation.

Suggested change
continue-on-error: true

Copilot uses AI. Check for mistakes.

- name: Set up Node.js 14 (for Sonar)
uses: actions/setup-node@v3
with:
node-version: 14

- name: Install SonarQube scanner
run: npm install -g sonarqube-scanner

- name: Run SonarQube scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: sonar-scanner

lint:
needs: build-test
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Node.js 18
uses: actions/setup-node@v3
with:
node-version: 18

- name: Cache node modules
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('package.json') }}

Copy link

Copilot AI Jul 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lint job depends on build-test but doesn't install dependencies. The cached node_modules from the build-test job won't be available since jobs run in separate environments.

Suggested change
- name: Install dependencies
run: npm install --legacy-peer-deps

Copilot uses AI. Check for mistakes.
- name: Run Lint
run: npm run lint
Loading