diff --git a/.github/workflows/Build.yml b/.github/workflows/Build.yml new file mode 100644 index 00000000000..f711e051d2c --- /dev/null +++ b/.github/workflows/Build.yml @@ -0,0 +1,89 @@ +name: Build-Test + +on: + push: + branches: + - "*" # Trigger on push to any branch + pull_request: + branches: + - "*" # Trigger on pull request to any branch + +jobs: + ci-cd-TestCases: + name: Build-Test + runs-on: ubuntu-latest + + steps: + # Checkout the repository to the runner + - name: Checkout repository + uses: actions/checkout@v3 + + # Set up Node.js environment + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: 18.20.2 + + # # Install client dependencies + # - name: Install client dependencies + # working-directory: src/app/client + # run: yarn install --no-progress --production=true + + # # Build the client + # - name: Build client + # working-directory: src/app/client + # run: npm run build + + # # List all files after the build + # - name: List all files after build + # working-directory: src/app/client + # run: find . -type f + + # # Check if the dist directory exists and list its contents + # - name: Check if dist directory exists and list contents + # working-directory: src/app/client + # run: | + # if [ -d dist ]; then + # echo "dist directory exists. Listing contents:" + # ls -l dist + # else + # echo "dist directory does not exist" + # fi + + # # Move index.html to index.ejs if it exists + # - name: Move index.html to index.ejs if it exists + # working-directory: src/app/client + # run: | + # if [ -f dist/index.html ]; then + # mv dist/index.html dist/index.ejs + # else + # echo "File dist/index.html does not exist" + # fi + + # # Set up server directories + # - name: Set up server directories + # run: mkdir -p $GITHUB_WORKSPACE/app_dist + + # # Copy server files to the destination directory + # - name: Copy server files + # run: | + # cp -r src/app/libs src/app/helpers src/app/proxy src/app/resourcebundles src/app/package.json src/app/framework.config.js src/app/sunbird-plugins src/app/routes src/app/constants src/app/controllers src/app/server.js $GITHUB_WORKSPACE/app_dist/ + # shell: /usr/bin/bash -e {0} + + # # Install server dependencies + # - name: Install server dependencies + # working-directory: ${{ github.workspace }}/app_dist + # run: yarn install --ignore-engines --no-progress --production=true + + # # Run server build script + # - name: Run server build script + # working-directory: ${{ github.workspace }}/app_dist + # run: node helpers/resourceBundles/build.js -task="phraseAppPull" + + # # Execute test cases using JEST + # - name: Execute test cases using JEST + # working-directory: src/app/client + # run: | + # yarn config set ignore-engines true + # yarn install + # npm run test:ci diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml deleted file mode 100644 index 013ae28516f..00000000000 --- a/.github/workflows/build-test.yml +++ /dev/null @@ -1,151 +0,0 @@ -name: Build - -on: - push: - branches: - - "*" # Trigger on push to any branch - pull_request: - branches: - - "*" # Trigger on pull request to any branch - workflow_dispatch: # Manual trigger - pull_request_target: # This is to access secrets from forked PRs - -jobs: - build-and-test: - runs-on: ubuntu-latest - - steps: - # Checkout the repository to the runner - - name: Checkout repository - uses: actions/checkout@v3 - - # Set up Node.js environment - - name: Set up Node.js - uses: actions/setup-node@v3 - with: - node-version: 18 - - # # Install client dependencies - # - name: Install client dependencies - # working-directory: src/app/client - # run: yarn install --no-progress --production=true - # # Build the client - # - name: Build client - # working-directory: src/app/client - # run: npm run build - # # List all files after the build - # - name: List all files after build - # working-directory: src/app/client - # run: find . -type f - # # Check if the dist directory exists and list its contents - # - name: Check if dist directory exists and list contents - # working-directory: src/app/client - # run: | - # if [ -d dist ]; then - # echo "dist directory exists. Listing contents:" - # ls -l dist - # else - # echo "dist directory does not exist" - # fi - # # Move index.html to index.ejs if it exists - # - name: Move index.html to index.ejs if it exists - # working-directory: src/app/client - # run: | - # if [ -f dist/index.html ]; then - # mv dist/index.html dist/index.ejs - # else - # echo "File dist/index.html does not exist" - # fi - # # Set up server directories - # - name: Set up server directories - # run: mkdir -p $GITHUB_WORKSPACE/app_dist - # # Copy server files to the destination directory - # - name: Copy server files - # run: | - # cp -r src/app/libs src/app/helpers src/app/proxy src/app/resourcebundles src/app/package.json src/app/framework.config.js src/app/sunbird-plugins src/app/routes src/app/constants src/app/controllers src/app/server.js $GITHUB_WORKSPACE/app_dist/ - # shell: /usr/bin/bash -e {0} - # # Install server dependencies - # - name: Install server dependencies - # working-directory: ${{ github.workspace }}/app_dist - # run: yarn install --ignore-engines --no-progress --production=true - # # Run server build script - # - name: Run server build script - # working-directory: ${{ github.workspace }}/app_dist - # run: node helpers/resourceBundles/build.js -task="phraseAppPull" - # Execute test cases using JEST - # - name: Execute test cases using JEST - # working-directory: src/app/client - # run: | - # yarn config set ignore-engines true - # yarn install - # npm run test:ci - # Debug: Print the masked SONAR_TOKEN - # - name: Print SONAR_TOKEN - # run: echo "SONAR_TOKEN=${{ secrets.SONAR_TOKEN }}PWR****123" - - # #Install Sonar Scanner - # - name: Install Sonar Scanner - # run: | - # cd /tmp - # wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-5.0.1.3006-linux.zip - # sudo apt-get install -y unzip - # unzip sonar-scanner-cli-5.0.1.3006-linux.zip - # cd - - - # # Run SonarScanner for frontend (Angular) - # - name: Run SonarScanner for frontend - # env: - # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - # run: | - # /tmp/sonar-scanner-5.0.1.3006-linux/bin/sonar-scanner \ - # -Dsonar.login=$SONAR_TOKEN - - # - name: Run Sonar Scanner - # env: - # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - # run: | - # /tmp/sonar-scanner-5.0.1.3006-linux/bin/sonar-scanner \ - # -Dsonar.projectKey=Sunbird-Ed_SunbirdEd-portal \ - # -Dsonar.sources=src/app/client/src \ - # -Dsonar.organization=sunbird-ed \ - # -Dsonar.host.url=https://sonarcloud.io \ - # -Dsonar.login=$SONAR_TOKEN - - # Install SonarScanner globally using npm - # - name: Install SonarScanner - # run: - # npm install -g sonarqube-scanner - - # # Check if SONAR_TOKEN is set - # - name: Check SONAR_TOKEN - # run: | - # if [ -z "${{ secrets.SONAR_TOKEN }}" ]; then - # echo "Error: SONAR_TOKEN is not set." - - # else - # echo "SONAR_TOKEN is set." - # fi - - # Debug: Print the masked SONAR_TOKEN - # - name: Print SONAR_TOKEN - # run: echo "SONAR_TOKEN=${{ secrets.SONAR_TOKEN }}PWR****123" - # # Ensure sonar-project.properties exists and print its content for debugging - # - name: Check sonar-project.properties - # run: | - # if [ -f sonar-project.properties ]; then - # echo "Found sonar-project.properties" - # cat sonar-project.properties - # else - # echo "sonar-project.properties not found" - # fi - # # Run SonarScanner in the specified directory - # - name: Run SonarScanner - # env: - # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - # run: | - # sonar-scanner \ - # -Dsonar.projectKey=Sunbird-Ed_SunbirdEd-portal \ - # -Dsonar.organization=sunbird-ed \ - # -Dsonar.sources=src/app/client/src \ - # -Dsonar.host.url=https://sonarcloud.io \ - # -Dsonar.login=$SONAR_TOKEN diff --git a/.github/workflows/build-upload-artifact.yml b/.github/workflows/build-upload-artifact.yml index 22f42a373b4..c31e57fd214 100644 --- a/.github/workflows/build-upload-artifact.yml +++ b/.github/workflows/build-upload-artifact.yml @@ -3,10 +3,10 @@ name: Build and Upload Artifact on: push: branches: - - "deploy" # Trigger on push to any branch + - "deploy" # Trigger on push to the "deploy" branch pull_request: branches: - - "deploy" # Trigger on pull request to any branch + - "deploy" # Trigger on pull request to the "deploy" branch jobs: build_and_deploy: @@ -32,14 +32,34 @@ jobs: WL_Customization: ${{ github.event.inputs.WL_Customization }} # Set environment variable WL_Customization - name: Build and Create Docker Image + id: build_docker_image run: | commit_hash=$(git rev-parse --short HEAD) # Get commit hash build_tag=$(echo "${{ github.ref }}" | rev | cut -d/ -f1 | rev)_${commit_hash}_${GITHUB_RUN_NUMBER} # Generate build tag - echo "build_tag: $build_tag" # Print build tag + echo "build_tag=$build_tag" >> $GITHUB_ENV # Save build tag to environment variable bash ./build.sh "${build_tag}" "${{ env.NODE_NAME }}" "test" true false "" # Run build script with parameters env: NODE_NAME: "18.20.2" # Set environment variable NODE_NAME + # - name: Log in to Docker Hub + # uses: docker/login-action@v2 + # with: + # username: ${{ secrets.DOCKER_USERNAME }} + # password: ${{ secrets.DOCKER_PASSWORD }} + + # - name: Push Docker Image + # run: | + # docker tag my-app:${{ env.build_tag }} ${{ secrets.DOCKER_USERNAME }}/my-app:${{ env.build_tag }} + # docker push ${{ secrets.DOCKER_USERNAME }}/my-app:${{ env.build_tag }} + + # - name: Push Docker Image + # uses: docker/build-push-action@v4 + # with: + # context: . + # # file: ./Dockerfile # Path to your Dockerfile + # push: true + # tags: ${{ secrets.DOCKER_USERNAME }}/my-app:${{ env.build_tag }} + - name: Archive Artifacts uses: actions/upload-artifact@v2 with: diff --git a/.github/workflows/sonar.yml b/.github/workflows/sonar.yml index 3c03b5316a9..bdecdb0f4f4 100644 --- a/.github/workflows/sonar.yml +++ b/.github/workflows/sonar.yml @@ -1,22 +1,22 @@ -name: Use the data +name: Sonar on: workflow_run: - workflows: ["Build"] + workflows: [Build-Test] # Trigger when the Build-Test workflow completes + branches: "*" types: - - completed + - completed # Trigger on completion of the Build-Test workflow jobs: - download: + SonarScanner: runs-on: ubuntu-latest - if: github.event.workflow_run.conclusion == 'success' + if: github.event.workflow_run.conclusion == 'success' # Run job only if Build-Test workflow succeeded + steps: + # Checkout repository to ensure we have the latest code - name: Checkout repository uses: actions/checkout@v3 - - name: Print SONAR_TOKEN - run: echo "SONAR_TOKEN=${{ secrets.SONAR_TOKEN }}PWR****123" - # Install Sonar Scanner - name: Install Sonar Scanner run: | @@ -24,10 +24,10 @@ jobs: wget -O /tmp/sonar-scanner-cli.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-5.0.1.3006-linux.zip unzip /tmp/sonar-scanner-cli.zip -d /tmp - # Run SonarScanner for frontend (Angular) - - name: Run SonarScanner for frontend + # Run SonarScanner for SunbirdEd-Portal + - name: Run SonarScanner for SunbirdEd-Portal env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Inject the SonarQube token securely run: | /tmp/sonar-scanner-5.0.1.3006-linux/bin/sonar-scanner \ -Dsonar.login=$SONAR_TOKEN diff --git a/README.md b/README.md index e172d5c4d21..494e674f997 100644 --- a/README.md +++ b/README.md @@ -229,4 +229,4 @@ Installing Sunbird requires two primary software components: | [@project-sunbird/sb-content-section](https://www.npmjs.com/package/@project-sunbird/sb-content-section) | https://github.com/Sunbird-Ed/sb-content-module | 8.0.1 | NG 16 | | [@project-sunbird/sb-notification](https://www.npmjs.com/package/@project-sunbird/sb-notification) | https://github.com/Sunbird-Ed/sb-notification | 8.0.1 | NG 16 | | [@shikshalokam/sl-questionnaire](https://www.npmjs.com/package/@shikshalokam/sl-questionnaire) | https://github.com/shikshalokam/sl-questionnaire-components | 7.0.0 | NG 16 | -| [@shikshalokam/sl-reports-library](https://www.npmjs.com/package/@shikshalokam/sl-reports-library) | https://github.com/shikshalokam/sl-reports-library | 6.0.0 | NG 16 | \ No newline at end of file +| [@shikshalokam/sl-reports-library](https://www.npmjs.com/package/@shikshalokam/sl-reports-library) | https://github.com/shikshalokam/sl-reports-library | 6.0.0 | NG 16 | diff --git a/local_setup.sh b/local_setup.sh index e37c6289cde..3265853542d 100644 --- a/local_setup.sh +++ b/local_setup.sh @@ -1,4 +1,4 @@ export sunbird_environment='local'; export sunbird_instance='sunbird'; export sunbird_default_channel='sunbird'; -export sunbird_default_tenant='sunbird'; \ No newline at end of file +export sunbird_default_tenant='sunbird'; diff --git a/src/app/client/src/app/modules/certificate/components/certificate-details/certificate-details.component.ts b/src/app/client/src/app/modules/certificate/components/certificate-details/certificate-details.component.ts index 89453b73e6b..93646d3d679 100644 --- a/src/app/client/src/app/modules/certificate/components/certificate-details/certificate-details.component.ts +++ b/src/app/client/src/app/modules/certificate/components/certificate-details/certificate-details.component.ts @@ -11,8 +11,7 @@ import { CsCertificateService } from '@project-sunbird/client-services/services/ @Component({ selector: 'app-certificate-details', - templateUrl: './certificate-details.component.html', - styleUrls: ['./certificate-details.component.scss'] + templateUrl: './certificate-details.component.html' }) export class CertificateDetailsComponent implements OnInit , OnDestroy { loader: boolean; diff --git a/src/app/client/src/app/modules/core/services/org-details/org-details.service.ts b/src/app/client/src/app/modules/core/services/org-details/org-details.service.ts index 88e98e28e9f..0d89aba9f9a 100644 --- a/src/app/client/src/app/modules/core/services/org-details/org-details.service.ts +++ b/src/app/client/src/app/modules/core/services/org-details/org-details.service.ts @@ -234,4 +234,3 @@ export class OrgDetailsService { } } - diff --git a/src/app/client/src/app/modules/offline/services/offline-card-service/offline-card.service.spec.data.ts b/src/app/client/src/app/modules/offline/services/offline-card-service/offline-card.service.spec.data.ts new file mode 100644 index 00000000000..5b8aa73f0a7 --- /dev/null +++ b/src/app/client/src/app/modules/offline/services/offline-card-service/offline-card.service.spec.data.ts @@ -0,0 +1,69 @@ +export const Response = { + cardData: { + 'name': 'B1 Test', + 'description': 'Untitled Collection', + 'action': { + 'right': { + 'class': 'trash large icon', + 'eventName': 'delete', + 'displayType': 'icon' + }, + 'onImage': { + 'eventName': 'onImage' + } + }, + 'ribbon': { + 'right': { + 'name': 'Worksheet', + 'class': 'ui black right ribbon label' + } + }, + 'resourceType': 'Worksheet', + 'telemetryInteractEdata': { + 'id': 'draftContentId', + 'type': 'click', + 'pageid': 'DraftContent' + }, + 'telemetryObjectType': 'draft', + 'metaData': { + 'identifier': 'do_1125430645258895361190', + 'mimeType': 'application/vnd.ekstep.content-collection', + 'framework': 'NCFCOPY', + 'contentType': 'TextBook' + }, + 'mimeTypesCount': '{"application/vnd.ekstep.html-archive":32, "video/x-youtube":1}' + }, + cardDataWithoutYoutubeContent: { + 'name': 'B1 Test', + 'description': 'Untitled Collection', + 'action': { + 'right': { + 'class': 'trash large icon', + 'eventName': 'delete', + 'displayType': 'icon' + }, + 'onImage': { + 'eventName': 'onImage' + } + }, + 'ribbon': { + 'right': { + 'name': 'Worksheet', + 'class': 'ui black right ribbon label' + } + }, + 'resourceType': 'Worksheet', + 'telemetryInteractEdata': { + 'id': 'draftContentId', + 'type': 'click', + 'pageid': 'DraftContent' + }, + 'telemetryObjectType': 'draft', + 'metaData': { + 'identifier': 'do_1125430645258895361190', + 'mimeType': 'application/vnd.ekstep.ecml-archive', + 'framework': 'NCFCOPY', + 'contentType': 'Resource' + } + } +}; diff --git a/src/app/client/src/app/modules/offline/services/offline-card-service/offline-card.service.spec.ts b/src/app/client/src/app/modules/offline/services/offline-card-service/offline-card.service.spec.ts new file mode 100644 index 00000000000..74ea89e05e8 --- /dev/null +++ b/src/app/client/src/app/modules/offline/services/offline-card-service/offline-card.service.spec.ts @@ -0,0 +1,23 @@ +import { TestBed } from '@angular/core/testing'; +import { OfflineCardService } from './offline-card.service'; +import { Response } from './offline-card.service.spec.data'; + +describe('OfflineCardService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: OfflineCardService = TestBed.get(OfflineCardService); + expect(service).toBeTruthy(); + }); + + it('If data has youtube content', () => { + const service: OfflineCardService = TestBed.get(OfflineCardService); + const response = service.checkYoutubeContent(Response.cardData); + expect(response).toBe(true); + }); + it('If data does not have youtube content', () => { + const service: OfflineCardService = TestBed.get(OfflineCardService); + const response = service.checkYoutubeContent(Response.cardDataWithoutYoutubeContent); + expect(response).toBe(false); + }); +}); diff --git a/src/app/client/src/app/modules/offline/services/offline-card-service/offline-card.service.ts b/src/app/client/src/app/modules/offline/services/offline-card-service/offline-card.service.ts new file mode 100644 index 00000000000..630705fee10 --- /dev/null +++ b/src/app/client/src/app/modules/offline/services/offline-card-service/offline-card.service.ts @@ -0,0 +1,21 @@ +import { Injectable } from '@angular/core'; +import * as _ from 'lodash-es'; + +@Injectable({ + providedIn: 'root' +}) +export class OfflineCardService { + + constructor() { } + + checkYoutubeContent(data) { + let isYoutube; + try { isYoutube = JSON.parse(data.mimeTypesCount); } catch (error) { isYoutube = undefined; } + if (_.includes(['video/youtube', 'video/x-youtube'], data.metaData.mimeType) + || _.has(isYoutube, 'video/youtube') || _.has(isYoutube, 'video/x-youtube')) { + return true; + } else { + return false; + } + } +} diff --git a/src/app/client/src/app/modules/shared-feature/components/batch-info/batch-info.component.ts b/src/app/client/src/app/modules/shared-feature/components/batch-info/batch-info.component.ts index 165ca3ea1a0..4c4c8ff76d1 100644 --- a/src/app/client/src/app/modules/shared-feature/components/batch-info/batch-info.component.ts +++ b/src/app/client/src/app/modules/shared-feature/components/batch-info/batch-info.component.ts @@ -140,4 +140,5 @@ export class BatchInfoComponent implements OnInit, OnDestroy { this.unsubscribe.next(); this.unsubscribe.complete(); } + } diff --git a/src/app/client/src/app/plugins/profile/components/profile-page/profile-page.component.html b/src/app/client/src/app/plugins/profile/components/profile-page/profile-page.component.html index 587382cb500..37a99614eb4 100644 --- a/src/app/client/src/app/plugins/profile/components/profile-page/profile-page.component.html +++ b/src/app/client/src/app/plugins/profile/components/profile-page/profile-page.component.html @@ -506,4 +506,3 @@