From 2228dd006ee664be99247bf59ab0069087aff0e3 Mon Sep 17 00:00:00 2001 From: Guan-Xin Wang Date: Mon, 23 Sep 2024 22:44:10 +0800 Subject: [PATCH 01/12] fix: attempt to fix 0 coverage --- sonar-project.properties | 1 + 1 file changed, 1 insertion(+) diff --git a/sonar-project.properties b/sonar-project.properties index 3ab96f1b..fc6added 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -21,3 +21,4 @@ sonar.cpd.exclusions=**/*.spec.ts,**/*.spec.tsx,**/*.spec.js,**/*.spec.jsx # Encoding of the source code. Default is default system encoding #sonar.sourceEncoding=UTF-8 sonar.typescript.lcov.reportPaths=coverage/lcov.info +sonar.javascript.lcov.reportPaths=coverage/lcov.info From 7650c3ecdd08d9a466062ca7ff1e0dfe2a1b9d0d Mon Sep 17 00:00:00 2001 From: Guan-Xin Wang Date: Mon, 23 Sep 2024 22:54:45 +0800 Subject: [PATCH 02/12] fix: update build.yml and properties --- .github/workflows/build.yml | 9 +++++++++ sonar-project.properties | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 61d9907f..7354fd7f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,6 +13,15 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Install dependencies + run: pnpm install + - name: Test and coverage + run: pnpm run test:cov && node merge-coverage.cjs + - name: Upload coverage report + uses: actions/upload-artifact@v2 + with: + name: coverage-report + path: coverage/lcov.info - name: SonarCloud Scan uses: SonarSource/sonarcloud-github-action@master env: diff --git a/sonar-project.properties b/sonar-project.properties index fc6added..1fa59820 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -20,5 +20,5 @@ sonar.cpd.exclusions=**/*.spec.ts,**/*.spec.tsx,**/*.spec.js,**/*.spec.jsx # Encoding of the source code. Default is default system encoding #sonar.sourceEncoding=UTF-8 -sonar.typescript.lcov.reportPaths=coverage/lcov.info -sonar.javascript.lcov.reportPaths=coverage/lcov.info +sonar.typescript.lcov.reportPaths=./coverage/lcov.info +sonar.javascript.lcov.reportPaths=./coverage/lcov.info From ec879cb546d11d9522b4e7df754d3becb48ec8fe Mon Sep 17 00:00:00 2001 From: Guan-Xin Wang Date: Mon, 23 Sep 2024 22:56:51 +0800 Subject: [PATCH 03/12] fix: update deprecated version --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7354fd7f..cd6f3f6f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,7 +18,7 @@ jobs: - name: Test and coverage run: pnpm run test:cov && node merge-coverage.cjs - name: Upload coverage report - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: coverage-report path: coverage/lcov.info From b59fdccf40888e3b413f0c92ed6a041f67fdb21b Mon Sep 17 00:00:00 2001 From: Guan-Xin Wang Date: Mon, 23 Sep 2024 22:58:40 +0800 Subject: [PATCH 04/12] fix: pnpm command not found Install pnpm and use pnpm --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cd6f3f6f..c43fcff4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,7 +14,7 @@ jobs: with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: Install dependencies - run: pnpm install + run: npm install pnpm && pnpm install - name: Test and coverage run: pnpm run test:cov && node merge-coverage.cjs - name: Upload coverage report From 25f587e8b7f16b916531db029b5c579d61138a48 Mon Sep 17 00:00:00 2001 From: Guan-Xin Wang Date: Mon, 23 Sep 2024 23:01:33 +0800 Subject: [PATCH 05/12] fix: follow SonarCloud to install pnpm --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c43fcff4..2d8bff51 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,7 +14,7 @@ jobs: with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: Install dependencies - run: npm install pnpm && pnpm install + run: npm i -g pnpm && pnpm install - name: Test and coverage run: pnpm run test:cov && node merge-coverage.cjs - name: Upload coverage report From 42136a47c8910db4e4d4eeaaa1b1f6a421351800 Mon Sep 17 00:00:00 2001 From: Guan-Xin Wang Date: Mon, 23 Sep 2024 23:06:21 +0800 Subject: [PATCH 06/12] fix: attempt to fix cannot test in Sonar build --- .github/workflows/build.yml | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2d8bff51..12f7803a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ jobs: - name: Install dependencies run: npm i -g pnpm && pnpm install - name: Test and coverage - run: pnpm run test:cov && node merge-coverage.cjs + run: pnpm run test:cov - name: Upload coverage report uses: actions/upload-artifact@v4 with: diff --git a/package.json b/package.json index b3ab83cd..c5627188 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "mock-reports-back": "nodemon mock/mock-server/mock-reports-backend.js", "mock-settings-back": "nodemon mock/mock-server/mock-settings-backend.js", "testing": "-----------------all testing scripts-----------------", - "test:cov": "nx run-many --all --target=test --parallel=6 --ci --coverage", + "test:cov": "nx run-many --all --target=test --parallel=6 --ci --coverage && node ./merge-coverage.cjs", "test": "vitest run", "prepare": "husky", "test:e2e": "vitest run ./apps/nest-backend/test/app.e2e-spec.ts", From ccaa4f65482a9b50a04df56285468ac32c601b85 Mon Sep 17 00:00:00 2001 From: Guan-Xin Wang Date: Tue, 24 Sep 2024 07:46:52 +0800 Subject: [PATCH 07/12] fix: run script --- .github/workflows/build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 12f7803a..81fd5e28 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,6 +17,9 @@ jobs: run: npm i -g pnpm && pnpm install - name: Test and coverage run: pnpm run test:cov + - name: 'Run script' + run: node ${{ github.action_path }}/merge-coverage.cjs + shell: bash - name: Upload coverage report uses: actions/upload-artifact@v4 with: From 78174eeb71212045117827677ff470e64c1de572 Mon Sep 17 00:00:00 2001 From: Guan-Xin Wang Date: Tue, 24 Sep 2024 07:49:38 +0800 Subject: [PATCH 08/12] fix: remove script's node --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c5627188..b3ab83cd 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "mock-reports-back": "nodemon mock/mock-server/mock-reports-backend.js", "mock-settings-back": "nodemon mock/mock-server/mock-settings-backend.js", "testing": "-----------------all testing scripts-----------------", - "test:cov": "nx run-many --all --target=test --parallel=6 --ci --coverage && node ./merge-coverage.cjs", + "test:cov": "nx run-many --all --target=test --parallel=6 --ci --coverage", "test": "vitest run", "prepare": "husky", "test:e2e": "vitest run ./apps/nest-backend/test/app.e2e-spec.ts", From 9b72f1c8026bbd6dc0ddee9b1cd9c7f0834d43ac Mon Sep 17 00:00:00 2001 From: Guan-Xin Wang Date: Tue, 24 Sep 2024 08:02:04 +0800 Subject: [PATCH 09/12] fix: verbose coverage log without --ci argument --- .github/workflows/build.yml | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 81fd5e28..433c88db 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,6 +17,7 @@ jobs: run: npm i -g pnpm && pnpm install - name: Test and coverage run: pnpm run test:cov + shell: bash - name: 'Run script' run: node ${{ github.action_path }}/merge-coverage.cjs shell: bash diff --git a/package.json b/package.json index b3ab83cd..f2b66524 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "mock-reports-back": "nodemon mock/mock-server/mock-reports-backend.js", "mock-settings-back": "nodemon mock/mock-server/mock-settings-backend.js", "testing": "-----------------all testing scripts-----------------", - "test:cov": "nx run-many --all --target=test --parallel=6 --ci --coverage", + "test:cov": "nx run-many --target=test --parallel=6 --coverage --verbose --exclude=**/test/*e2e-spec.ts", "test": "vitest run", "prepare": "husky", "test:e2e": "vitest run ./apps/nest-backend/test/app.e2e-spec.ts", From 552f4e284b217e20251bf6f82dc907f537a83495 Mon Sep 17 00:00:00 2001 From: Guan-Xin Wang Date: Tue, 24 Sep 2024 08:12:39 +0800 Subject: [PATCH 10/12] fix: seperate coverage actions --- .github/workflows/build.yml | 3 +++ package.json | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 433c88db..29e89c30 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,6 +18,9 @@ jobs: - name: Test and coverage run: pnpm run test:cov shell: bash + - name: Test backend coverage + run: pnpm run test-back:cov + shell: bash - name: 'Run script' run: node ${{ github.action_path }}/merge-coverage.cjs shell: bash diff --git a/package.json b/package.json index f2b66524..0a5607a2 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,8 @@ "mock-reports-back": "nodemon mock/mock-server/mock-reports-backend.js", "mock-settings-back": "nodemon mock/mock-server/mock-settings-backend.js", "testing": "-----------------all testing scripts-----------------", - "test:cov": "nx run-many --target=test --parallel=6 --coverage --verbose --exclude=**/test/*e2e-spec.ts", + "test:cov": "nx run-many --target=test --parallel=6 --coverage --verbose --exclude=**/nest-backend", + "test-back:cov": "vitest --coverage --root=apps/nest-backend --exclude=**/test/*e2e-spec.ts --watch=false", "test": "vitest run", "prepare": "husky", "test:e2e": "vitest run ./apps/nest-backend/test/app.e2e-spec.ts", From 20fb1c395bc7b85de3f5859367312df0364518d7 Mon Sep 17 00:00:00 2001 From: Guan-Xin Wang Date: Tue, 24 Sep 2024 08:16:32 +0800 Subject: [PATCH 11/12] fix: add backend test and report merging after coverage test --- .github/workflows/build.yml | 6 ------ package.json | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 29e89c30..79243e38 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,12 +18,6 @@ jobs: - name: Test and coverage run: pnpm run test:cov shell: bash - - name: Test backend coverage - run: pnpm run test-back:cov - shell: bash - - name: 'Run script' - run: node ${{ github.action_path }}/merge-coverage.cjs - shell: bash - name: Upload coverage report uses: actions/upload-artifact@v4 with: diff --git a/package.json b/package.json index 0a5607a2..a256fd69 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "mock-reports-back": "nodemon mock/mock-server/mock-reports-backend.js", "mock-settings-back": "nodemon mock/mock-server/mock-settings-backend.js", "testing": "-----------------all testing scripts-----------------", - "test:cov": "nx run-many --target=test --parallel=6 --coverage --verbose --exclude=**/nest-backend", + "test:cov": "nx run-many --target=test --parallel=6 --coverage --verbose --exclude=**/nest-backend && pnpm run test-back:cov && node ./merge-coverage.cjs", "test-back:cov": "vitest --coverage --root=apps/nest-backend --exclude=**/test/*e2e-spec.ts --watch=false", "test": "vitest run", "prepare": "husky", From 0c606faa4f77d65f1fbc3c9f7010f214fae87c70 Mon Sep 17 00:00:00 2001 From: Guan-Xin Wang Date: Tue, 24 Sep 2024 08:43:45 +0800 Subject: [PATCH 12/12] fix: fix e2e-test in the pre-commit --- .husky/pre-commit | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index db26bfd9..703afcf7 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,2 +1,3 @@ pnpm run test:cov +pnpm run test:e2e node merge-coverage.cjs diff --git a/package.json b/package.json index a256fd69..d5bb0390 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "test-back:cov": "vitest --coverage --root=apps/nest-backend --exclude=**/test/*e2e-spec.ts --watch=false", "test": "vitest run", "prepare": "husky", - "test:e2e": "vitest run ./apps/nest-backend/test/app.e2e-spec.ts", + "test:e2e": "vitest --root=apps/nest-backend --watch=false", "test-back:unit": "vitest --root=apps/nest-backend --exclude=**/test/*e2e-spec.ts --watch=false", "sentry:sourcemaps": "sentry-cli sourcemaps inject --org guan-xin-wang --project tag-check ./dist/apps/ng-frontend/browser && sentry-cli sourcemaps upload --org guan-xin-wang --project tag-check ./dist/apps/ng-frontend/browser" },