Skip to content

Commit

Permalink
Merge pull request #9303 from princegupta1131/8.0.0_github_action
Browse files Browse the repository at this point in the history
@princegupta1131 ED-4000 feat: Github actions instead of Jenkins
  • Loading branch information
rajeevsathish authored Jun 10, 2024
2 parents 69dc225 + 5f0a8c2 commit 590db58
Show file tree
Hide file tree
Showing 109 changed files with 5,618 additions and 1,199 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,4 @@ workflows:
build_and_test:
jobs:
- test-cases

106 changes: 106 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: CI/CD

on:
push:
branches:
- "*" # Trigger on push to any branch
pull_request:
branches:
- "*" # Trigger on pull request to any branch

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
# 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: 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
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,10 @@ Installing Sunbird requires two primary software components:

| Plugin Name | Plugin Repository | npm version | NG Version |
|-------------------------------------------------------------------------------------------------------------- |------------------------------------------------------------------ |------------- |------------ |
| [@project-sunbird/chatbot-client](https://www.npmjs.com/package/@project-sunbird/chatbot-client) | https://github.com/project-sunbird/sunbird-bot-client | 4.0.0 | NG 13 |
| [@project-sunbird/common-consumption](https://www.npmjs.com/package/@project-sunbird/common-consumption) | https://github.com/Sunbird-Ed/SunbirdEd-consumption-ngcomponents | 6.0.0 | NG 13 |
| [@project-sunbird/common-form-elements-full](https://www.npmjs.com/package/@project-sunbird/common-form-elements-full) | https://github.com/Sunbird-Ed/SunbirdEd-forms | 6.0.0 | NG 14 |
| [@project-sunbird/sb-content-section](https://www.npmjs.com/package/@project-sunbird/sb-content-section) | https://github.com/Sunbird-Ed/sb-content-module | 6.0.0 | NG 13 |
| [@project-sunbird/sb-notification](https://www.npmjs.com/package/@project-sunbird/sb-notification) | https://github.com/Sunbird-Ed/sb-notification | 6.0.0 | NG 14 |
| [@shikshalokam/sl-questionnaire](https://www.npmjs.com/package/@shikshalokam/sl-questionnaire) | https://github.com/shikshalokam/sl-questionnaire-components | 2.3.0 | NG 12 |
| [@shikshalokam/sl-reports-library](https://www.npmjs.com/package/@shikshalokam/sl-reports-library) | https://github.com/shikshalokam/sl-reports-library | 3.0.1 | NG 14 |
| [@project-sunbird/chatbot-client](https://www.npmjs.com/package/@project-sunbird/chatbot-client) | https://github.com/project-sunbird/sunbird-bot-client | 8.0.1 | NG 16 |
| [@project-sunbird/common-consumption](https://www.npmjs.com/package/@project-sunbird/common-consumption) | https://github.com/Sunbird-Ed/SunbirdEd-consumption-ngcomponents | 8.0.2 | NG 16 |
| [@project-sunbird/common-form-elements-full](https://www.npmjs.com/package/@project-sunbird/common-form-elements-full) | https://github.com/Sunbird-Ed/SunbirdEd-forms | 8.0.1 | NG 16 |
| [@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 |
23 changes: 12 additions & 11 deletions src/app/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"inject-cdn-fallback": "gulp inject:cdnFallBack:script",
"with-stats": "node --max_old_space_size=8096 node_modules/.bin/ng build --configuration production --stats-json",
"build:stats": "ng build --stats-json",
"analyze": "webpack-bundle-analyzer dist/stats.json"
"analyze": "webpack-bundle-analyzer dist/stats.json",
"test-for-file": "./node_modules/jest/bin/jest.js --clearCache && node --max_old_space_size=2048 ./node_modules/jest/bin/jest.js telemetry-interact.directive.spec --ci --collectCoverage=true --coverageReporters=lcov"
},
"nodemonConfig": {
"ext": "png,jpeg,js,ts,html,json,css,scss"
Expand Down Expand Up @@ -63,31 +64,31 @@
"@project-sunbird/common-consumption": "8.0.2",
"@project-sunbird/common-form-elements-full": "8.0.1",
"@project-sunbird/discussions-ui": "8.0.1",
"@project-sunbird/ng2-semantic-ui": "8.0.2",
"@project-sunbird/ng2-semantic-ui": "^8.0.3",
"@project-sunbird/sb-content-section": "8.0.1",
"@project-sunbird/sb-dashlet": "8.0.2",
"@project-sunbird/sb-notification": "8.0.1",
"@project-sunbird/sb-styles": "0.0.16",
"@project-sunbird/sb-styles": "0.0.17",
"@project-sunbird/sb-svg2pdf": "8.0.1",
"@project-sunbird/sb-themes": "8.0.5",
"@project-sunbird/sunbird-collection-editor": "5.4.10",
"@project-sunbird/sb-themes": "8.0.8",
"@project-sunbird/sunbird-collection-editor": "6.1.0",
"@project-sunbird/sunbird-epub-player-v9": "5.6.0",
"@project-sunbird/sunbird-epub-player-web-component": "1.2.0",
"@project-sunbird/sunbird-file-upload-library": "1.0.2",
"@project-sunbird/sunbird-pdf-player-v9": "5.5.0",
"@project-sunbird/sunbird-pdf-player-web-component": "1.4.0",
"@project-sunbird/sunbird-questionset-editor": "8.0.1",
"@project-sunbird/sunbird-questionset-editor": "8.0.3",
"@project-sunbird/sunbird-quml-player": "7.0.3",
"@project-sunbird/sunbird-quml-player-v9": "5.1.5",
"@project-sunbird/sunbird-quml-player-web-component": "4.0.0",
"@project-sunbird/sunbird-resource-library": "8.0.0",
"@project-sunbird/sunbird-quml-player-web-component": "4.0.2",
"@project-sunbird/sunbird-resource-library": "8.0.2",
"@project-sunbird/sunbird-video-player-v9": "5.5.1",
"@project-sunbird/sunbird-video-player-web-component": "1.1.1",
"@project-sunbird/telemetry-sdk": "1.3.0",
"@project-sunbird/web-extensions": "8.0.1",
"@samagra-x/uci-console": "6.0.3",
"uci-console-v16": "8.0.0",
"@shikshalokam/sl-questionnaire": "7.0.0",
"@shikshalokam/sl-reports-library": "3.0.1",
"@shikshalokam/sl-reports-library": "6.0.0",
"@swimlane/ngx-datatable": "20.1.0",
"@types/jquery": "3.3.31",
"@types/jquery.fancytree": "2.7.34",
Expand Down Expand Up @@ -244,4 +245,4 @@
"jest-preset-angular/build/serializers/html-comment"
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
border-radius: calculateRem(6px);
box-shadow: var(--sbt-box-shadow-6px);
font-size: calculateRem(12px);
font-weight: bold;
font-weight: 500;
margin-right: calculateRem(12px);
height: calculateRem(48px);
transition: all ease .3s;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('DataService', () => {

it('should return observableThrowError for failed POST request', (done) => {
const mockErrorResponse = { responseCode: 'ERROR', data: 'Error data' };
jest.spyOn(mockHttpClient, 'post').mockReturnValue(throwError(mockErrorResponse));
jest.spyOn(mockHttpClient, 'post').mockReturnValue(of(mockErrorResponse));
(dayjs as any).mockReturnValue({ format: jest.fn(() => 'formatDate') });
dataService.post({
url: '/mock-url',
Expand Down Expand Up @@ -114,7 +114,7 @@ describe('DataService', () => {

it('should handle error for failed PATCH request', (done) => {
const mockErrorResponse = { responseCode: 'ERROR', data: 'Error data' };
jest.spyOn(mockHttpClient, 'patch').mockReturnValue(throwError(mockErrorResponse));
jest.spyOn(mockHttpClient, 'patch').mockReturnValue(of(mockErrorResponse));
(dayjs as any).mockReturnValue({ format: jest.fn(() => 'formatDate') });
dataService.patch({
url: '/mock-url',
Expand Down Expand Up @@ -142,7 +142,7 @@ describe('DataService', () => {

it('should handle error for failed DELETE request', (done) => {
const mockErrorResponse = { responseCode: 'ERROR', data: 'Error data' };
jest.spyOn(mockHttpClient, 'delete').mockReturnValue(throwError(mockErrorResponse));
jest.spyOn(mockHttpClient, 'delete').mockReturnValue(of(mockErrorResponse));
(dayjs as any).mockReturnValue({ format: jest.fn(() => 'formatDate') });
dataService.delete({
url: '/mock-url',
Expand Down Expand Up @@ -170,7 +170,7 @@ describe('DataService', () => {

it('should handle error for failed PUT request', (done) => {
const mockErrorResponse = { responseCode: 'ERROR', data: 'Error data' };
jest.spyOn(mockHttpClient, 'put').mockReturnValue(throwError(mockErrorResponse));
jest.spyOn(mockHttpClient, 'put').mockReturnValue(of(mockErrorResponse));
(dayjs as any).mockReturnValue({ format: jest.fn(() => 'formatDate') });
dataService.put({
url: '/mock-url',
Expand Down Expand Up @@ -286,5 +286,25 @@ describe('DataService', () => {
});
});
});
it('should handle successful POST request with headers', async () => {
jest.spyOn(document, 'getElementById').mockImplementation((data) => {
return { value: '32cef05697d1ab3a8049c0e8981bcc79' } as any;
});
dataService.rootOrgId = '1234567890';
dataService.channelId = '1234567890';
DataService.userId = 'user_123';
const mockResponse = { responseCode: 'OK', data: 'Mock data' };
const mockHeaders = { get: jest.fn(() => '2023-01-01T12:00:00Z') };

jest.spyOn(mockHttpClient, 'post').mockReturnValue(of({ body: mockResponse, headers: mockHeaders }));
(dayjs as any).mockReturnValue({ format: jest.fn(() => 'formatDate') });
jest.spyOn(dataService, 'getDateDiff' as any).mockReturnValue(0);

await dataService.postWithHeaders({ url: '/mock-url', data: { key: 'value' }, header: { 'Custom-Header': 'custom-value' } }).subscribe((response) => {
expect(response).toEqual(mockResponse);
expect(mockHttpClient.post).toHaveBeenCalledWith(expect.stringContaining('/mock-url'), { key: 'value' }, expect.any(Object));
expect(dataService['getDateDiff']).toHaveBeenCalledWith('2023-01-01T12:00:00Z');
});
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,104 @@ export const MockResponse = {
courseHierarchy: {
contentType: 'Course',
primaryCategory: 'Course',
trackable: {enabled: 'Yes'}
trackable: { enabled: 'Yes' }
},
courseHierarchyNew: {
contentType: 'Course',
primaryCategory: 'Course',
trackable: 'true'
},
courseHierarchyone:{
contentType: 'course',
primaryCategory: 'course',
},
courseHierarchytwo:{
contentType: 'book',
primaryCategory: 'book',
},
generaliseLblResponse: {
'result': '{"dflt":{"nontrk":{"frmelmnts":{"lbl":{"ActivityTextbooks":" Tasks","chapter":" Learning module"}},"messages":{"stmsg":{"m0125":" Start creating or uploading content. You currently do not have any content saved as a draft "}}},"trk":{"frmelmnts":{"btn":{"create":" Create ","enroll":" Join"},"tab":{"courses":" Tasks"}},"messages":{"dashboard":{"emsg":{"m002":" User has not joined any batch for this learning task"}}}}},"crs":{"nontrk":{"frmelmnts":{"lbl":{"ActivityTextbooks":" Courses","ACTIVITY_TEXTBOOK_TITLE":" Courses","desktop":{"downloadBook":" Download course","find_more":" Find more courses and related content on {instance}","updateTextbook":" Update course"},"downloadBooks":" Download courses to access while offline","fromTheTextBook":" from the course","noBookfoundTitle":" Board is adding courses","textbooks":" Courses","chapter":" Course module"}}},"trk":{"completedCourse":" Course completed","frmelmnts":{"btn":{"createCourse":" Create course"},"lbl":{"accessCourse":" Access course","accessToLogin":" To access the course you have to log in and join the course"}},"messages":{"dashboard":{"emsg":{"m002":" The user is not enrolled in any batch of this course"}}}}}}'
result:
{
'default': {
'nontrackable': {
'en': {
'frmelmnts': {
'lbl': {
'ActivityTextbooks': ' Tasks',
'chapter': ' Learning module'
}
},
'messages': {
'stmsg': {
'm0125': ' Start creating or uploading content. You currently do not have any content saved as a draft'
}
}
}
},
'trackable': {
'en': {
'frmelmnts': {
'btn': {
'create': ' Create ',
'enroll': ' Join'
},
'tab': {
'courses': ' Tasks'
}
},
'messages': {
'dashboard': {
'emsg': {
'm002': ' User has not joined any batch for this learning task'
}
}
}
}
}
},
'course': {
'nontrackable': {
'en': {
'frmelmnts': {
'lbl': {
'ActivityTextbooks': ' Courses',
'ACTIVITY_TEXTBOOK_TITLE': ' Courses',
'desktop': {
'downloadBook': ' Download course',
'find_more': ' Find more courses and related content on {instance}',
'updateTextbook': ' Update course'
},
'downloadBooks': ' Download courses to access while offline',
'fromTheTextBook': ' from the course',
'noBookfoundTitle': ' Board is adding courses',
'textbooks': ' Courses',
'chapter': ' Course module'
}
}
}
},
'trackable': {
'en': {
'completedCourse': ' Course completed',
'frmelmnts': {
'btn': {
'createCourse': ' Create course'
},
'lbl': {
'accessCourse': ' Access course',
'accessToLogin': ' To access the course you have to log in and join the course'
}
},
'messages': {
'dashboard': {
'emsg': {
'm002': ' The user is not enrolled in any batch of this course'
}
}
}
}
}
}
}
}
};
Loading

0 comments on commit 590db58

Please sign in to comment.