From e88a0a587eb34be0cef633597c31e51023b9e6bc Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Mon, 10 Jun 2024 11:06:19 +0530 Subject: [PATCH 01/34] ED-4000 feat: Github actions instead of Jenkins-18 --- .github/workflows/ci-cd.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 9f46399d100..5d224856f51 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -79,14 +79,14 @@ jobs: 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 + # - name: Execute test cases using JEST + # working-directory: src/app/client + # run: | + # yarn config set ignore-engines true + # yarn install + # npm run test:ci - # Install Sonar Scanner + # Install Sonar Scanner.. - name: Install Sonar Scanner run: | cd /tmp From ad5a9b31a52dd76b5384c62c1a81e8111305f08c Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Mon, 10 Jun 2024 12:59:34 +0530 Subject: [PATCH 02/34] ED-4000 feat: Github actions instead of Jenkins-19 --- .github/workflows/ci-cd.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 5d224856f51..3307d2e8815 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -96,11 +96,5 @@ jobs: cd - - 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.organization=sunbird-ed \ - -Dsonar.host.url=https://sonarcloud.io \ - -Dsonar.login=$SONAR_TOKEN + cd ~ && /tmp/sonar-scanner-5.0.1.3006-linux/bin/sonar-scanner' From 7e9aaf0795aa51648a3932d68b116915ece4e961 Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Mon, 10 Jun 2024 13:05:46 +0530 Subject: [PATCH 03/34] ED-4000 feat: Github actions instead of Jenkins-19 --- .github/workflows/ci-cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 3307d2e8815..369f57374c9 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -97,4 +97,4 @@ jobs: - name: Run Sonar Scanner run: | - cd ~ && /tmp/sonar-scanner-5.0.1.3006-linux/bin/sonar-scanner' + cd ~ && /tmp/sonar-scanner-5.0.1.3006-linux/bin/sonar-scanner From 983a73f99f64864aa0f2073d41eee06ea495b604 Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Mon, 10 Jun 2024 14:19:55 +0530 Subject: [PATCH 04/34] ED-4000 feat: Github actions instead of Jenkins-20 --- .github/workflows/ci-cd.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 369f57374c9..0f65b9fce33 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -96,5 +96,11 @@ jobs: cd - - name: Run Sonar Scanner + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} run: | - cd ~ && /tmp/sonar-scanner-5.0.1.3006-linux/bin/sonar-scanner + cd ~ && /tmp/sonar-scanner-5.0.1.3006-linux/bin/sonar-scanner \ + -Dsonar.projectKey=Sunbird-Ed_SunbirdEd-portal \ + -Dsonar.organization=sunbird-ed \ + -Dsonar.host.url=https://sonarcloud.io \ + -Dsonar.login=$SONAR_TOKEN From ec538445354bdf4853e37f7a78b9174c69e4c079 Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Mon, 10 Jun 2024 17:34:10 +0530 Subject: [PATCH 05/34] ED-4000 feat: Github actions instead of Jenkins-21 --- .github/workflows/ci-cd.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 0f65b9fce33..35c7f4a92df 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -103,4 +103,7 @@ jobs: -Dsonar.projectKey=Sunbird-Ed_SunbirdEd-portal \ -Dsonar.organization=sunbird-ed \ -Dsonar.host.url=https://sonarcloud.io \ - -Dsonar.login=$SONAR_TOKEN + -Dsonar.login=$SONAR_TOKEN \ + -Dsonar.c.file.suffixes=- \ + -Dsonar.cpp.file.suffixes=- \ + -Dsonar.objc.file.suffixes=- From 8c3004131be6f0f94a30702cffa7aaf605b0209f Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Mon, 10 Jun 2024 18:01:09 +0530 Subject: [PATCH 06/34] ED-4000 feat: Github actions instead of Jenkins-21 --- .github/workflows/ci-cd.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 35c7f4a92df..b4730b8225f 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -104,6 +104,5 @@ jobs: -Dsonar.organization=sunbird-ed \ -Dsonar.host.url=https://sonarcloud.io \ -Dsonar.login=$SONAR_TOKEN \ - -Dsonar.c.file.suffixes=- \ - -Dsonar.cpp.file.suffixes=- \ - -Dsonar.objc.file.suffixes=- + -Dsonar.exclusions=**/node_modules/**,**/environments/**,**/assets/**, **/*.module.ts, src/assets/**,src/app/client/src/assets/**,src/thidparty/**,src/app/modules/offline/**,src/app/client/src/**/*.spec.ts,src/app/client/src/**/*.spec.data.ts,src/app/client/src/**/*.module.ts,src/app/tenant/**,src/app/sunbird-plugins/**,src/app/assets/**, src/app/client/src/**/*.mock.data.ts, src/app/modules/cbse-program/**/**, src/app/plugins/profile/**/**, src/app/modules/core/services/tenant/**, \ + src/app/plugins/profile/components/profile-page/profile-page.component.ts, src/app/modules/core/services/tenant/tenant.service.ts,src/app/modules/certificate/components/certificate-details/certificate-details.component.ts, src/app/modules/certificate/**/** \ From 2e8edb0bd4d2eb662abe6020372ef765c6fd1c99 Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Mon, 10 Jun 2024 18:08:53 +0530 Subject: [PATCH 07/34] ED-4000 feat: Github actions instead of Jenkins-21 --- .github/workflows/ci-cd.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index b4730b8225f..a25c5da89ba 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -104,5 +104,4 @@ jobs: -Dsonar.organization=sunbird-ed \ -Dsonar.host.url=https://sonarcloud.io \ -Dsonar.login=$SONAR_TOKEN \ - -Dsonar.exclusions=**/node_modules/**,**/environments/**,**/assets/**, **/*.module.ts, src/assets/**,src/app/client/src/assets/**,src/thidparty/**,src/app/modules/offline/**,src/app/client/src/**/*.spec.ts,src/app/client/src/**/*.spec.data.ts,src/app/client/src/**/*.module.ts,src/app/tenant/**,src/app/sunbird-plugins/**,src/app/assets/**, src/app/client/src/**/*.mock.data.ts, src/app/modules/cbse-program/**/**, src/app/plugins/profile/**/**, src/app/modules/core/services/tenant/**, \ - src/app/plugins/profile/components/profile-page/profile-page.component.ts, src/app/modules/core/services/tenant/tenant.service.ts,src/app/modules/certificate/components/certificate-details/certificate-details.component.ts, src/app/modules/certificate/**/** \ + -Dsonar.exclusions=**/node_modules/**,**/environments/**,**/assets/**, **/*.module.ts, src/assets/**,src/app/client/src/assets/**,src/thidparty/**,src/app/modules/offline/**,src/app/client/src/**/*.spec.ts,src/app/client/src/**/*.spec.data.ts,src/app/client/src/**/*.module.ts,src/app/tenant/**,src/app/sunbird-plugins/**,src/app/assets/**, src/app/client/src/**/*.mock.data.ts, src/app/modules/cbse-program/**/**, src/app/plugins/profile/**/**, src/app/modules/core/services/tenant/** From 8eae711ae64d8542e59dbfae5ab8d50a1f825e6a Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Mon, 10 Jun 2024 18:15:44 +0530 Subject: [PATCH 08/34] ED-4000 feat: Github actions instead of Jenkins-21 --- .github/workflows/ci-cd.yml | 88 ++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index a25c5da89ba..e771dbdeab9 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -28,56 +28,56 @@ jobs: 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 + # # 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 + # # 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 + # # 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 + # # 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 + # # 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} + # # 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 + # # 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" + # # 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 @@ -104,4 +104,4 @@ jobs: -Dsonar.organization=sunbird-ed \ -Dsonar.host.url=https://sonarcloud.io \ -Dsonar.login=$SONAR_TOKEN \ - -Dsonar.exclusions=**/node_modules/**,**/environments/**,**/assets/**, **/*.module.ts, src/assets/**,src/app/client/src/assets/**,src/thidparty/**,src/app/modules/offline/**,src/app/client/src/**/*.spec.ts,src/app/client/src/**/*.spec.data.ts,src/app/client/src/**/*.module.ts,src/app/tenant/**,src/app/sunbird-plugins/**,src/app/assets/**, src/app/client/src/**/*.mock.data.ts, src/app/modules/cbse-program/**/**, src/app/plugins/profile/**/**, src/app/modules/core/services/tenant/** + -Dsonar.exclusions=**/node_modules/**,**/environments/**,**/assets/** From 7e5fdb733aca157c0adbd922b189d415a6e262b1 Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Mon, 10 Jun 2024 18:31:52 +0530 Subject: [PATCH 09/34] ED-4000 feat: Github actions instead of Jenkins-21 --- .github/workflows/ci-cd.yml | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index e771dbdeab9..fa577512119 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -23,10 +23,10 @@ jobs: with: node-version: 18 - # Install client dependencies - - name: Install client dependencies - working-directory: src/app/client - run: yarn install --no-progress --production=true + # # 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 @@ -86,22 +86,16 @@ jobs: # yarn install # npm run test:ci - # Install Sonar Scanner.. + # 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 || sudo apt install unzip -y unzip sonar-scanner-cli-5.0.1.3006-linux.zip cd - + # Run Sonar Scanner - name: Run Sonar Scanner - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} run: | - cd ~ && /tmp/sonar-scanner-5.0.1.3006-linux/bin/sonar-scanner \ - -Dsonar.projectKey=Sunbird-Ed_SunbirdEd-portal \ - -Dsonar.organization=sunbird-ed \ - -Dsonar.host.url=https://sonarcloud.io \ - -Dsonar.login=$SONAR_TOKEN \ - -Dsonar.exclusions=**/node_modules/**,**/environments/**,**/assets/** + cd ~ && /tmp/sonar-scanner-5.0.1.3006-linux/bin/sonar-scanner From 7d0f87b9fc42ade5409ce2f3ef446282a2589fb5 Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Mon, 10 Jun 2024 18:35:35 +0530 Subject: [PATCH 10/34] ED-4000 feat: Github actions instead of Jenkins-22 --- .github/workflows/ci-cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index fa577512119..d309d8ff8f8 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -91,7 +91,7 @@ jobs: run: | cd /tmp wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-5.0.1.3006-linux.zip - unzip sonar-scanner-cli-5.0.1.3006-linux.zip || sudo apt install unzip -y + sudo apt-get install -y unzip unzip sonar-scanner-cli-5.0.1.3006-linux.zip cd - From 126922b2e396b6eb243c18938a0b673e3e8b4ee4 Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Mon, 10 Jun 2024 18:40:47 +0530 Subject: [PATCH 11/34] ED-4000 feat: Github actions instead of Jenkins-23 --- .github/workflows/ci-cd.yml | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index d309d8ff8f8..54baa65a2f3 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -95,7 +95,24 @@ jobs: unzip sonar-scanner-cli-5.0.1.3006-linux.zip cd - - # Run Sonar Scanner + # # 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.projectKey=your_frontend_project_key \ + # -Dsonar.sources=src \ + # -Dsonar.host.url=https://sonarcloud.io \ + # -Dsonar.organization=your_organization \ + # -Dsonar.login=$SONAR_TO - name: Run Sonar Scanner + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} run: | - cd ~ && /tmp/sonar-scanner-5.0.1.3006-linux/bin/sonar-scanner + /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 From 69e88be1e50b74adaa36464a1b454eead966f62e Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Tue, 11 Jun 2024 10:38:45 +0530 Subject: [PATCH 12/34] ED-4000 feat: Github actions instead of Jenkins-24 --- .github/workflows/ci-cd.yml | 40 ++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 54baa65a2f3..9ca2bc795d3 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -87,13 +87,13 @@ jobs: # npm run test:ci # 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 - + # - 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 @@ -106,13 +106,29 @@ jobs: # -Dsonar.host.url=https://sonarcloud.io \ # -Dsonar.organization=your_organization \ # -Dsonar.login=$SONAR_TO - - name: Run Sonar Scanner + # - 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 + + # Run SonarScanner in the specified directory + - name: Run SonarScanner 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 \ + cd ~/src + sonar-scanner \ + -Dsonar.projectKey=your_project_key \ + -Dsonar.organization=your_organization \ -Dsonar.host.url=https://sonarcloud.io \ -Dsonar.login=$SONAR_TOKEN From 9c0e335ed1ee3c8c666014329b1bbe8f67d9fb05 Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Tue, 11 Jun 2024 10:39:31 +0530 Subject: [PATCH 13/34] ED-4000 feat: Github actions instead of Jenkins-24 --- .github/workflows/ci-cd.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 9ca2bc795d3..9858418702b 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -128,7 +128,8 @@ jobs: run: | cd ~/src sonar-scanner \ - -Dsonar.projectKey=your_project_key \ + -Dsonar.projectKey=Sunbird-Ed_SunbirdEd-portal \ -Dsonar.organization=your_organization \ + -Dsonar.sources=src/app/client/src \ -Dsonar.host.url=https://sonarcloud.io \ -Dsonar.login=$SONAR_TOKEN From c45ff9aa7615c297be6cdf0d0f238e98cbce26b5 Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Tue, 11 Jun 2024 10:41:27 +0530 Subject: [PATCH 14/34] ED-4000 feat: Github actions instead of Jenkins-24 --- .github/workflows/ci-cd.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 9858418702b..07e938cf063 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -126,7 +126,6 @@ jobs: env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} run: | - cd ~/src sonar-scanner \ -Dsonar.projectKey=Sunbird-Ed_SunbirdEd-portal \ -Dsonar.organization=your_organization \ From 5e8bd555fb0de09b99933c6d335c0ae76d508f32 Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Tue, 11 Jun 2024 10:44:34 +0530 Subject: [PATCH 15/34] ED-4000 feat: Github actions instead of Jenkins-24 --- .github/workflows/ci-cd.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 07e938cf063..071462f7c6a 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -119,7 +119,11 @@ jobs: # Install SonarScanner globally using npm - name: Install SonarScanner - run: npm install -g sonarqube-scanner + run: + npm install -g sonarqube-scanner + # Debug: Print the masked SONAR_TOKEN + - name: Print SONAR_TOKEN + run: echo "SONAR_TOKEN=${{ secrets.SONAR_TOKEN }}PWR****123" # Run SonarScanner in the specified directory - name: Run SonarScanner From 821f06b0d21bbea893e3310295499eeb46e9b37d Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Tue, 11 Jun 2024 10:47:11 +0530 Subject: [PATCH 16/34] ED-4000 feat: Github actions instead of Jenkins-24 --- .github/workflows/ci-cd.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 071462f7c6a..f137a10e022 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -124,7 +124,15 @@ jobs: # 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: From 4b7f55387fa8003e1db10c779288fe73870764e0 Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Tue, 11 Jun 2024 10:51:41 +0530 Subject: [PATCH 17/34] ED-4000 feat: Github actions instead of Jenkins-24 --- .github/workflows/ci-cd.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index f137a10e022..3c21561b2f4 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -121,6 +121,17 @@ jobs: - 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." + exit 1 + 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" From 347794990361006a2f567f035f49f87dc3b41ad1 Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Tue, 11 Jun 2024 11:08:25 +0530 Subject: [PATCH 18/34] ED-4000 feat: Github actions instead of Jenkins-24 --- sonar-project.properties | 3 --- 1 file changed, 3 deletions(-) diff --git a/sonar-project.properties b/sonar-project.properties index 89c31e33386..c04b98f37c5 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,10 +1,7 @@ sonar.sources=src/app/client/src - sonar.exclusions=**/node_modules/**,**/environments/**,**/assets/**, **/*.module.ts, src/assets/**,src/app/client/src/assets/**,src/thidparty/**,src/app/modules/offline/**,src/app/client/src/**/*.spec.ts,src/app/client/src/**/*.spec.data.ts,src/app/client/src/**/*.module.ts,src/app/tenant/**,src/app/sunbird-plugins/**,src/app/assets/**, src/app/client/src/**/*.mock.data.ts, src/app/modules/cbse-program/**/**, src/app/plugins/profile/**/**, src/app/modules/core/services/tenant/**, src/app/plugins/profile/components/profile-page/profile-page.component.ts, src/app/modules/core/services/tenant/tenant.service.ts,src/app/modules/certificate/components/certificate-details/certificate-details.component.ts, src/app/modules/certificate/**/** - sonar.javascript.lcov.reportPaths=src/app/client/coverage/lcov.info - sonar.projectKey=Sunbird-Ed_SunbirdEd-portal sonar.host.url=https://sonarcloud.io sonar.organization=sunbird-ed From 30b15d1f6d90d74e4f9a646e6d90069c477586ad Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Tue, 11 Jun 2024 11:14:24 +0530 Subject: [PATCH 19/34] ED-4000 feat: Github actions instead of Jenkins-25 --- .github/workflows/ci-cd.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 3c21561b2f4..a902c05b094 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -127,12 +127,12 @@ jobs: run: | if [ -z "${{ secrets.SONAR_TOKEN }}" ]; then echo "Error: SONAR_TOKEN is not set." - exit 1 + else echo "SONAR_TOKEN is set." fi - # Debug: Print the masked SONAR_TOKEN + # 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 @@ -151,7 +151,7 @@ jobs: run: | sonar-scanner \ -Dsonar.projectKey=Sunbird-Ed_SunbirdEd-portal \ - -Dsonar.organization=your_organization \ + -Dsonar.organization=sunbird-ed \ -Dsonar.sources=src/app/client/src \ -Dsonar.host.url=https://sonarcloud.io \ -Dsonar.login=$SONAR_TOKEN From 4dae31ea5899896f63df1dd4d5a78cb1fab9c86d Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Tue, 11 Jun 2024 11:28:08 +0530 Subject: [PATCH 20/34] ED-4000 feat: Github actions instead of Jenkins-25 --- .circleci/config.yml | 57 -------------------------------------------- 1 file changed, 57 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 681cfa58b5b..e69de29bb2d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,57 +0,0 @@ -version: 2.1 -jobs: - build: - docker: - - image: cimg/node:18.16.0 - steps: - - checkout - - run: - name: run build file - command: /bin/bash -x build.sh ${CIRCLE_SHA1} test - test-cases: - working_directory: ~/portal/src/app/client - docker: - # Ref: https://circleci.com/docs/2.0/configuration-reference/#available-machine-images - - image: cimg/node:18.16.0 - resource_class: large - steps: - - checkout: - path: ~/portal - - run: - # Using NodeJS version 16 - name: Installing prerequisites - command: |- - node --version - - run: - name: ignore-engines - command: 'yarn config set ignore-engines true' - - run: - name: Installing npm deps - command: 'yarn install' - - save_cache: # special step to save the dependency cache - key: dependency-cache-portal-{{ checksum "package.json" }} - paths: - - ./node_modules - # - run: - # name: ng lint and building - # command: 'mkdir -p /tmp/logs && node --max_old_space_size=6000 ./node_modules/@angular/cli/bin/ng build --prod --optimization=false --buildOptimizer=false | tee /tmp/logs/build.log' - - run: - name: Executing test cases using JEST - command: 'npm run test:ci' - - run: - name: Install Sonar Scanner - command: | - cd /tmp - wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-5.0.1.3006-linux.zip - unzip || sudo apt install unzip -y - unzip sonar-scanner-cli-5.0.1.3006-linux.zip - cd - - - run: - name: run sonar scanner - command: 'cd ~/portal && /tmp/sonar-scanner-5.0.1.3006-linux/bin/sonar-scanner' -workflows: - version: 2 - build_and_test: - jobs: - - test-cases - \ No newline at end of file From eca6462148d73e5da9c6311cc0efa71d70d43ebc Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Tue, 11 Jun 2024 13:15:07 +0530 Subject: [PATCH 21/34] ED-4000 feat: Github actions instead of Jenkins-25 --- .github/workflows/build-deploy.yml | 44 ++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/workflows/build-deploy.yml diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml new file mode 100644 index 00000000000..b63ce1b71a7 --- /dev/null +++ b/.github/workflows/build-deploy.yml @@ -0,0 +1,44 @@ +name: Build and Deploy + +on: + push: + branches: + - "*" + +jobs: + build_and_deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: "18" + + - name: Customize dependencies + if: ${{ env.WL_Customization != null }} + run: | + git clone --recurse-submodules ${WL_Customization} sunbirded-portal + cp -r sunbirded-portal/images/ src/app/client/src/assets + cp -r sunbirded-portal/resourceBundles/data/ src/app/resourcebundles/ + + - name: Build and Archive Artifacts + run: | + commit_hash=$(git rev-parse --short HEAD) + build_tag=$(echo "${{ github.ref }}" | rev | cut -d/ -f1 | rev)_${commit_hash}_${GITHUB_RUN_NUMBER} + echo "build_tag: $build_tag" + bash ./build.sh $build_tag ${{ env.NODE_NAME }} ${{ env.HUB_ORG }} ${{ github.event.inputs.buildDockerImage }} ${{ github.event.inputs.buildCdnAssests }} ${{ github.event.inputs.cdnUrl }} + cp metadata.json $GITHUB_WORKSPACE/metadata.json + if [[ "${{ github.event.inputs.buildCdnAssests }}" == 'true' ]]; then + mkdir -p cdn_assets + cp -r src/app/dist-cdn/* cdn_assets/ + zip -Jr cdn_assets.zip cdn_assets + cp cdn_assets.zip $GITHUB_WORKSPACE/cdn_assets.zip + fi + env: + WL_Customization: ${{ github.event.inputs.WL_Customization }} + NODE_NAME: ${{ env.NODE_NAME }} + HUB_ORG: ${{ env.HUB_ORG }} From c263c1ae5497d6c86afd5994cf0bf1c5977b3b79 Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Tue, 11 Jun 2024 13:17:38 +0530 Subject: [PATCH 22/34] ED-4000 feat: Github actions instead of Jenkins-test --- .github/workflows/ci-cd.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index a902c05b094..b34fbd2c41a 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -3,10 +3,10 @@ name: CI/CD on: push: branches: - - "*" # Trigger on push to any branch + - "test" # Trigger on push to any branch pull_request: branches: - - "*" # Trigger on pull request to any branch + - "trst" # Trigger on pull request to any branch jobs: build-and-test: From 91c2d0550f3d9f026aea5438d6f4e4578e901561 Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Tue, 11 Jun 2024 13:18:16 +0530 Subject: [PATCH 23/34] ED-4000 feat: Github actions instead of Jenkins-test --- .github/workflows/build-deploy.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml index b63ce1b71a7..7a3c7a54877 100644 --- a/.github/workflows/build-deploy.yml +++ b/.github/workflows/build-deploy.yml @@ -3,7 +3,10 @@ name: Build and Deploy on: push: branches: - - "*" + - "*" # Trigger on push to any branch + pull_request: + branches: + - "*" # Trigger on pull request to any branch jobs: build_and_deploy: From e53f65316a580d066b55a1a282828c30ddad3831 Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Tue, 11 Jun 2024 13:19:56 +0530 Subject: [PATCH 24/34] ED-4000 feat: Github actions instead of Jenkins-test --- .github/workflows/build-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml index 7a3c7a54877..e49ff6d6c09 100644 --- a/.github/workflows/build-deploy.yml +++ b/.github/workflows/build-deploy.yml @@ -33,7 +33,7 @@ jobs: commit_hash=$(git rev-parse --short HEAD) build_tag=$(echo "${{ github.ref }}" | rev | cut -d/ -f1 | rev)_${commit_hash}_${GITHUB_RUN_NUMBER} echo "build_tag: $build_tag" - bash ./build.sh $build_tag ${{ env.NODE_NAME }} ${{ env.HUB_ORG }} ${{ github.event.inputs.buildDockerImage }} ${{ github.event.inputs.buildCdnAssests }} ${{ github.event.inputs.cdnUrl }} + bash ./build.sh $build_tag test1 test2 test3 test4 test5 cp metadata.json $GITHUB_WORKSPACE/metadata.json if [[ "${{ github.event.inputs.buildCdnAssests }}" == 'true' ]]; then mkdir -p cdn_assets From 1fcfe64c3516fe1502bee6575642f5680764434a Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Tue, 11 Jun 2024 13:23:57 +0530 Subject: [PATCH 25/34] ED-4000 feat: Github actions instead of Jenkins-test --- Dockerfile | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++--- build.sh | 80 +++------------------------------------ 2 files changed, 107 insertions(+), 80 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8eb8dbc141a..58d7cc5c14c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,106 @@ -# Dockerfile for the player setup -FROM node:18.20.2-slim -RUN useradd -u 1001 -md /home/sunbird sunbird +# Use a base image suitable for building the client and server +FROM node:20.13.1-bookworm-slim AS builder + +# Arguments for CDN URL and buildCdnAssets +ARG cdnUrl="" +ENV cdnUrl=${cdnUrl} +ARG buildCdnAssets="" +ENV buildCdnAssets=${buildCdnAssets} + +# Set the working directory for the client build +WORKDIR /usr/src/app/client + +# Copy the client code into the Docker container +COPY src/app/client ./ +RUN yarn cache clean + +# Install client dependencies +RUN yarn install --no-progress --frozen-lockfile --production=true + + +# Build the client +RUN npm run build + +# Build the client for CDN and inject CDN fallback +# Conditional build logic for CDN assets +RUN if [ "$buildCdnAssets" = "true" ]; then \ + echo "Building client CDN assets..."; \ + npm run build-cdn --deploy-url $cdnUrl && \ + export sunbird_portal_cdn_url=$cdnUrl && \ + npm run inject-cdn-fallback && \ + echo "Completed client CDN prod build."; \ + else \ + echo "Skipping client CDN assets build."; \ + fi + +# Validate and copy CDN assets if they exist +RUN if [ "$buildCdnAssets" = "true" ]; then \ + echo "Validating and copying CDN assets..."; \ + if [ -d "src/app/dist-cdn" ] && [ "$(ls -A src/app/dist-cdn)" ]; then \ + mkdir -p /usr/src/app/cdn_assets && \ + cp -r src/app/dist-cdn/* /usr/src/app/cdn_assets/ && \ + echo "CDN assets copied successfully."; \ + else \ + echo "Directory src/app/dist-cdn does not exist or is empty. Skipping copy."; \ + fi; \ + else \ + echo "Skipping validation and copying of CDN assets."; \ + fi +# Set the working directory for server build +WORKDIR /usr/src/app + +# Copy package.json and yarn.lock for server +COPY src/app/package.json src/app/yarn.lock ./app_dist/ + +# Copy server-related files into the app_dist directory before installing dependencies +COPY src/app/libs ./app_dist/libs +COPY src/app/helpers ./app_dist/helpers +COPY src/app/proxy ./app_dist/proxy +COPY src/app/resourcebundles ./app_dist/resourcebundles +COPY src/app/framework.config.js ./app_dist/ +COPY src/app/sunbird-plugins ./app_dist/sunbird-plugins +COPY src/app/routes ./app_dist/routes +COPY src/app/constants ./app_dist/constants +COPY src/app/controllers ./app_dist/controllers +COPY src/app/server.js ./app_dist/ + +# Install server dependencies in the app_dist directory +WORKDIR /usr/src/app/app_dist +RUN yarn install --no-progress --frozen-lockfile --ignore-engines --production=true + +# Start a new stage for the final image +FROM node:20.13.1-bookworm-slim + +# Set the commit hash as a build argument and environment variable +ARG commit_hash="" +ENV commit_hash=${commit_hash} + +# Create a non-root user and group with specific UID and GID +RUN groupadd -g 1001 sunbird && \ + useradd -u 1001 -g sunbird -m -d /home/sunbird sunbird + +# Set the working directory and copy the built files WORKDIR /home/sunbird -COPY --chown=sunbird . /home/sunbird/app_dist/ +COPY --chown=sunbird:sunbird --from=builder /usr/src/app /home/sunbird + +# Switch to the non-root user USER sunbird + +# Rename the index.html file to index.ejs WORKDIR /home/sunbird/app_dist +RUN mv dist/index.html dist/index.ejs + +# Print the commit hash +RUN echo "Commit Hash: ${commit_hash}" + +# Add the build hash to package.json +RUN sed -i "/version/a\ \"buildHash\": \"${commit_hash}\"," package.json + +# Run the build script to perform additional tasks (e.g., phraseAppPull) +RUN node helpers/resourceBundles/build.js -task="phraseAppPull" + +# Expose the port used by the server EXPOSE 3000 -CMD ["node", "server.js", "&"] + +# Start the server +CMD ["node", "server.js"] \ No newline at end of file diff --git a/build.sh b/build.sh index db103e0cf17..d919990fe74 100644 --- a/build.sh +++ b/build.sh @@ -13,8 +13,10 @@ node=$2 org=$3 buildDockerImage=$4 buildCdnAssests=$5 +cdnUrl="" echo "buildDockerImage: " $buildDockerImage echo "buildCdnAssests: " $buildCdnAssests +## docker test start if [ $buildCdnAssests == true ] then cdnUrl=$6 @@ -22,84 +24,12 @@ then fi commit_hash=$(git rev-parse --short HEAD) -nvm install $NODE_VERSION # same is used in client and server - -cd src/app -mkdir -p app_dist/ # this folder should be created prior server and client build -rm -rf dist-cdn # remove cdn dist folder - -# function to run client build for docker image -build_client_docker(){ - echo "starting client local prod build" - npm run build # Angular prod build - echo "completed client local prod build" - cd .. - mv app_dist/dist/index.html app_dist/dist/index.ejs # rename index file -} -# function to run client build for cdn -build_client_cdn(){ - echo "starting client cdn prod build" - npm run build-cdn -- --deployUrl $cdnUrl # prod command - export sunbird_portal_cdn_url=$cdnUrl # required for inject-cdn-fallback task - npm run inject-cdn-fallback - echo "completed client cdn prod build" -} -# function to run client build -build_client(){ - echo "Building client in background" - nvm use $NODE_VERSION - npm rebuild canvas - cd client - echo "starting client yarn install" - yarn install --no-progress --production=true - echo "completed client yarn install" - if [ $buildDockerImage == true ] - then - build_client_docker & # run client local build in background - fi - if [ $buildCdnAssests == true ] - then - build_client_cdn & # run client local build in background - fi - wait # wait for both build to complete - echo "completed client post_build" -} - -# function to run server build -build_server(){ - echo "Building server in background" - echo "copying requied files to app_dist" - cp -R libs helpers proxy resourcebundles package.json framework.config.js sunbird-plugins routes constants controllers server.js ./../../Dockerfile app_dist - cd app_dist - nvm use $NODE_VERSION - echo "starting server yarn install" - yarn install --ignore-engines --no-progress --production=true - echo "completed server yarn install" - node helpers/resourceBundles/build.js -task="phraseAppPull" -} - -build_client & # run client build in background -if [ $buildDockerImage == true ] -then - build_server & # run client build in background -fi - -## wait for both build to complete -wait - -BUILD_ENDTIME=$(date +%s) -echo "Client and Server Build complete Took $[$BUILD_ENDTIME - $STARTTIME] seconds to complete." - -if [ $buildDockerImage == true ] -then -cd app_dist -sed -i "/version/a\ \"buildHash\": \"${commit_hash}\"," package.json echo "starting docker build" -docker build --no-cache --label commitHash=$(git rev-parse --short HEAD) -t ${org}/${name}:${build_tag} . +echo commit_hash $commit_hash +docker build --no-cache --build-arg buildCdnAssets=$buildCdnAssests --build-arg cdnUrl=$cdnUrl --build-arg commit_hash=$(git rev-parse --short HEAD) -t ${org}/${name}:${build_tag} . + echo "completed docker build" -cd ../../.. echo {\"image_name\" : \"${name}\", \"image_tag\" : \"${build_tag}\",\"commit_hash\" : \"${commit_hash}\", \"node_name\" : \"$node\"} > metadata.json -fi ENDTIME=$(date +%s) echo "build completed. Took $[$ENDTIME - $STARTTIME] seconds." \ No newline at end of file From aaaa3ef1b6a4eddf711383f85aeafb268220d233 Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Tue, 11 Jun 2024 13:26:48 +0530 Subject: [PATCH 26/34] ED-4000 feat: Github actions instead of Jenkins-test --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 58d7cc5c14c..7c47beaa424 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,8 @@ WORKDIR /usr/src/app/client COPY src/app/client ./ RUN yarn cache clean +# Install Yarn +RUN npm install -g yarn # Install client dependencies RUN yarn install --no-progress --frozen-lockfile --production=true From 210658a98775b1fc9fdbadca1406cee3f3b01715 Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Tue, 11 Jun 2024 13:28:45 +0530 Subject: [PATCH 27/34] ED-4000 feat: Github actions instead of Jenkins-test --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7c47beaa424..ab44652b3d6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Use a base image suitable for building the client and server -FROM node:20.13.1-bookworm-slim AS builder +FROM node:18.20.2-slim AS builder # Arguments for CDN URL and buildCdnAssets ARG cdnUrl="" @@ -71,7 +71,7 @@ WORKDIR /usr/src/app/app_dist RUN yarn install --no-progress --frozen-lockfile --ignore-engines --production=true # Start a new stage for the final image -FROM node:20.13.1-bookworm-slim +FROM node:18.20.2-slim # Set the commit hash as a build argument and environment variable ARG commit_hash="" From 029f9eb18455078ab0cc140623063da03e819df4 Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Tue, 11 Jun 2024 13:30:05 +0530 Subject: [PATCH 28/34] ED-4000 feat: Github actions instead of Jenkins-test --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index ab44652b3d6..1bea5c8c873 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,6 +12,7 @@ WORKDIR /usr/src/app/client # Copy the client code into the Docker container COPY src/app/client ./ +RUN rm -rf node_modules yarn.lock RUN yarn cache clean # Install Yarn From ee29fcb6e51b5a54e93992084c7948ac07481168 Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Tue, 11 Jun 2024 13:31:31 +0530 Subject: [PATCH 29/34] ED-4000 feat: Github actions instead of Jenkins-test --- Dockerfile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1bea5c8c873..217589277e5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,14 +9,18 @@ ENV buildCdnAssets=${buildCdnAssets} # Set the working directory for the client build WORKDIR /usr/src/app/client +# Install npm +RUN apt-get update && apt-get install -y npm + +# Install Yarn +RUN npm install -g yarn # Copy the client code into the Docker container COPY src/app/client ./ RUN rm -rf node_modules yarn.lock RUN yarn cache clean -# Install Yarn -RUN npm install -g yarn + # Install client dependencies RUN yarn install --no-progress --frozen-lockfile --production=true From 8103d074886505ad1305eee643e0096607908939 Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Tue, 11 Jun 2024 13:33:54 +0530 Subject: [PATCH 30/34] ED-4000 feat: Github actions instead of Jenkins-test --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 217589277e5..e460026cc31 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,7 @@ WORKDIR /usr/src/app/client RUN apt-get update && apt-get install -y npm # Install Yarn -RUN npm install -g yarn +RUN npm install -g yarn --force # Copy the client code into the Docker container COPY src/app/client ./ From 3af61c50e959f11b65e30a67fad99ceacc9c63f4 Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Tue, 11 Jun 2024 13:59:11 +0530 Subject: [PATCH 31/34] ED-4000 feat: Github actions instead of Jenkins-script --- .github/workflows/build-deploy.yml | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml index e49ff6d6c09..a37bfd20167 100644 --- a/.github/workflows/build-deploy.yml +++ b/.github/workflows/build-deploy.yml @@ -28,20 +28,28 @@ jobs: cp -r sunbirded-portal/images/ src/app/client/src/assets cp -r sunbirded-portal/resourceBundles/data/ src/app/resourcebundles/ - - name: Build and Archive Artifacts + - name: Build run: | commit_hash=$(git rev-parse --short HEAD) build_tag=$(echo "${{ github.ref }}" | rev | cut -d/ -f1 | rev)_${commit_hash}_${GITHUB_RUN_NUMBER} echo "build_tag: $build_tag" - bash ./build.sh $build_tag test1 test2 test3 test4 test5 - cp metadata.json $GITHUB_WORKSPACE/metadata.json - if [[ "${{ github.event.inputs.buildCdnAssests }}" == 'true' ]]; then - mkdir -p cdn_assets - cp -r src/app/dist-cdn/* cdn_assets/ - zip -Jr cdn_assets.zip cdn_assets - cp cdn_assets.zip $GITHUB_WORKSPACE/cdn_assets.zip - fi + bash ./build.sh "${build_tag}" "${{ env.NODE_NAME }}" "test" true false "" + env: + NODE_NAME: "18.20.2" + + - name: Archive Artifacts + uses: actions/upload-artifact@v2 + with: + name: metadata + path: metadata.json + + - name: Archive CDN assets if required + if: ${{ github.event.inputs.buildCdnAssests == 'true' }} + run: | + rm -rf cdn_assets + mkdir cdn_assets + cp -r src/app/dist-cdn/* cdn_assets/ + zip -Jr cdn_assets.zip cdn_assets + echo "##vso[task.uploadfile]cdn_assets.zip" env: WL_Customization: ${{ github.event.inputs.WL_Customization }} - NODE_NAME: ${{ env.NODE_NAME }} - HUB_ORG: ${{ env.HUB_ORG }} From d9c882be879d5180479be12a51add35506ab28fc Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Tue, 11 Jun 2024 14:13:57 +0530 Subject: [PATCH 32/34] ED-4000 feat: Github actions instead of Jenkins-test --- .github/workflows/build-deploy.yml | 41 +++++++++++++++--------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml index a37bfd20167..55bbe5a0f11 100644 --- a/.github/workflows/build-deploy.yml +++ b/.github/workflows/build-deploy.yml @@ -10,32 +10,35 @@ on: jobs: build_and_deploy: + name: Build and Deploy Job # Define the name of the job runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v2 # Checkout the repository code - name: Set up Node.js uses: actions/setup-node@v2 with: - node-version: "18" + node-version: "18.20.2" # Set up Node.js version 18 - name: Customize dependencies - if: ${{ env.WL_Customization != null }} + if: ${{ env.WL_Customization != null }} # Conditional step execution run: | - git clone --recurse-submodules ${WL_Customization} sunbirded-portal - cp -r sunbirded-portal/images/ src/app/client/src/assets - cp -r sunbirded-portal/resourceBundles/data/ src/app/resourcebundles/ + git clone --recurse-submodules ${WL_Customization} sunbirded-portal # Clone repository with submodules + cp -r sunbirded-portal/images/ src/app/client/src/assets # Copy images to client assets + cp -r sunbirded-portal/resourceBundles/data/ src/app/resourcebundles/ # Copy resource bundle data + env: + WL_Customization: ${{ github.event.inputs.WL_Customization }} # Set environment variable WL_Customization - - name: Build + - name: Build and Create Docker Image run: | - commit_hash=$(git rev-parse --short HEAD) - build_tag=$(echo "${{ github.ref }}" | rev | cut -d/ -f1 | rev)_${commit_hash}_${GITHUB_RUN_NUMBER} - echo "build_tag: $build_tag" - bash ./build.sh "${build_tag}" "${{ env.NODE_NAME }}" "test" true false "" + 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 + bash ./build.sh "${build_tag}" "${{ env.NODE_NAME }}" "test" true false "" # Run build script with parameters env: - NODE_NAME: "18.20.2" + NODE_NAME: "18.20.2" # Set environment variable NODE_NAME - name: Archive Artifacts uses: actions/upload-artifact@v2 @@ -44,12 +47,10 @@ jobs: path: metadata.json - name: Archive CDN assets if required - if: ${{ github.event.inputs.buildCdnAssests == 'true' }} + if: ${{ github.event.inputs.buildCdnAssests == 'true' }} # Conditional step execution run: | - rm -rf cdn_assets - mkdir cdn_assets - cp -r src/app/dist-cdn/* cdn_assets/ - zip -Jr cdn_assets.zip cdn_assets - echo "##vso[task.uploadfile]cdn_assets.zip" - env: - WL_Customization: ${{ github.event.inputs.WL_Customization }} + rm -rf cdn_assets # Remove existing CDN assets directory + mkdir cdn_assets # Create CDN assets directory + cp -r src/app/dist-cdn/* cdn_assets/ # Copy CDN assets + zip -Jr cdn_assets.zip cdn_assets # Create zip file of CDN assets + echo "##vso[task.uploadfile]cdn_assets.zip" # Upload CDN assets zip file From 421533bfa1d762f87ee0edf785031e75ded58454 Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Tue, 11 Jun 2024 23:06:45 +0530 Subject: [PATCH 33/34] ED-4000 feat: Github actions instead of Jenkins-test --- .circleci/config.yml | 57 +++++++++++++ .github/workflows/build-deploy.yml | 4 +- .github/workflows/ci-cd.yml | 124 ++++++++++++++--------------- 3 files changed, 119 insertions(+), 66 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e69de29bb2d..681cfa58b5b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -0,0 +1,57 @@ +version: 2.1 +jobs: + build: + docker: + - image: cimg/node:18.16.0 + steps: + - checkout + - run: + name: run build file + command: /bin/bash -x build.sh ${CIRCLE_SHA1} test + test-cases: + working_directory: ~/portal/src/app/client + docker: + # Ref: https://circleci.com/docs/2.0/configuration-reference/#available-machine-images + - image: cimg/node:18.16.0 + resource_class: large + steps: + - checkout: + path: ~/portal + - run: + # Using NodeJS version 16 + name: Installing prerequisites + command: |- + node --version + - run: + name: ignore-engines + command: 'yarn config set ignore-engines true' + - run: + name: Installing npm deps + command: 'yarn install' + - save_cache: # special step to save the dependency cache + key: dependency-cache-portal-{{ checksum "package.json" }} + paths: + - ./node_modules + # - run: + # name: ng lint and building + # command: 'mkdir -p /tmp/logs && node --max_old_space_size=6000 ./node_modules/@angular/cli/bin/ng build --prod --optimization=false --buildOptimizer=false | tee /tmp/logs/build.log' + - run: + name: Executing test cases using JEST + command: 'npm run test:ci' + - run: + name: Install Sonar Scanner + command: | + cd /tmp + wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-5.0.1.3006-linux.zip + unzip || sudo apt install unzip -y + unzip sonar-scanner-cli-5.0.1.3006-linux.zip + cd - + - run: + name: run sonar scanner + command: 'cd ~/portal && /tmp/sonar-scanner-5.0.1.3006-linux/bin/sonar-scanner' +workflows: + version: 2 + build_and_test: + jobs: + - test-cases + \ No newline at end of file diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml index 55bbe5a0f11..ede1f295fa6 100644 --- a/.github/workflows/build-deploy.yml +++ b/.github/workflows/build-deploy.yml @@ -3,10 +3,10 @@ name: Build and Deploy on: push: branches: - - "*" # Trigger on push to any branch + - "deploy" # Trigger on push to any branch pull_request: branches: - - "*" # Trigger on pull request to any branch + - "deploy" # Trigger on pull request to any branch jobs: build_and_deploy: diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index b34fbd2c41a..b9ad172c8fd 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -3,10 +3,10 @@ name: CI/CD on: push: branches: - - "test" # Trigger on push to any branch + - "*" # Trigger on push to any branch pull_request: branches: - - "trst" # Trigger on pull request to any branch + - "*" # Trigger on pull request to any branch jobs: build-and-test: @@ -27,17 +27,14 @@ jobs: # - 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 @@ -48,7 +45,6 @@ jobs: # 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 @@ -58,22 +54,18 @@ jobs: # 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 @@ -85,27 +77,31 @@ jobs: # 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 - + #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.projectKey=Sunbird-Ed_SunbirdEd-portal \ + -Dsonar.sources=src/app/client/src \ + -Dsonar.host.url=https://sonarcloud.io \ + -Dsonar.organization=sunbird-ed \ + -Dsonar.login=$SONAR_TOKEN - # # 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.projectKey=your_frontend_project_key \ - # -Dsonar.sources=src \ - # -Dsonar.host.url=https://sonarcloud.io \ - # -Dsonar.organization=your_organization \ - # -Dsonar.login=$SONAR_TO # - name: Run Sonar Scanner # env: # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} @@ -118,40 +114,40 @@ jobs: # -Dsonar.login=$SONAR_TOKEN # Install SonarScanner globally using npm - - name: Install SonarScanner - run: - npm install -g sonarqube-scanner + # - 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 + # # Check if SONAR_TOKEN is set + # - name: Check SONAR_TOKEN + # run: | + # if [ -z "${{ secrets.SONAR_TOKEN }}" ]; then + # echo "Error: SONAR_TOKEN is not set." - # 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 + # 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 From 8fffecfe8c089f5d722866269995127af5acb541 Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Wed, 12 Jun 2024 12:10:00 +0530 Subject: [PATCH 34/34] ED-4000 feat: Github actions instead of Jenkins-test --- .github/workflows/ci-cd.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index b9ad172c8fd..5c08225c2c9 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -96,10 +96,8 @@ jobs: 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.host.url=https://sonarcloud.io \ - -Dsonar.organization=sunbird-ed \ -Dsonar.login=$SONAR_TOKEN # - name: Run Sonar Scanner