From dbed7450d454fdf846d69572b99aca955e2c79b1 Mon Sep 17 00:00:00 2001 From: srakeshkumar1019 Date: Tue, 4 Jun 2024 11:30:27 +0530 Subject: [PATCH 01/27] NXP-32655: add lint & format setup --- .eslintrc.json | 47 ++++++++++++++++++++++++++++++++++++ .github/workflows/lint.yaml | 48 +++++++++++++++++++++++++++++++++++++ .prettierignore | 2 ++ .prettierrc | 5 ++++ angular.json | 7 +++++- package.json | 15 +++++++++--- 6 files changed, 120 insertions(+), 4 deletions(-) create mode 100644 .eslintrc.json create mode 100644 .github/workflows/lint.yaml create mode 100644 .prettierignore create mode 100644 .prettierrc diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 00000000..3d5fb584 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,47 @@ +{ + "root": true, + "ignorePatterns": [ + "projects/**/*" + ], + "overrides": [ + { + "files": [ + "*.ts" + ], + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/recommended", + "plugin:@angular-eslint/recommended", + "plugin:@angular-eslint/template/process-inline-templates" + ], + "rules": { + "@angular-eslint/directive-selector": [ + "error", + { + "type": "attribute", + "prefix": "app", + "style": "camelCase" + } + ], + "@angular-eslint/component-selector": [ + "error", + { + "type": "element", + "prefix": "app", + "style": "kebab-case" + } + ] + } + }, + { + "files": [ + "*.html" + ], + "extends": [ + "plugin:@angular-eslint/template/recommended", + "plugin:@angular-eslint/template/accessibility" + ], + "rules": {} + } + ] + } \ No newline at end of file diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 00000000..e21090f1 --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,48 @@ +name: Lint + +on: + pull_request: + branches: + - dev + workflow_call: + inputs: + branch: + description: 'The current branch' + default: dev + type: string + required: false + +env: + BRANCH_NAME: ${{ github.head_ref || inputs.branch || 'dev' }} + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ env.BRANCH_NAME }} + + - uses: actions/setup-node@v3 + with: + registry-url: 'https://packages.nuxeo.com/repository/npm-public/' + node-version: 20 + scope: '@nuxeo' + + - name: Configure Additional Registries + run: | + npm config set @hylandsoftware:registry https://npm.pkg.github.com --global + npm config set //npm.pkg.github.com/:_authToken=${{ secrets.GIT_TOKEN }} --global + + - name: Configure npm for Nexus Authentication + run: | + npm config set //packages.nuxeo.com/repository/npm-public/:_authToken=${{ secrets.NPM_ADMIN_TOKEN }} --global + + - name: Install @angular/cli + run: npm install -g @angular/cli + + - name: Install + run: npm install + + - name: Lint + run: npm run build diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..246d599d --- /dev/null +++ b/.prettierignore @@ -0,0 +1,2 @@ +/dist +/node_modules \ No newline at end of file diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 00000000..530d8158 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,5 @@ +{ + "singleQuote": true, + "trailingComma": "all", + "printWidth": 80 +} \ No newline at end of file diff --git a/angular.json b/angular.json index 8f3ba2f9..c2e72ec2 100644 --- a/angular.json +++ b/angular.json @@ -106,7 +106,12 @@ "includePaths": ["node_modules"] } } - } + }, + "lint": { + "builder": "@angular-eslint/builder:lint", + "options": { + "lintFilePatterns": ["src/**/*.ts", "src/**/*.html"] + } } } }, diff --git a/package.json b/package.json index 61f110b2..76f25bd8 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,9 @@ "start": "ng serve", "build": "ng build", "watch": "ng build --watch --configuration development", - "test": "ng test --code-coverage" + "test": "ng test", + "lint": "ng lint", + "format": "prettier --write \"src/**/*.{ts,html,css,scss}\"" }, "private": true, "dependencies": { @@ -34,18 +36,25 @@ }, "devDependencies": { "@angular-devkit/build-angular": "^16.2.14", + "@angular-eslint/builder": "16.3.1", + "@angular-eslint/eslint-plugin": "16.3.1", + "@angular-eslint/eslint-plugin-template": "16.3.1", + "@angular-eslint/schematics": "16.3.1", + "@angular-eslint/template-parser": "16.3.1", "@angular/cli": "^16.2.14", "@angular/compiler-cli": "^16.2.0", "@hylandsoftware/hy-ui-devkit": "^6.0.1", "@hylandsoftware/hy-ui-standards": "^6.0.1", "@types/jasmine": "~4.3.0", + "@typescript-eslint/eslint-plugin": "5.62.0", + "@typescript-eslint/parser": "5.62.0", + "eslint": "^8.51.0", "jasmine-core": "~4.6.0", "karma": "~6.4.0", "karma-chrome-launcher": "~3.2.0", "karma-coverage": "~2.2.0", - "karma-coverage-istanbul-reporter": "^3.0.3", "karma-jasmine": "~5.1.0", "karma-jasmine-html-reporter": "~2.1.0", "typescript": "~5.1.3" } -} +} \ No newline at end of file From f052e39c0afa7945acd10bb0efe201f252280b1e Mon Sep 17 00:00:00 2001 From: sushildeep Date: Wed, 5 Jun 2024 17:30:22 +0530 Subject: [PATCH 02/27] add lint build --- .github/workflows/build.yaml | 71 ++++++++++++++++++++++++++++++++++++ .github/workflows/lint.yaml | 13 +++---- 2 files changed, 76 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/build.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 00000000..750f5d87 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,71 @@ +name: Build and Publish + +on: +#pull_request: +#branches: +#- dev + workflow_dispatch: + inputs: + branch: + description: 'The current branch' + default: dev + type: string + required: false + debug: + type: boolean + description: enable debug + default: false + +env: + BRANCH_NAME: ${{ github.head_ref || inputs.branch || 'dev' }} + enabledebug: ${{ inputs.debug == true && '-vvv' || ''}} + NEXUS_URL: https://packages.nuxeo.com/repository/npm-public/ + NEXUS_REPOSITORY: npm-public + NODE_AUTH_TOKEN: ${{ secrets.NPM_ADMIN_TOKEN }} + GIT_TOKEN: ${{ secrets.GIT_TOKEN}} + +jobs: + build-and-publish: + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + ref: ${{ env.BRANCH_NAME }} + + - name: Remove .npmrc file if exists + run: | + if [ -f .npmrc ]; then + rm .npmrc + fi + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + registry-url: ${{ env.NEXUS_URL }} + scope: '@nuxeo' + + - name: Configure Additional Registries + run: | + npm config set @hylandsoftware:registry https://npm.pkg.github.com --global + npm config set //npm.pkg.github.com/:_authToken=${{ secrets.GIT_TOKEN }} --global + npm config set //packages.nuxeo.com/repository/npm-public/:_authToken=${{ secrets.NPM_ADMIN_TOKEN }} --global + npm config set registry https://registry.npmjs.org/ --global + + - name: Verify npm Configuration + run: cat ~/.npmrc + + - name: Install Angular CLI + run: npm install -g @angular/cli + + - name: Install Dependencies + run: npm install + + - name: Build Angular Project + run: npm run build + + - name: Publish to Nexus + run: npm publish --registry=https://packages.nuxeo.com/repository/npm-public/ + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_ADMIN_TOKEN }} diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index e21090f1..1c80d854 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -19,11 +19,11 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: ref: ${{ env.BRANCH_NAME }} - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: registry-url: 'https://packages.nuxeo.com/repository/npm-public/' node-version: 20 @@ -33,16 +33,13 @@ jobs: run: | npm config set @hylandsoftware:registry https://npm.pkg.github.com --global npm config set //npm.pkg.github.com/:_authToken=${{ secrets.GIT_TOKEN }} --global - - - name: Configure npm for Nexus Authentication - run: | - npm config set //packages.nuxeo.com/repository/npm-public/:_authToken=${{ secrets.NPM_ADMIN_TOKEN }} --global + npm config set registry https://registry.npmjs.org/ --global - name: Install @angular/cli run: npm install -g @angular/cli - - name: Install + - name: Install Node run: npm install - name: Lint - run: npm run build + run: npm run lint From 7f68be5d0434a860cad03f5185ef437d07a47e20 Mon Sep 17 00:00:00 2001 From: sushildeep Date: Wed, 5 Jun 2024 17:34:14 +0530 Subject: [PATCH 03/27] fix --- .github/workflows/lint.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 1c80d854..3564cb29 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -22,7 +22,12 @@ jobs: - uses: actions/checkout@v4 with: ref: ${{ env.BRANCH_NAME }} - + + - name: Remove .npmrc file if exists + run: | + if [ -f .npmrc ]; then + rm .npmrc + fi - uses: actions/setup-node@v4 with: registry-url: 'https://packages.nuxeo.com/repository/npm-public/' From 97b93bf4f0466fc855bc700f804dc0a3a414f0c7 Mon Sep 17 00:00:00 2001 From: sushildeep Date: Wed, 5 Jun 2024 17:43:11 +0530 Subject: [PATCH 04/27] remove verify config --- .github/workflows/build.yaml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 750f5d87..e7fd92ef 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -38,7 +38,7 @@ jobs: if [ -f .npmrc ]; then rm .npmrc fi - + - name: Setup Node.js uses: actions/setup-node@v4 with: @@ -53,9 +53,6 @@ jobs: npm config set //packages.nuxeo.com/repository/npm-public/:_authToken=${{ secrets.NPM_ADMIN_TOKEN }} --global npm config set registry https://registry.npmjs.org/ --global - - name: Verify npm Configuration - run: cat ~/.npmrc - - name: Install Angular CLI run: npm install -g @angular/cli From ac5ad2b262c606579410ffd05c2e537ac493d99a Mon Sep 17 00:00:00 2001 From: sushildeep Date: Wed, 5 Jun 2024 17:52:50 +0530 Subject: [PATCH 05/27] remove private --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 76f25bd8..da809402 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,6 @@ "lint": "ng lint", "format": "prettier --write \"src/**/*.{ts,html,css,scss}\"" }, - "private": true, "dependencies": { "@angular/animations": "^16.2.0", "@angular/common": "^16.2.0", From 14be1c8af440fc9e05220e2c8769491c420e9999 Mon Sep 17 00:00:00 2001 From: sushildeep Date: Wed, 5 Jun 2024 18:04:26 +0530 Subject: [PATCH 06/27] add verify step --- .github/workflows/lint.yaml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 3564cb29..7a7945e3 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -22,7 +22,7 @@ jobs: - uses: actions/checkout@v4 with: ref: ${{ env.BRANCH_NAME }} - + - name: Remove .npmrc file if exists run: | if [ -f .npmrc ]; then @@ -44,7 +44,14 @@ jobs: run: npm install -g @angular/cli - name: Install Node - run: npm install + run: npm install + + - name: Verify angular.json exists + run: | + if [ ! -f angular.json ]; then + echo "angular.json file not found" + exit 1 + fi - name: Lint run: npm run lint From 675ffa378151551ea6db1d3c4df82d089467ab5e Mon Sep 17 00:00:00 2001 From: sushildeep Date: Wed, 5 Jun 2024 18:30:32 +0530 Subject: [PATCH 07/27] add verify step --- .github/workflows/lint.yaml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 7a7945e3..85733d69 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -43,15 +43,24 @@ jobs: - name: Install @angular/cli run: npm install -g @angular/cli - - name: Install Node + - name: Install Dependencies run: npm install - + + - name: Print Working Directory + run: pwd + + - name: List Files in Root + run: ls -la + - name: Verify angular.json exists run: | if [ ! -f angular.json ]; then - echo "angular.json file not found" + echo "angular.json file not found in $(pwd)" exit 1 fi - + + - name: Print angular.json contents + run: cat angular.json + - name: Lint run: npm run lint From d14aecb62c40a10562023f8b92d1e92b91119b08 Mon Sep 17 00:00:00 2001 From: sushildeep Date: Thu, 6 Jun 2024 12:03:42 +0530 Subject: [PATCH 08/27] add root project --- .github/workflows/lint.yaml | 16 ----------- angular.json | 53 ++++++++++++++++++++++++++----------- 2 files changed, 38 insertions(+), 31 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 85733d69..e744117c 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -45,22 +45,6 @@ jobs: - name: Install Dependencies run: npm install - - - name: Print Working Directory - run: pwd - - - name: List Files in Root - run: ls -la - - - name: Verify angular.json exists - run: | - if [ ! -f angular.json ]; then - echo "angular.json file not found in $(pwd)" - exit 1 - fi - - - name: Print angular.json contents - run: cat angular.json - name: Lint run: npm run lint diff --git a/angular.json b/angular.json index c2e72ec2..44f1bff1 100644 --- a/angular.json +++ b/angular.json @@ -6,7 +6,7 @@ "mediumclone_angular": { "projectType": "application", "schematics": {}, - "root": "", + "root": "src", "sourceRoot": "src", "prefix": "app", "architect": { @@ -26,12 +26,21 @@ "output": "./" } ], - "styles": ["src/styles.scss"], + "styles": [ + "src/styles.scss" + ], "scripts": [], - "i18nPaths": ["src/app"], - "i18nModules": ["@hyland/ui", "@hyland/ui-shell"], + "i18nPaths": [ + "src/app" + ], + "i18nModules": [ + "@hyland/ui", + "@hyland/ui-shell" + ], "stylePreprocessorOptions": { - "includePaths": ["node_modules"] + "includePaths": [ + "node_modules" + ] } }, "configurations": { @@ -97,25 +106,39 @@ "test": { "builder": "@angular-devkit/build-angular:karma", "options": { - "polyfills": ["src/polyfills.ts", "zone.js", "zone.js/testing"], + "polyfills": [ + "src/polyfills.ts", + "zone.js", + "zone.js/testing" + ], "tsConfig": "tsconfig.spec.json", - "assets": ["src/favicon.ico", "src/assets"], - "styles": ["src/styles.scss"], + "assets": [ + "src/favicon.ico", + "src/assets" + ], + "styles": [ + "src/styles.scss" + ], "scripts": [], "stylePreprocessorOptions": { - "includePaths": ["node_modules"] + "includePaths": [ + "node_modules" + ] } } }, "lint": { "builder": "@angular-eslint/builder:lint", "options": { - "lintFilePatterns": ["src/**/*.ts", "src/**/*.html"] + "lintFilePatterns": [ + "src/**/*.ts", + "src/**/*.html" + ] } + } } + }, + "cli": { + "analytics": "7fa2cc0e-3e82-45f7-bedc-bce83c5ba0d7" } - }, - "cli": { - "analytics": "7fa2cc0e-3e82-45f7-bedc-bce83c5ba0d7" - } -} + } \ No newline at end of file From 5f5ab334b2a5f65d5980e118a21d9586e1a7b732 Mon Sep 17 00:00:00 2001 From: sushildeep Date: Thu, 6 Jun 2024 12:16:13 +0530 Subject: [PATCH 09/27] add root --- angular.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/angular.json b/angular.json index 44f1bff1..ce0ca92c 100644 --- a/angular.json +++ b/angular.json @@ -139,6 +139,7 @@ } }, "cli": { - "analytics": "7fa2cc0e-3e82-45f7-bedc-bce83c5ba0d7" + "analytics": "7fa2cc0e-3e82-45f7-bedc-bce83c5ba0d7", + "root": "src" } } \ No newline at end of file From ac3be8b6a0cd78ed034bc35750e9dc1bc1a4ad89 Mon Sep 17 00:00:00 2001 From: sushildeep Date: Thu, 6 Jun 2024 12:20:56 +0530 Subject: [PATCH 10/27] add root --- angular.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/angular.json b/angular.json index ce0ca92c..2725c1c9 100644 --- a/angular.json +++ b/angular.json @@ -139,7 +139,7 @@ } }, "cli": { - "analytics": "7fa2cc0e-3e82-45f7-bedc-bce83c5ba0d7", "root": "src" } - } \ No newline at end of file + } +} \ No newline at end of file From 07337ef8a78bb5eabd1c8d893b097051e0b82013 Mon Sep 17 00:00:00 2001 From: sushildeep Date: Fri, 7 Jun 2024 12:18:35 +0530 Subject: [PATCH 11/27] add ut wk --- .github/workflows/build.yaml | 2 +- .github/workflows/utest.yaml | 50 ++++++++++++++++++++++++++++++++++++ angular.json | 3 +++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/utest.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index e7fd92ef..00be0bf8 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -63,6 +63,6 @@ jobs: run: npm run build - name: Publish to Nexus - run: npm publish --registry=https://packages.nuxeo.com/repository/npm-public/ + run: npm publish --@nuxeo:registry=https://packages.nuxeo.com/repository/npm-public/ env: NODE_AUTH_TOKEN: ${{ secrets.NPM_ADMIN_TOKEN }} diff --git a/.github/workflows/utest.yaml b/.github/workflows/utest.yaml new file mode 100644 index 00000000..8d489ee2 --- /dev/null +++ b/.github/workflows/utest.yaml @@ -0,0 +1,50 @@ +name: Lint + +on: + pull_request: + branches: + - dev + workflow_call: + inputs: + branch: + description: 'The current branch' + default: dev + type: string + required: false + +env: + BRANCH_NAME: ${{ github.head_ref || inputs.branch || 'dev' }} + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ env.BRANCH_NAME }} + + - name: Remove .npmrc file if exists + run: | + if [ -f .npmrc ]; then + rm .npmrc + fi + - uses: actions/setup-node@v4 + with: + registry-url: 'https://packages.nuxeo.com/repository/npm-public/' + node-version: 20 + scope: '@nuxeo' + + - name: Configure Additional Registries + run: | + npm config set @hylandsoftware:registry https://npm.pkg.github.com --global + npm config set //npm.pkg.github.com/:_authToken=${{ secrets.GIT_TOKEN }} --global + npm config set registry https://registry.npmjs.org/ --global + + - name: Install @angular/cli + run: npm install -g @angular/cli + + - name: Install Dependencies + run: npm install + + - name: Unit tests + run: npm run test diff --git a/angular.json b/angular.json index 2725c1c9..ce06a815 100644 --- a/angular.json +++ b/angular.json @@ -141,5 +141,8 @@ "cli": { "root": "src" } + }, + "cli": { + "analytics": false } } \ No newline at end of file From 2bdb9ef4b829717e6bd7d6c96d51874ec0501a2e Mon Sep 17 00:00:00 2001 From: sushildeep Date: Fri, 7 Jun 2024 12:19:08 +0530 Subject: [PATCH 12/27] add ut wk --- .github/workflows/utest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/utest.yaml b/.github/workflows/utest.yaml index 8d489ee2..68b78753 100644 --- a/.github/workflows/utest.yaml +++ b/.github/workflows/utest.yaml @@ -1,4 +1,4 @@ -name: Lint +name: Utest on: pull_request: From eb19777518393633c052869237f5e8dbbbb350bd Mon Sep 17 00:00:00 2001 From: sushildeep Date: Fri, 7 Jun 2024 12:20:13 +0530 Subject: [PATCH 13/27] add ut wk --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 00be0bf8..d9d5ade2 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,4 +1,4 @@ -name: Build and Publish +name: Build on: #pull_request: From 31049f01c2f28f385d3577ddcdd8188880742345 Mon Sep 17 00:00:00 2001 From: sushildeep Date: Fri, 7 Jun 2024 12:23:31 +0530 Subject: [PATCH 14/27] add ut wk --- .github/workflows/utest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/utest.yaml b/.github/workflows/utest.yaml index 68b78753..f66ce868 100644 --- a/.github/workflows/utest.yaml +++ b/.github/workflows/utest.yaml @@ -1,4 +1,4 @@ -name: Utest +name: Unit-test on: pull_request: From 9b973af014b0a9ff6d7a154a35b61275837d964a Mon Sep 17 00:00:00 2001 From: sushildeep Date: Fri, 7 Jun 2024 12:26:51 +0530 Subject: [PATCH 15/27] change jobs name --- .github/workflows/utest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/utest.yaml b/.github/workflows/utest.yaml index f66ce868..3ed63ea7 100644 --- a/.github/workflows/utest.yaml +++ b/.github/workflows/utest.yaml @@ -16,7 +16,7 @@ env: BRANCH_NAME: ${{ github.head_ref || inputs.branch || 'dev' }} jobs: - lint: + utest: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 From c74841a3e4ec256f66688bb67d60b18cffb4fd14 Mon Sep 17 00:00:00 2001 From: sushildeep Date: Fri, 7 Jun 2024 12:48:53 +0530 Subject: [PATCH 16/27] change jobs name --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index d9d5ade2..81eb0614 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -51,7 +51,7 @@ jobs: npm config set @hylandsoftware:registry https://npm.pkg.github.com --global npm config set //npm.pkg.github.com/:_authToken=${{ secrets.GIT_TOKEN }} --global npm config set //packages.nuxeo.com/repository/npm-public/:_authToken=${{ secrets.NPM_ADMIN_TOKEN }} --global - npm config set registry https://registry.npmjs.org/ --global + npm config set "@nuxeo:registry" "https://packages.nuxeo.com/repository/npm-public" --global - name: Install Angular CLI run: npm install -g @angular/cli From d391699e8fa8dc0a329f52b62967c3c3e9edcfad Mon Sep 17 00:00:00 2001 From: srakeshkumar1019 Date: Tue, 4 Jun 2024 11:30:27 +0530 Subject: [PATCH 17/27] NXP-32655: add lint & format setup --- .eslintrc.json | 47 ++++++++++++++ .github/workflows/lint.yaml | 45 +++++++++++++ .husky/pre-commit | 6 ++ .npmrc | 3 - angular.json | 64 ++++++++++++++----- package.json | 22 ++++++- src/app/app.component.spec.ts | 9 ++- src/app/app.component.ts | 2 +- src/app/app.module.ts | 4 +- .../SSO/hylandSSOManager.component.ts | 4 +- .../auth/services/auth-interceptor.service.ts | 1 - .../warning/warning.component.spec.ts | 7 +- src/app/features/warning/warning.component.ts | 2 +- .../backendErrorMessages.component.ts | 2 +- .../shared/services/common.service.spec.ts | 2 +- src/app/shared/services/common.service.ts | 2 +- .../services/persistence.service.spec.ts | 3 +- .../shared/services/persistence.service.ts | 4 +- 18 files changed, 190 insertions(+), 39 deletions(-) create mode 100644 .eslintrc.json create mode 100644 .github/workflows/lint.yaml create mode 100644 .husky/pre-commit delete mode 100644 .npmrc diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 00000000..cb3286cb --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,47 @@ +{ + "root": true, + "ignorePatterns": [ + "projects/**/*" + ], + "overrides": [ + { + "files": [ + "*.ts" + ], + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/recommended", + "plugin:@angular-eslint/recommended", + "plugin:@angular-eslint/template/process-inline-templates" + ], + "rules": { + "@angular-eslint/directive-selector": [ + "error", + { + "type": "attribute", + "prefix": "", + "style": "camelCase" + } + ], + "@angular-eslint/component-selector": [ + "error", + { + "type": "element", + "prefix": "", + "style": "kebab-case" + } + ] + } + }, + { + "files": [ + "*.html" + ], + "extends": [ + "plugin:@angular-eslint/template/recommended", + "plugin:@angular-eslint/template/accessibility" + ], + "rules": {} + } + ] + } \ No newline at end of file diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 00000000..e087365e --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,45 @@ +name: Lint + +on: + pull_request: + branches: + - dev + workflow_call: + inputs: + branch: + description: 'The current branch' + default: dev + type: string + required: false + +env: + BRANCH_NAME: ${{ github.head_ref || inputs.branch || 'dev' }} + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ env.BRANCH_NAME }} + + - uses: actions/setup-node@v3 + with: + registry-url: 'https://packages.nuxeo.com/repository/npm-public/' + node-version: 20 + scope: '@nuxeo' + + - name: Configure Additional Registries + run: | + npm config set @hylandsoftware:registry https://npm.pkg.github.com --global + npm config set //npm.pkg.github.com/:_authToken=${{ secrets.GIT_TOKEN }} --global + npm config set registry https://registry.npmjs.org/ --global + + - name: Install @angular/cli + run: npm install -g @angular/cli + + - name: Install + run: npm install + + - name: Lint + run: npm run lint diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 00000000..549b2316 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,6 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +echo "Running pre-commit hook..." +npm run lint +echo "Linting completed." diff --git a/.npmrc b/.npmrc deleted file mode 100644 index fb2ceaa7..00000000 --- a/.npmrc +++ /dev/null @@ -1,3 +0,0 @@ -@hylandsoftware:registry=https://npm.pkg.github.com -//npm.pkg.github.com/:_authToken=ghp_your_authenticated_token -registry=https://registry.npmjs.org/ \ No newline at end of file diff --git a/angular.json b/angular.json index 8f3ba2f9..e2ce6a75 100644 --- a/angular.json +++ b/angular.json @@ -3,17 +3,17 @@ "version": 1, "newProjectRoot": "projects", "projects": { - "mediumclone_angular": { + "admin_console_ui": { "projectType": "application", "schematics": {}, - "root": "", + "root": "src", "sourceRoot": "src", "prefix": "app", "architect": { "build": { "builder": "@hylandsoftware/hy-ui-devkit:browser", "options": { - "outputPath": "dist/mediumclone_angular", + "outputPath": "dist/admin_console_ui", "index": "src/index.html", "main": "src/main.ts", "polyfills": "src/polyfills.ts", @@ -26,12 +26,21 @@ "output": "./" } ], - "styles": ["src/styles.scss"], + "styles": [ + "src/styles.scss" + ], "scripts": [], - "i18nPaths": ["src/app"], - "i18nModules": ["@hyland/ui", "@hyland/ui-shell"], + "i18nPaths": [ + "src/app" + ], + "i18nModules": [ + "@hyland/ui", + "@hyland/ui-shell" + ], "stylePreprocessorOptions": { - "includePaths": ["node_modules"] + "includePaths": [ + "node_modules" + ] } }, "configurations": { @@ -80,10 +89,10 @@ }, "configurations": { "production": { - "browserTarget": "mediumclone_angular:build:production" + "browserTarget": "admin_console_ui:build:production" }, "development": { - "browserTarget": "mediumclone_angular:build:development" + "browserTarget": "admin_console_ui:build:development" } }, "defaultConfiguration": "development" @@ -91,26 +100,49 @@ "extract-i18n": { "builder": "@angular-devkit/build-angular:extract-i18n", "options": { - "browserTarget": "mediumclone_angular:build" + "browserTarget": "admin_console_ui:build" } }, "test": { "builder": "@angular-devkit/build-angular:karma", "options": { - "polyfills": ["src/polyfills.ts", "zone.js", "zone.js/testing"], + "polyfills": [ + "src/polyfills.ts", + "zone.js", + "zone.js/testing" + ], "tsConfig": "tsconfig.spec.json", - "assets": ["src/favicon.ico", "src/assets"], - "styles": ["src/styles.scss"], + "assets": [ + "src/favicon.ico", + "src/assets" + ], + "styles": [ + "src/styles.scss" + ], "scripts": [], "stylePreprocessorOptions": { - "includePaths": ["node_modules"] + "includePaths": [ + "node_modules" + ] } } + }, + "lint": { + "builder": "@angular-eslint/builder:lint", + "options": { + "lintFilePatterns": [ + "src/**/*.ts", + "src/**/*.html" + ] + } } } + }, + "cli": { + "root": "src" } }, "cli": { - "analytics": "7fa2cc0e-3e82-45f7-bedc-bce83c5ba0d7" + "analytics": "bac8daa6-35ed-405f-89f7-031d9cd916f4" } -} +} \ No newline at end of file diff --git a/package.json b/package.json index 61f110b2..46ddd838 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,9 @@ "start": "ng serve", "build": "ng build", "watch": "ng build --watch --configuration development", - "test": "ng test --code-coverage" + "test": "ng test --code-coverage", + "lint": "ng lint", + "prepare": "husky" }, "private": true, "dependencies": { @@ -32,13 +34,30 @@ "tslib": "^2.3.0", "zone.js": "~0.13.0" }, + "husky": { + "hooks": { + "pre-commit": "lint-staged" + } + }, + "lint-staged": { + "*.{ts,js,html}": "npm run lint" + }, "devDependencies": { "@angular-devkit/build-angular": "^16.2.14", + "@angular-eslint/builder": "16.3.1", + "@angular-eslint/eslint-plugin": "16.3.1", + "@angular-eslint/eslint-plugin-template": "16.3.1", + "@angular-eslint/schematics": "16.3.1", + "@angular-eslint/template-parser": "16.3.1", "@angular/cli": "^16.2.14", "@angular/compiler-cli": "^16.2.0", "@hylandsoftware/hy-ui-devkit": "^6.0.1", "@hylandsoftware/hy-ui-standards": "^6.0.1", "@types/jasmine": "~4.3.0", + "@typescript-eslint/eslint-plugin": "5.62.0", + "@typescript-eslint/parser": "5.62.0", + "eslint": "^8.51.0", + "husky": "^9.0.11", "jasmine-core": "~4.6.0", "karma": "~6.4.0", "karma-chrome-launcher": "~3.2.0", @@ -46,6 +65,7 @@ "karma-coverage-istanbul-reporter": "^3.0.3", "karma-jasmine": "~5.1.0", "karma-jasmine-html-reporter": "~2.1.0", + "lint-staged": "^15.2.5", "typescript": "~5.1.3" } } diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts index 1eb44773..ae513da8 100644 --- a/src/app/app.component.spec.ts +++ b/src/app/app.component.spec.ts @@ -19,11 +19,14 @@ describe("AppComponent", () => { get() { return null; } - set() {} + + set() { + return; + } } class commonServiceStub { - loadApp = new EventEmitter(); + loadApp = new EventEmitter(); } beforeEach(async () => { @@ -51,7 +54,7 @@ describe("AppComponent", () => { }); it("should open the warning dialog if warning preference is not set", () => { spyOn(component.persistenceService, "get").and.returnValue(null); - let loadAppSubscriptionSpy = spyOn( + const loadAppSubscriptionSpy = spyOn( component.commonService.loadApp, "subscribe" ).and.callThrough(); diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 6bbb7fc6..858e011b 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -11,7 +11,7 @@ import { WarningComponent } from "./features/warning/warning.component"; styleUrls: ["./app.component.scss"], }) export class AppComponent implements OnInit, OnDestroy { - loadApp: Boolean = false; + loadApp = false; loadAppSubscription = new Subscription(); constructor( public dialogService: MatDialog, diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 33cfa6f8..a76e8c28 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -21,7 +21,7 @@ import { BulkActionMonitoringModule } from "./features/bulk-action-monitoring/bu import { HomeModule } from "./features/home/home.module"; import { WarningComponent } from "./features/warning/warning.component"; import { HylandSSOManagerComponent } from "./auth/components/SSO/hylandSSOManager.component"; -import { BackendErrorMessages } from "./shared/components/backendErrorMessages/backendErrorMessages.component"; +import { BackendErrorMessagesComponent } from "./shared/components/backendErrorMessages/backendErrorMessages.component"; import { AppComponent } from "./app.component"; import { AuthInterceptorService } from "./auth/services/auth-interceptor.service"; import { authReducer } from "./auth/store/reducers"; @@ -46,7 +46,7 @@ import * as HomeEffects from "./features/home/store/effects"; HeaderBarComponent, MenuBarComponent, WarningComponent, - BackendErrorMessages, + BackendErrorMessagesComponent, HylandSSOManagerComponent, BaseLayoutComponent, ], diff --git a/src/app/auth/components/SSO/hylandSSOManager.component.ts b/src/app/auth/components/SSO/hylandSSOManager.component.ts index 056cc82a..fb379429 100644 --- a/src/app/auth/components/SSO/hylandSSOManager.component.ts +++ b/src/app/auth/components/SSO/hylandSSOManager.component.ts @@ -1,4 +1,4 @@ -import { Component } from "@angular/core"; +import { Component, OnInit } from "@angular/core"; import { FormBuilder } from "@angular/forms"; import { Store } from "@ngrx/store"; import { combineLatest } from "rxjs"; @@ -13,7 +13,7 @@ import { HylandSSORequestInterface } from "../../types/hylandSSORequest.interfac selector: "ssomanager", templateUrl: "./hylandSSOManager.component.html", }) -export class HylandSSOManagerComponent { +export class HylandSSOManagerComponent implements OnInit { data$ = combineLatest({ isSubmitting: this.store.select(selectIsSubmitting), backendErrors: this.store.select(selectValidationErrors), diff --git a/src/app/auth/services/auth-interceptor.service.ts b/src/app/auth/services/auth-interceptor.service.ts index 1de251cb..e0b14e4a 100644 --- a/src/app/auth/services/auth-interceptor.service.ts +++ b/src/app/auth/services/auth-interceptor.service.ts @@ -16,7 +16,6 @@ export class AuthInterceptorService implements HttpInterceptor { request: HttpRequest, next: HttpHandler ): Observable> { - const token = this.persistenceService.get("accessToken"); const req = request.clone({ setHeaders: { //TODO: Remove this once proper authentication & login flow is implemented diff --git a/src/app/features/warning/warning.component.spec.ts b/src/app/features/warning/warning.component.spec.ts index ba80db68..a1b41a64 100644 --- a/src/app/features/warning/warning.component.spec.ts +++ b/src/app/features/warning/warning.component.spec.ts @@ -19,11 +19,14 @@ describe("WarningComponent", () => { get() { return null; } - set() {} + + set() { + return; + } } class commonServiceStub { - loadApp = new EventEmitter(); + loadApp = new EventEmitter(); } beforeEach(async () => { diff --git a/src/app/features/warning/warning.component.ts b/src/app/features/warning/warning.component.ts index 251f98a8..3f81e4c9 100644 --- a/src/app/features/warning/warning.component.ts +++ b/src/app/features/warning/warning.component.ts @@ -10,7 +10,7 @@ import { HyKeyboardFocusService } from "@hyland/ui/keyboard-focus"; styleUrls: ["./warning.component.scss"], }) export class WarningComponent implements OnInit { - public doNotWarn: boolean = false; + public doNotWarn = false; constructor( public dialogService: MatDialog, diff --git a/src/app/shared/components/backendErrorMessages/backendErrorMessages.component.ts b/src/app/shared/components/backendErrorMessages/backendErrorMessages.component.ts index e8360410..e0408747 100644 --- a/src/app/shared/components/backendErrorMessages/backendErrorMessages.component.ts +++ b/src/app/shared/components/backendErrorMessages/backendErrorMessages.component.ts @@ -5,7 +5,7 @@ import { BackendErrorsInterface } from "../../types/backendErrors.interface"; selector: "mc-backend-error-messages", templateUrl: "./backendErrorMessages.component.html", }) -export class BackendErrorMessages implements OnInit { +export class BackendErrorMessagesComponent implements OnInit { @Input() backendErrors: BackendErrorsInterface = {}; errorMessages: string[] = []; diff --git a/src/app/shared/services/common.service.spec.ts b/src/app/shared/services/common.service.spec.ts index 17a2f328..c236e1ee 100644 --- a/src/app/shared/services/common.service.spec.ts +++ b/src/app/shared/services/common.service.spec.ts @@ -15,6 +15,6 @@ describe("CommonService", () => { }); it("should test if loadApp is initialised", () => { - expect(service.loadApp).toBeInstanceOf(EventEmitter); + expect(service.loadApp).toBeInstanceOf(EventEmitter); }); }); diff --git a/src/app/shared/services/common.service.ts b/src/app/shared/services/common.service.ts index a52b7118..87490f0e 100644 --- a/src/app/shared/services/common.service.ts +++ b/src/app/shared/services/common.service.ts @@ -4,5 +4,5 @@ import { EventEmitter, Injectable } from "@angular/core"; providedIn: "root", }) export class CommonService { - loadApp = new EventEmitter(); + loadApp = new EventEmitter(); } diff --git a/src/app/shared/services/persistence.service.spec.ts b/src/app/shared/services/persistence.service.spec.ts index e48b73dd..b5b3dc54 100644 --- a/src/app/shared/services/persistence.service.spec.ts +++ b/src/app/shared/services/persistence.service.spec.ts @@ -3,7 +3,6 @@ import { TestBed } from "@angular/core/testing"; describe("PersistenceService", () => { let service: PersistenceService; - let getItemSpy: jasmine.Spy; beforeEach(() => { TestBed.configureTestingModule({ providers: [PersistenceService] }); @@ -16,7 +15,7 @@ describe("PersistenceService", () => { describe("should test getting & setting of key value pair in localstorage", () => { beforeEach(() => { - let store: { [key: string]: any } = {}; + const store: { [key: string]: any } = {}; const mockLocalStorage = { getItem: (key: string): string => { return key in store ? store[key] : null; diff --git a/src/app/shared/services/persistence.service.ts b/src/app/shared/services/persistence.service.ts index f807c11b..8a69f021 100644 --- a/src/app/shared/services/persistence.service.ts +++ b/src/app/shared/services/persistence.service.ts @@ -4,7 +4,7 @@ import { Injectable } from "@angular/core"; providedIn: "root", }) export class PersistenceService { - set(key: string, data: unknown): void { + set(key: string, data: any): void { try { localStorage.setItem(key, JSON.stringify(data)); } catch (e) { @@ -12,7 +12,7 @@ export class PersistenceService { } } - get(key: string): unknown { + get(key: string): any { try { const localStorageItem = localStorage.getItem(key); return localStorageItem ? JSON.parse(localStorageItem) : null; From a4191b7a11f2f9cc537ea3f6a970994605e7d002 Mon Sep 17 00:00:00 2001 From: sushildeep Date: Fri, 7 Jun 2024 15:11:45 +0530 Subject: [PATCH 18/27] change jobs name --- .github/workflows/lint.yaml | 49 +++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index e69de29b..a7127bb9 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -0,0 +1,49 @@ +name: Lint + +on: + pull_request: + branches: + - dev + workflow_call: + inputs: + branch: + description: 'The current branch' + default: dev + type: string + required: false + +env: + BRANCH_NAME: ${{ github.head_ref || inputs.branch || 'dev' }} + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ env.BRANCH_NAME }} + + - name: Remove .npmrc file if exists + run: | + if [ -f .npmrc ]; then + rm .npmrc + fi + - uses: actions/setup-node@v4 + with: + registry-url: 'https://packages.nuxeo.com/repository/npm-public/' + node-version: 20 + scope: '@nuxeo' + + - name: Configure Additional Registries + run: | + npm config set @hylandsoftware:registry https://npm.pkg.github.com --global + npm config set //npm.pkg.github.com/:_authToken=${{ secrets.GIT_TOKEN }} --global + npm config set registry https://registry.npmjs.org/ --global + - name: Install @angular/cli + run: npm install -g @angular/cli + + - name: Install Dependencies + run: npm install + + - name: Lint + run: npm run lint \ No newline at end of file From 695da80a8dce92e47358dfa9e0462103c7f9188c Mon Sep 17 00:00:00 2001 From: sushildeep Date: Fri, 7 Jun 2024 16:16:06 +0530 Subject: [PATCH 19/27] change jobs name --- angular.json | 2 +- karma.conf.js | 14 ++++++++++---- package.json | 10 +++++++++- .../components/SSO/hylandSSOManager.component.ts | 2 +- src/app/auth/services/auth-interceptor.service.ts | 4 ++-- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/angular.json b/angular.json index e07cc500..e2ce6a75 100644 --- a/angular.json +++ b/angular.json @@ -143,6 +143,6 @@ } }, "cli": { - "analytics": "7fa2cc0e-3e82-45f7-bedc-bce83c5ba0d7" + "analytics": "bac8daa6-35ed-405f-89f7-031d9cd916f4" } } \ No newline at end of file diff --git a/karma.conf.js b/karma.conf.js index 409742f8..aae65be5 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,4 +1,4 @@ -module.exports = function(config) { +module.exports = function (config) { config.set({ basePath: '', frameworks: ['jasmine', '@angular-devkit/build-angular'], @@ -21,8 +21,14 @@ module.exports = function(config) { colors: true, logLevel: config.LOG_INFO, autoWatch: true, - browsers: ['Chrome'], - singleRun: false, - restartOnFileChange: true + browsers: ['ChromeHeadless'], + singleRun: true, + restartOnFileChange: true, + customLaunchers: { + ChromeHeadless: { + base: 'Chrome', + flags: ['--headless', '--no-sandbox'] + } + } }); }; diff --git a/package.json b/package.json index 750785af..3ea082e1 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,11 @@ "start": "ng serve", "build": "ng build", "watch": "ng build --watch --configuration development", - "test": "ng test --code-coverage" + "test": "ng test --code-coverage", + "lint": "ng lint", + "prepare": "husky" }, + "private": true, "dependencies": { "@angular/animations": "^16.2.0", "@angular/common": "^16.2.0", @@ -51,10 +54,15 @@ "@hylandsoftware/hy-ui-devkit": "^6.0.1", "@hylandsoftware/hy-ui-standards": "^6.0.1", "@types/jasmine": "~4.3.0", + "@typescript-eslint/eslint-plugin": "5.62.0", + "@typescript-eslint/parser": "5.62.0", + "eslint": "^8.51.0", + "husky": "^9.0.11", "jasmine-core": "~4.6.0", "karma": "~6.4.0", "karma-chrome-launcher": "~3.2.0", "karma-coverage": "~2.2.0", + "karma-coverage-istanbul-reporter": "^3.0.3", "karma-jasmine": "~5.1.0", "karma-jasmine-html-reporter": "~2.1.0", "lint-staged": "^15.2.5", diff --git a/src/app/auth/components/SSO/hylandSSOManager.component.ts b/src/app/auth/components/SSO/hylandSSOManager.component.ts index fb379429..5b0019fb 100644 --- a/src/app/auth/components/SSO/hylandSSOManager.component.ts +++ b/src/app/auth/components/SSO/hylandSSOManager.component.ts @@ -19,7 +19,7 @@ export class HylandSSOManagerComponent implements OnInit { backendErrors: this.store.select(selectValidationErrors), }); - constructor(private fb: FormBuilder, private store: Store) {} + constructor(private fb: FormBuilder, private store: Store) { } initSSO() { const request: HylandSSORequestInterface = { diff --git a/src/app/auth/services/auth-interceptor.service.ts b/src/app/auth/services/auth-interceptor.service.ts index e0b14e4a..1ffe916d 100644 --- a/src/app/auth/services/auth-interceptor.service.ts +++ b/src/app/auth/services/auth-interceptor.service.ts @@ -10,7 +10,7 @@ import { Observable } from "rxjs"; @Injectable() export class AuthInterceptorService implements HttpInterceptor { - constructor(private persistenceService: PersistenceService) {} + constructor(private persistenceService: PersistenceService) { } intercept( request: HttpRequest, @@ -24,4 +24,4 @@ export class AuthInterceptorService implements HttpInterceptor { }); return next.handle(req); } -} +} \ No newline at end of file From 15dcf0389a2fa320f86bdf46c748efebbc328310 Mon Sep 17 00:00:00 2001 From: sushildeep Date: Fri, 7 Jun 2024 16:47:41 +0530 Subject: [PATCH 20/27] change jobs name --- .github/workflows/utest.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/utest.yaml b/.github/workflows/utest.yaml index 3ed63ea7..d0df4bc9 100644 --- a/.github/workflows/utest.yaml +++ b/.github/workflows/utest.yaml @@ -46,5 +46,18 @@ jobs: - name: Install Dependencies run: npm install + - name: Install Chrome and Xvfb + run: | + sudo apt-get update + sudo apt-get install -y google-chrome-stable xvfb + + - name: Start Xvfb + run: | + sudo Xvfb :99 -ac -screen 0 1280x1024x16 > /dev/null 2>&1 & + + - name: Set DISPLAY variable + run: | + export DISPLAY=:99 + - name: Unit tests run: npm run test From dcd249fcd16cd623fe40fb6b1850a80245229d9e Mon Sep 17 00:00:00 2001 From: sushildeep Date: Fri, 7 Jun 2024 16:51:15 +0530 Subject: [PATCH 21/27] change jobs name --- karma.conf.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/karma.conf.js b/karma.conf.js index aae65be5..d50d56ea 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -29,6 +29,15 @@ module.exports = function (config) { base: 'Chrome', flags: ['--headless', '--no-sandbox'] } - } + }, + // Add Xvfb settings + browsers: ['ChromeCustom'], + customLaunchers: { + ChromeCustom: { + base: 'ChromeHeadless', + flags: ['--disable-gpu', '--no-sandbox', '--remote-debugging-port=9222'] + } + }, + singleRun: true }); }; From f0d051145704fa6b590612e15d5f79fc27a3ef59 Mon Sep 17 00:00:00 2001 From: sushildeep Date: Fri, 7 Jun 2024 16:58:04 +0530 Subject: [PATCH 22/27] change jobs name --- karma.conf.js | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/karma.conf.js b/karma.conf.js index d50d56ea..1ba96cbd 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -21,23 +21,14 @@ module.exports = function (config) { colors: true, logLevel: config.LOG_INFO, autoWatch: true, - browsers: ['ChromeHeadless'], + browsers: ['ChromeCustom'], // Use custom Chrome launcher singleRun: true, restartOnFileChange: true, - customLaunchers: { - ChromeHeadless: { - base: 'Chrome', - flags: ['--headless', '--no-sandbox'] - } - }, - // Add Xvfb settings - browsers: ['ChromeCustom'], customLaunchers: { ChromeCustom: { base: 'ChromeHeadless', - flags: ['--disable-gpu', '--no-sandbox', '--remote-debugging-port=9222'] + flags: ['--headless', '--disable-gpu', '--no-sandbox'] } - }, - singleRun: true + } }); }; From 22f920d2ba1c7bccdc6846ccb5ec75aeb8fc141e Mon Sep 17 00:00:00 2001 From: sushildeep Date: Fri, 7 Jun 2024 17:04:39 +0530 Subject: [PATCH 23/27] change jobs name --- karma.conf.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/karma.conf.js b/karma.conf.js index 1ba96cbd..b2e0abfa 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -21,14 +21,8 @@ module.exports = function (config) { colors: true, logLevel: config.LOG_INFO, autoWatch: true, - browsers: ['ChromeCustom'], // Use custom Chrome launcher + browsers: ['ChromeHeadless'], // Use ChromeHeadless directly singleRun: true, - restartOnFileChange: true, - customLaunchers: { - ChromeCustom: { - base: 'ChromeHeadless', - flags: ['--headless', '--disable-gpu', '--no-sandbox'] - } - } + restartOnFileChange: true }); }; From a5fed80a216a2991277d748b8eb968d8657fe92c Mon Sep 17 00:00:00 2001 From: sushildeep Date: Fri, 7 Jun 2024 17:15:02 +0530 Subject: [PATCH 24/27] change jobs name --- .github/workflows/utest.yaml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/utest.yaml b/.github/workflows/utest.yaml index d0df4bc9..1c4cc577 100644 --- a/.github/workflows/utest.yaml +++ b/.github/workflows/utest.yaml @@ -46,10 +46,15 @@ jobs: - name: Install Dependencies run: npm install - - name: Install Chrome and Xvfb - run: | - sudo apt-get update - sudo apt-get install -y google-chrome-stable xvfb + - name: Install Chrome and Chromedriver + uses: browser-actions/setup-chrome@v1 + with: + chrome-version: 120 + install-chromedriver: true + + - name: Verify Chrome installation + run: google-chrome --version + - name: Start Xvfb run: | From a18402c5095887ac0ece6d58686399262c79a21b Mon Sep 17 00:00:00 2001 From: sushildeep Date: Fri, 7 Jun 2024 17:18:38 +0530 Subject: [PATCH 25/27] change jobs name --- .github/workflows/utest.yaml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/.github/workflows/utest.yaml b/.github/workflows/utest.yaml index 1c4cc577..99da51d3 100644 --- a/.github/workflows/utest.yaml +++ b/.github/workflows/utest.yaml @@ -55,14 +55,6 @@ jobs: - name: Verify Chrome installation run: google-chrome --version - - - name: Start Xvfb - run: | - sudo Xvfb :99 -ac -screen 0 1280x1024x16 > /dev/null 2>&1 & - - - name: Set DISPLAY variable - run: | - export DISPLAY=:99 - - name: Unit tests - run: npm run test + run: | + xvfb-run --auto-servernum --server-args="-screen 0 1024x768x24" npm test From 84772037a60a9e3e897b732b91083b1c7497db3d Mon Sep 17 00:00:00 2001 From: sushildeep Date: Fri, 7 Jun 2024 17:26:02 +0530 Subject: [PATCH 26/27] change jobs name --- karma.conf.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/karma.conf.js b/karma.conf.js index b2e0abfa..284ba5a6 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -21,8 +21,24 @@ module.exports = function (config) { colors: true, logLevel: config.LOG_INFO, autoWatch: true, - browsers: ['ChromeHeadless'], // Use ChromeHeadless directly + browsers: ['ChromeCustom'], // Use custom Chrome launcher singleRun: true, - restartOnFileChange: true + restartOnFileChange: true, + customLaunchers: { + ChromeCustom: { + base: 'ChromeHeadless', + flags: ['--headless', '--disable-gpu', '--no-sandbox'] + } + }, + // Force exit after tests complete + browserNoActivityTimeout: 30000, + captureTimeout: 30000, + processKillTimeout: 3000, + browserDisconnectTimeout: 10000, + browserDisconnectTolerance: 3, + // Ensure Karma exits after tests + onExit: function (exitCode) { + process.exit(exitCode); + } }); }; From 6764f297aa4c2e86bd1ef34c7da44791213bc9a5 Mon Sep 17 00:00:00 2001 From: sushildeep Date: Fri, 7 Jun 2024 17:42:58 +0530 Subject: [PATCH 27/27] change jobs name --- karma.conf.js | 11 +++-------- package.json | 2 +- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/karma.conf.js b/karma.conf.js index 284ba5a6..cea64e9f 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -20,25 +20,20 @@ module.exports = function (config) { port: 9876, colors: true, logLevel: config.LOG_INFO, - autoWatch: true, + autoWatch: false, // set to false to disable watching files browsers: ['ChromeCustom'], // Use custom Chrome launcher singleRun: true, - restartOnFileChange: true, + restartOnFileChange: false, // set to false to disable restart on file change customLaunchers: { ChromeCustom: { base: 'ChromeHeadless', flags: ['--headless', '--disable-gpu', '--no-sandbox'] } }, - // Force exit after tests complete browserNoActivityTimeout: 30000, captureTimeout: 30000, processKillTimeout: 3000, browserDisconnectTimeout: 10000, - browserDisconnectTolerance: 3, - // Ensure Karma exits after tests - onExit: function (exitCode) { - process.exit(exitCode); - } + browserDisconnectTolerance: 3 }); }; diff --git a/package.json b/package.json index 3ea082e1..299eeea8 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "start": "ng serve", "build": "ng build", "watch": "ng build --watch --configuration development", - "test": "ng test --code-coverage", + "test": "ng test --code-coverage --watch=false", "lint": "ng lint", "prepare": "husky" },