From 1d0f8195a70608904e85653313ec86bc16f1736b Mon Sep 17 00:00:00 2001 From: Joe Fong Date: Wed, 12 Jun 2024 10:37:37 +0100 Subject: [PATCH 01/11] edit sonarcloud config about coverage report ingestion --- sonar-project.properties | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sonar-project.properties b/sonar-project.properties index 86d896b..9a85707 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -2,12 +2,16 @@ sonar.projectKey=prm-orphaned-record-continuity_prm-repo-gp2gp-messenger sonar.organization=prm-orphaned-record-continuity # This is the name and version displayed in the SonarCloud UI. -#sonar.projectName=prm-repo-gp2gp-messenger -#sonar.projectVersion=1.0 +sonar.projectName="GP2GP Messenger" +sonar.projectVersion=1.0 +sonar.javascript.lcov.reportPaths=coverage/lcov.info # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. -#sonar.sources=. +sonar.sources=src/ +sonar.exclusions=src/**/__test__/**/* +sonar.tests=src/ +sonar.inclusion=src/**/__tests__/*.js,src/**/__mocks__/*,src/**/__builders__/*,src/**/*.test.js # Encoding of the source code. Default is default system encoding #sonar.sourceEncoding=UTF-8 \ No newline at end of file From f7ca6724bc533dfbd25553472f303e9d4b5b9988 Mon Sep 17 00:00:00 2001 From: Joe Fong Date: Wed, 12 Jun 2024 10:44:03 +0100 Subject: [PATCH 02/11] amend config --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 9a85707..df195e0 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -11,7 +11,7 @@ sonar.javascript.lcov.reportPaths=coverage/lcov.info sonar.sources=src/ sonar.exclusions=src/**/__test__/**/* sonar.tests=src/ -sonar.inclusion=src/**/__tests__/*.js,src/**/__mocks__/*,src/**/__builders__/*,src/**/*.test.js +sonar.tests.inclusion=src/**/__tests__/*.js,src/**/__mocks__/*,src/**/__builders__/*,src/**/*.test.js # Encoding of the source code. Default is default system encoding #sonar.sourceEncoding=UTF-8 \ No newline at end of file From 00ca0efe1f1d38b30c3023d6f459e01c639d6f48 Mon Sep 17 00:00:00 2001 From: Joe Fong Date: Wed, 12 Jun 2024 10:49:23 +0100 Subject: [PATCH 03/11] amend config --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index df195e0..502b405 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -9,7 +9,7 @@ sonar.javascript.lcov.reportPaths=coverage/lcov.info # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. sonar.sources=src/ -sonar.exclusions=src/**/__test__/**/* +sonar.exclusions=src/**/__test__/**/*,**/*.json sonar.tests=src/ sonar.tests.inclusion=src/**/__tests__/*.js,src/**/__mocks__/*,src/**/__builders__/*,src/**/*.test.js From ef0a77dc04e661eee37f97d51cda7a0fc73ec995 Mon Sep 17 00:00:00 2001 From: Joe Fong Date: Wed, 12 Jun 2024 10:51:37 +0100 Subject: [PATCH 04/11] amend config --- sonar-project.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sonar-project.properties b/sonar-project.properties index 502b405..0024424 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -9,9 +9,9 @@ sonar.javascript.lcov.reportPaths=coverage/lcov.info # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. sonar.sources=src/ -sonar.exclusions=src/**/__test__/**/*,**/*.json -sonar.tests=src/ -sonar.tests.inclusion=src/**/__tests__/*.js,src/**/__mocks__/*,src/**/__builders__/*,src/**/*.test.js +sonar.exclusions=src/**/__test__/**/* +sonar.tests=src/test/ +sonar.test.inclusions=src/**/__tests__/*.js,src/**/__mocks__/*,src/**/__builders__/*,src/**/*.test.js # Encoding of the source code. Default is default system encoding #sonar.sourceEncoding=UTF-8 \ No newline at end of file From 57b76d9c8e7cf0f4773b41bc380ddc4ff5c4f8c3 Mon Sep 17 00:00:00 2001 From: Joe Fong Date: Wed, 12 Jun 2024 10:58:44 +0100 Subject: [PATCH 05/11] amend config --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 0024424..8c4aa82 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -10,7 +10,7 @@ sonar.javascript.lcov.reportPaths=coverage/lcov.info # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. sonar.sources=src/ sonar.exclusions=src/**/__test__/**/* -sonar.tests=src/test/ +sonar.tests=src/,test/ sonar.test.inclusions=src/**/__tests__/*.js,src/**/__mocks__/*,src/**/__builders__/*,src/**/*.test.js # Encoding of the source code. Default is default system encoding From dda697d1e6b33fe270ce21ad04853161b3499dde Mon Sep 17 00:00:00 2001 From: Joe Fong Date: Wed, 12 Jun 2024 11:14:57 +0100 Subject: [PATCH 06/11] edit github action to run coverage --- .github/workflows/build.yml | 10 ++++++++++ sonar-project.properties | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d232096..fcecdfa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,6 +13,16 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + + - name: Use Node.js 14.x + uses: actions/setup-node@v3 + with: + node-version: 14.x + + - name: Run test coverage + run: | + ./tasks test_coverage + - name: SonarCloud Scan uses: SonarSource/sonarcloud-github-action@master env: diff --git a/sonar-project.properties b/sonar-project.properties index 8c4aa82..3296812 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -11,7 +11,7 @@ sonar.javascript.lcov.reportPaths=coverage/lcov.info sonar.sources=src/ sonar.exclusions=src/**/__test__/**/* sonar.tests=src/,test/ -sonar.test.inclusions=src/**/__tests__/*.js,src/**/__mocks__/*,src/**/__builders__/*,src/**/*.test.js +sonar.test.inclusions=src/**/__tests__/*,src/**/__mocks__/*,src/**/__builders__/*,src/**/*.test.js # Encoding of the source code. Default is default system encoding #sonar.sourceEncoding=UTF-8 \ No newline at end of file From 28b952d54e9e2c7806ca6d7023b1583b1a3fd7e0 Mon Sep 17 00:00:00 2001 From: Joe Fong Date: Wed, 12 Jun 2024 11:25:36 +0100 Subject: [PATCH 07/11] amend github actions --- .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 fcecdfa..01553a7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,7 +21,7 @@ jobs: - name: Run test coverage run: | - ./tasks test_coverage + ./tasks _test_coverage - name: SonarCloud Scan uses: SonarSource/sonarcloud-github-action@master From 0d12b7a656603965c0aa3ccc714b144e41cf9387 Mon Sep 17 00:00:00 2001 From: Joe Fong Date: Wed, 12 Jun 2024 11:30:06 +0100 Subject: [PATCH 08/11] try run coverage with node 16.x --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 01553a7..f5f9c5e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,10 +14,10 @@ jobs: with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - name: Use Node.js 14.x + - name: Use Node.js 16.x uses: actions/setup-node@v3 with: - node-version: 14.x + node-version: 16.x - name: Run test coverage run: | From 408057fa0e7d84c6d84e5d9a0795e27c2dd03916 Mon Sep 17 00:00:00 2001 From: Joe Fong Date: Wed, 12 Jun 2024 11:41:12 +0100 Subject: [PATCH 09/11] try to add an uncovered code file --- src/foo.js | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/foo.js diff --git a/src/foo.js b/src/foo.js new file mode 100644 index 0000000..ec0585a --- /dev/null +++ b/src/foo.js @@ -0,0 +1,8 @@ +// a temp file just to trigger sonarcloud coverage scan +// to be removed later. + +function foo() { + return "bar"; +} + +export default foo; From 0b647253fd3e7fcbb7035ba5967b5e8ded6cec3b Mon Sep 17 00:00:00 2001 From: Joe Fong Date: Wed, 12 Jun 2024 11:49:14 +0100 Subject: [PATCH 10/11] add test to cover the dummy code (to trigger sonarcloud calculation) --- src/__tests__/foo.test.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/__tests__/foo.test.js diff --git a/src/__tests__/foo.test.js b/src/__tests__/foo.test.js new file mode 100644 index 0000000..45df491 --- /dev/null +++ b/src/__tests__/foo.test.js @@ -0,0 +1,13 @@ +// a temp file just to trigger sonarcloud coverage scan +// to be removed later. + +import foo from "../foo"; + +describe('foo', () => { + it('should return bar', () => { + const actual = foo(); + const expected = 'bar'; + + expect(actual).toBe(expected); + }) +}); \ No newline at end of file From 20d8f3974364d3dd73c21a7ea488e4641af2f1a7 Mon Sep 17 00:00:00 2001 From: Joe Fong Date: Wed, 12 Jun 2024 11:53:01 +0100 Subject: [PATCH 11/11] remove the dummy files for testing sonarcloud --- src/__tests__/foo.test.js | 13 ------------- src/foo.js | 8 -------- 2 files changed, 21 deletions(-) delete mode 100644 src/__tests__/foo.test.js delete mode 100644 src/foo.js diff --git a/src/__tests__/foo.test.js b/src/__tests__/foo.test.js deleted file mode 100644 index 45df491..0000000 --- a/src/__tests__/foo.test.js +++ /dev/null @@ -1,13 +0,0 @@ -// a temp file just to trigger sonarcloud coverage scan -// to be removed later. - -import foo from "../foo"; - -describe('foo', () => { - it('should return bar', () => { - const actual = foo(); - const expected = 'bar'; - - expect(actual).toBe(expected); - }) -}); \ No newline at end of file diff --git a/src/foo.js b/src/foo.js deleted file mode 100644 index ec0585a..0000000 --- a/src/foo.js +++ /dev/null @@ -1,8 +0,0 @@ -// a temp file just to trigger sonarcloud coverage scan -// to be removed later. - -function foo() { - return "bar"; -} - -export default foo;