From a57bce3bd50e4009fe0e4036ce50808d239f02aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9line=20Souchet?= Date: Wed, 25 Nov 2020 15:38:50 +0100 Subject: [PATCH 01/28] Add configuration to run a SonarCloud analysis on master branch and pull requests --- .github/workflows/build.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 607d9e70be..d9b871d26f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,6 +23,7 @@ on: - 'docs/**' - '*.md' - LICENSE + types: [opened, synchronize, reopened] jobs: build: @@ -73,3 +74,15 @@ jobs: # Ensure we don't break scripts - name: Build utils run: npm run build-utils + sonarcloud: + name: SonarCloud + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} From b50b176bc19a0670597a2c677c70a468c13ffe43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9line=20Souchet?= Date: Wed, 25 Nov 2020 15:45:19 +0100 Subject: [PATCH 02/28] Add the configuration file in the root directory of the project: sonar-project.properties --- sonar-project.properties | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 sonar-project.properties diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000000..ac1b53ac74 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,12 @@ +sonar.projectKey=process-analytics_bpmn-visualization-js +sonar.organization=process-analytics + +# This is the name and version displayed in the SonarCloud UI. +sonar.projectName=bpmn-visualization +sonar.projectVersion=0.8.0 + +# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. +#sonar.sources=. + +# Encoding of the source code. Default is default system encoding +#sonar.sourceEncoding=UTF-8 From 78ccba88244932a1809c0c30c56bccd23208c80d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9line=20Souchet?= Date: Wed, 25 Nov 2020 17:45:43 +0100 Subject: [PATCH 03/28] - Generate eslint report in json format - Configurate tslint & eslint report on Sonar --- .github/workflows/build.yml | 2 +- sonar-project.properties | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d9b871d26f..73af6c2855 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,7 +50,7 @@ jobs: - name: Install dependencies run: npm ci - name: Lint check - run: npm run lint-check + run: npm run lint-check -- -f json -o build/eslint-reporter.json - name: Build Application run: npm run build - name: Test Application diff --git a/sonar-project.properties b/sonar-project.properties index ac1b53ac74..28ac7740fc 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -8,5 +8,8 @@ sonar.projectVersion=0.8.0 # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. #sonar.sources=. +sonar.eslint.reportPaths=build/eslint-reporter.json +sonar.typescript.tsconfigPath=tsconfig.json + # Encoding of the source code. Default is default system encoding #sonar.sourceEncoding=UTF-8 From 263ac74d797c47d6d9fda796ee1338a89365eab0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9line=20Souchet?= Date: Wed, 25 Nov 2020 17:48:37 +0100 Subject: [PATCH 04/28] Generate Jest test execution report & configure Sonar --- package-lock.json | 18 ++++++++++++++++++ package.json | 1 + sonar-project.properties | 15 ++++++++++++++- test/e2e/jest.config.js | 6 ++++++ test/unit/jest.config.js | 6 ++++++ 5 files changed, 45 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 806deca7e7..d403752f55 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11821,6 +11821,24 @@ } } }, + "jest-sonar": { + "version": "0.2.11", + "resolved": "https://registry.npmjs.org/jest-sonar/-/jest-sonar-0.2.11.tgz", + "integrity": "sha512-uQej+af8ElXNp6rP5OyjrZraSpbxGwLUuMJIxaBq/dd9V0rP6GCFjUUn35w6oUF5RT8vC8N+gNq1lxrlgpbmUg==", + "dev": true, + "requires": { + "entities": "2.0.3", + "strip-ansi": "6.0.0" + }, + "dependencies": { + "entities": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/entities/-/entities-2.0.3.tgz", + "integrity": "sha512-MyoZ0jgnLvB2X3Lg5HqpFmn1kybDiIfEQmKzTb5apr51Rb+T3KdmMiqa70T+bhGnyv7bQ6WMj2QMHpGMmlrUYQ==", + "dev": true + } + } + }, "jest-util": { "version": "26.6.1", "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-26.6.1.tgz", diff --git a/package.json b/package.json index 72876d4c54..aba62d1930 100644 --- a/package.json +++ b/package.json @@ -103,6 +103,7 @@ "jest-html-reporter": "^3.3.0", "jest-image-snapshot": "^4.2.0", "jest-puppeteer": "^4.4.0", + "jest-sonar": "^0.2.11", "lint-staged": "^10.5.2", "minimist": "^1.2.5", "mxgraph-type-definitions": "^1.0.4", diff --git a/sonar-project.properties b/sonar-project.properties index 28ac7740fc..9336da3e20 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -6,10 +6,23 @@ sonar.projectName=bpmn-visualization sonar.projectVersion=0.8.0 # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. -#sonar.sources=. +sonar.sources=src +#sonar.exclusions= +#sonar.inclusions= + +# Path to tests +sonar.tests=test +#sonar.test.exclusions= +#sonar.test.inclusions= + +sonar.javascript.lcov.reportPaths= +sonar.testExecutionReportPaths=build/test-report/unit/sonar-report.xml,build/test-report/e2e/sonar-report.xml sonar.eslint.reportPaths=build/eslint-reporter.json sonar.typescript.tsconfigPath=tsconfig.json +# Exclusions for copy-paste detection +#sonar.cpd.exclusions= + # Encoding of the source code. Default is default system encoding #sonar.sourceEncoding=UTF-8 diff --git a/test/e2e/jest.config.js b/test/e2e/jest.config.js index 9c6fb4497d..cc82ccf4c3 100644 --- a/test/e2e/jest.config.js +++ b/test/e2e/jest.config.js @@ -39,5 +39,11 @@ module.exports = { includeSuiteFailure: true, }, ], + [ + 'jest-sonar', + { + outputDirectory: 'build/test-report/e2e', + }, + ], ], }; diff --git a/test/unit/jest.config.js b/test/unit/jest.config.js index b11fcd8515..8d3e760bd4 100644 --- a/test/unit/jest.config.js +++ b/test/unit/jest.config.js @@ -48,5 +48,11 @@ module.exports = { includeSuiteFailure: true, }, ], + [ + 'jest-sonar', + { + outputDirectory: 'build/test-report/unit', + }, + ], ], }; From 410ea9f3fb8b15425b95452ce8112a902b91b739 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9line=20Souchet?= Date: Wed, 25 Nov 2020 17:49:35 +0100 Subject: [PATCH 05/28] Execute Sonar analysis after all steps of build and only on ubuntu --- .github/workflows/build.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 73af6c2855..661ba0d78e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -74,14 +74,10 @@ jobs: # Ensure we don't break scripts - name: Build utils run: npm run build-utils - sonarcloud: - name: SonarCloud - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + + # No need to run the analysis from all environments - name: SonarCloud Scan + if: ${{ success() && matrix.os.name == 'ubuntu-20.04' }} uses: SonarSource/sonarcloud-github-action@master env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any From 2be0664862abba8895006eb2e5c0bf8a2104e7ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9line=20Souchet?= Date: Wed, 25 Nov 2020 19:34:46 +0100 Subject: [PATCH 06/28] Fix coverage generation --- test/e2e/jest.config.js | 21 +++++++++++++++++---- test/unit/jest.config.js | 12 +++++++----- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/test/e2e/jest.config.js b/test/e2e/jest.config.js index cc82ccf4c3..9ca919272d 100644 --- a/test/e2e/jest.config.js +++ b/test/e2e/jest.config.js @@ -14,10 +14,11 @@ * limitations under the License. */ module.exports = { + rootDir: '../..', + roots: ['./test/e2e', './src'], preset: 'jest-puppeteer', - roots: ['./'], testMatch: ['**/?(*.)+(spec|test).[t]s'], - testPathIgnorePatterns: ['/node_modules/', 'dist'], + testPathIgnorePatterns: ['/node_modules/', 'dist', 'src'], testTimeout: 200000, transform: { '^.+\\.ts?$': 'ts-jest', @@ -25,9 +26,21 @@ module.exports = { testEnvironment: 'jest-environment-puppeteer-jsdom', globalSetup: 'jest-environment-puppeteer-jsdom/setup', globalTeardown: 'jest-environment-puppeteer-jsdom/teardown', - setupFiles: ['./config/jest.globals.ts'], + collectCoverageFrom: ['**/*.{ts,js}'], + coveragePathIgnorePatterns: ['/node_modules/', 'dist', 'test', 'src/demo', 'src/static'], + coverageThreshold: { + global: { + branches: 80, + functions: 80, + lines: 80, + statements: 80, + }, + }, + coverageReporters: ['lcovonly', 'text', 'text-summary'], + coverageDirectory: 'build/test-report/e2e', + setupFiles: ['./test/e2e/config/jest.globals.ts'], // jest-image-snapshot configuration doesn't work with setupFiles, fix with setupFilesAfterEnv: see https://github.com/testing-library/jest-dom/issues/122#issuecomment-650520461 - setupFilesAfterEnv: ['./config/jest.image.ts'], + setupFilesAfterEnv: ['./test/e2e/config/jest.image.ts'], reporters: [ 'default', [ diff --git a/test/unit/jest.config.js b/test/unit/jest.config.js index 8d3e760bd4..79101e2bfb 100644 --- a/test/unit/jest.config.js +++ b/test/unit/jest.config.js @@ -14,19 +14,20 @@ * limitations under the License. */ module.exports = { - roots: ['./'], + rootDir: '../..', + roots: ['./test/unit', './src'], moduleNameMapper: { // mock files that jest doesn't support like CSS and SVG files '\\.css$': './../module-mock.js', '\\.svg$': './../module-mock.js', }, testMatch: ['**/?(*.)+(spec|test).[t]s'], - testPathIgnorePatterns: ['/node_modules/', 'dist'], + testPathIgnorePatterns: ['/node_modules/', 'dist', 'src'], transform: { '^.+\\.ts?$': 'ts-jest', }, collectCoverageFrom: ['**/*.{ts,js}'], - coveragePathIgnorePatterns: ['/node_modules/', 'dist', 'test'], + coveragePathIgnorePatterns: ['/node_modules/', 'dist', 'test', 'src/demo', 'src/static'], coverageThreshold: { global: { branches: 80, @@ -35,8 +36,9 @@ module.exports = { statements: 80, }, }, - coverageReporters: ['json', 'json-summary', 'lcov', 'text', 'text-summary', 'clover'], - setupFiles: ['./jest.globals.ts'], + coverageReporters: ['lcovonly', 'text', 'text-summary'], + coverageDirectory: 'build/test-report/unit', + setupFiles: ['./test/unit/jest.globals.ts'], reporters: [ 'default', [ From 62fadcf0bee478723026691549b33276e6c30d47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9line=20Souchet?= Date: Wed, 25 Nov 2020 19:35:51 +0100 Subject: [PATCH 07/28] Configure Sonar to get the coverage reports --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 9336da3e20..9fa4a73134 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -15,7 +15,7 @@ sonar.tests=test #sonar.test.exclusions= #sonar.test.inclusions= -sonar.javascript.lcov.reportPaths= +sonar.javascript.lcov.reportPaths=build/test-report/unit/lcov.info,build/test-report/e2e/lcov.info sonar.testExecutionReportPaths=build/test-report/unit/sonar-report.xml,build/test-report/e2e/sonar-report.xml sonar.eslint.reportPaths=build/eslint-reporter.json From 05d44ca07d75026e1e4e4c4579754fdd3bc77be9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9line=20Souchet?= Date: Wed, 25 Nov 2020 19:36:15 +0100 Subject: [PATCH 08/28] add coverage badge in README --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 26b60b2c12..294fac6606 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,9 @@ Build + + Coverage + Gitpod From 074bdf88fe07b6c87036c08238517c5a5d43d80a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9line=20Souchet?= Date: Wed, 25 Nov 2020 19:55:38 +0100 Subject: [PATCH 09/28] Run coverage only for ubuntu --- .github/workflows/build.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 661ba0d78e..5ab3517d88 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -55,7 +55,13 @@ jobs: run: npm run build - name: Test Application id: 'test_unit' - run: npm run test:unit + run: | + if ["${{ matrix.os.name }}" = "ubuntu-20.04"]; then + npm run test:unit:coverage + else + npm run test:unit + fi + shell: bash - name: Upload unit test results if: ${{ failure() && steps.test_unit.outcome == 'failure' }} uses: actions/upload-artifact@v2 @@ -64,7 +70,13 @@ jobs: path: build/test-report/unit - name: Test Application End to End id: 'test_e2e' - run: npm run test:e2e + run: | + if ["${{ matrix.os.name }}" = "ubuntu-20.04"]; then + npm run test:e2e:coverage + else + npm run test:e2e + fi + shell: bash - name: Upload e2e test results if: ${{ failure() && steps.test_e2e.outcome == 'failure' }} uses: actions/upload-artifact@v2 From 7d79cb8d7858a5a61bd7fe6518ce3e8d3cbd3c6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9line=20Souchet?= Date: Wed, 25 Nov 2020 20:12:00 +0100 Subject: [PATCH 10/28] Add a global property for coverage --- .github/workflows/build.yml | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5ab3517d88..a82b6c7d74 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,7 +34,7 @@ jobs: matrix: # syntax inspired from https://github.community/t5/GitHub-Actions/Using-a-matrix-defined-input-for-a-custom-action/m-p/32032/highlight/true#M988 os: - - { name: ubuntu-20.04 } + - { name: ubuntu-20.04, coverage: '-- --coverage' } - { name: macos-10.15 } - { name: windows-2019 } steps: @@ -55,13 +55,7 @@ jobs: run: npm run build - name: Test Application id: 'test_unit' - run: | - if ["${{ matrix.os.name }}" = "ubuntu-20.04"]; then - npm run test:unit:coverage - else - npm run test:unit - fi - shell: bash + run: npm run test:unit ${{ matrix.os.coverage }} - name: Upload unit test results if: ${{ failure() && steps.test_unit.outcome == 'failure' }} uses: actions/upload-artifact@v2 @@ -70,13 +64,7 @@ jobs: path: build/test-report/unit - name: Test Application End to End id: 'test_e2e' - run: | - if ["${{ matrix.os.name }}" = "ubuntu-20.04"]; then - npm run test:e2e:coverage - else - npm run test:e2e - fi - shell: bash + run: npm run test:e2e ${{ matrix.os.coverage }} - name: Upload e2e test results if: ${{ failure() && steps.test_e2e.outcome == 'failure' }} uses: actions/upload-artifact@v2 @@ -89,7 +77,7 @@ jobs: # No need to run the analysis from all environments - name: SonarCloud Scan - if: ${{ success() && matrix.os.name == 'ubuntu-20.04' }} + if: ${{ success() && contains(matrix.os.coverage, 'coverage') }} uses: SonarSource/sonarcloud-github-action@master env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any From 47e9dc06faef6372a1e73df284a660383f752e5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9line=20Souchet?= Date: Thu, 26 Nov 2020 14:35:43 +0100 Subject: [PATCH 11/28] Remove Eslint configuration for Sonar, because the job failed, if the lint check failed --- .github/workflows/build.yml | 2 +- sonar-project.properties | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a82b6c7d74..61f4cadf00 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,7 +50,7 @@ jobs: - name: Install dependencies run: npm ci - name: Lint check - run: npm run lint-check -- -f json -o build/eslint-reporter.json + run: npm run lint-check - name: Build Application run: npm run build - name: Test Application diff --git a/sonar-project.properties b/sonar-project.properties index 9fa4a73134..66b3e6d248 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -3,7 +3,7 @@ sonar.organization=process-analytics # This is the name and version displayed in the SonarCloud UI. sonar.projectName=bpmn-visualization -sonar.projectVersion=0.8.0 +sonar.projectVersion=0.7.0 # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. sonar.sources=src @@ -18,7 +18,8 @@ sonar.tests=test sonar.javascript.lcov.reportPaths=build/test-report/unit/lcov.info,build/test-report/e2e/lcov.info sonar.testExecutionReportPaths=build/test-report/unit/sonar-report.xml,build/test-report/e2e/sonar-report.xml -sonar.eslint.reportPaths=build/eslint-reporter.json +# The job failed before the sonar analysis, if the lint check failed. So no need to configure eslint for Sonar +#sonar.eslint.reportPaths=build/eslint-reporter.json sonar.typescript.tsconfigPath=tsconfig.json # Exclusions for copy-paste detection From 09731fc155b475be2c24647d08a6e25daed22dee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9line=20Souchet?= Date: Thu, 26 Nov 2020 14:36:47 +0100 Subject: [PATCH 12/28] Use the 1.4 version of the Sonar Github Action --- .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 61f4cadf00..9274de1170 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -78,7 +78,7 @@ jobs: # No need to run the analysis from all environments - name: SonarCloud Scan if: ${{ success() && contains(matrix.os.coverage, 'coverage') }} - uses: SonarSource/sonarcloud-github-action@master + uses: SonarSource/sonarcloud-github-action@v1.4 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} From bafe09b44d62c431b5dc0799a3b3c4b2fbe6ff47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9line=20Souchet?= Date: Thu, 26 Nov 2020 15:05:00 +0100 Subject: [PATCH 13/28] Remove the coverage thresholds --- test/e2e/jest.config.js | 8 -------- test/unit/jest.config.js | 8 -------- 2 files changed, 16 deletions(-) diff --git a/test/e2e/jest.config.js b/test/e2e/jest.config.js index 9ca919272d..e74b0213dd 100644 --- a/test/e2e/jest.config.js +++ b/test/e2e/jest.config.js @@ -28,14 +28,6 @@ module.exports = { globalTeardown: 'jest-environment-puppeteer-jsdom/teardown', collectCoverageFrom: ['**/*.{ts,js}'], coveragePathIgnorePatterns: ['/node_modules/', 'dist', 'test', 'src/demo', 'src/static'], - coverageThreshold: { - global: { - branches: 80, - functions: 80, - lines: 80, - statements: 80, - }, - }, coverageReporters: ['lcovonly', 'text', 'text-summary'], coverageDirectory: 'build/test-report/e2e', setupFiles: ['./test/e2e/config/jest.globals.ts'], diff --git a/test/unit/jest.config.js b/test/unit/jest.config.js index 79101e2bfb..f1e23540ad 100644 --- a/test/unit/jest.config.js +++ b/test/unit/jest.config.js @@ -28,14 +28,6 @@ module.exports = { }, collectCoverageFrom: ['**/*.{ts,js}'], coveragePathIgnorePatterns: ['/node_modules/', 'dist', 'test', 'src/demo', 'src/static'], - coverageThreshold: { - global: { - branches: 80, - functions: 80, - lines: 80, - statements: 80, - }, - }, coverageReporters: ['lcovonly', 'text', 'text-summary'], coverageDirectory: 'build/test-report/unit', setupFiles: ['./test/unit/jest.globals.ts'], From e12e44d7fe26d0514fb4d8a7b62f7ef2b92d0233 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9line=20Souchet?= Date: Thu, 26 Nov 2020 15:05:58 +0100 Subject: [PATCH 14/28] add 'src/model' to ignored path for the coverage --- test/e2e/jest.config.js | 2 +- test/unit/jest.config.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/e2e/jest.config.js b/test/e2e/jest.config.js index e74b0213dd..250cf78308 100644 --- a/test/e2e/jest.config.js +++ b/test/e2e/jest.config.js @@ -27,7 +27,7 @@ module.exports = { globalSetup: 'jest-environment-puppeteer-jsdom/setup', globalTeardown: 'jest-environment-puppeteer-jsdom/teardown', collectCoverageFrom: ['**/*.{ts,js}'], - coveragePathIgnorePatterns: ['/node_modules/', 'dist', 'test', 'src/demo', 'src/static'], + coveragePathIgnorePatterns: ['/node_modules/', 'dist', 'test', 'src/demo', 'src/static', 'src/model'], coverageReporters: ['lcovonly', 'text', 'text-summary'], coverageDirectory: 'build/test-report/e2e', setupFiles: ['./test/e2e/config/jest.globals.ts'], diff --git a/test/unit/jest.config.js b/test/unit/jest.config.js index f1e23540ad..41410e687d 100644 --- a/test/unit/jest.config.js +++ b/test/unit/jest.config.js @@ -27,7 +27,7 @@ module.exports = { '^.+\\.ts?$': 'ts-jest', }, collectCoverageFrom: ['**/*.{ts,js}'], - coveragePathIgnorePatterns: ['/node_modules/', 'dist', 'test', 'src/demo', 'src/static'], + coveragePathIgnorePatterns: ['/node_modules/', 'dist', 'test', 'src/demo', 'src/static', 'src/model'], coverageReporters: ['lcovonly', 'text', 'text-summary'], coverageDirectory: 'build/test-report/unit', setupFiles: ['./test/unit/jest.globals.ts'], From eb3e37f2ce2bd45a633468d6f62fbf62060b149f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9line=20Souchet?= Date: Thu, 26 Nov 2020 15:12:55 +0100 Subject: [PATCH 15/28] remove unnecessary type of pull request on github workflow --- .github/workflows/build.yml | 1 - sonar-project.properties | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9274de1170..d838139c16 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,7 +23,6 @@ on: - 'docs/**' - '*.md' - LICENSE - types: [opened, synchronize, reopened] jobs: build: diff --git a/sonar-project.properties b/sonar-project.properties index 66b3e6d248..8dbb038f0f 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,3 +1,4 @@ +# Organization and project keys are displayed in the right sidebar of the project homepage sonar.projectKey=process-analytics_bpmn-visualization-js sonar.organization=process-analytics From 246bb0e572aed188190f5ea9b96413034827526e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9line=20Souchet?= Date: Thu, 26 Nov 2020 15:33:07 +0100 Subject: [PATCH 16/28] Remove source config for Sonar --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 8dbb038f0f..25e6385c2b 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -7,7 +7,7 @@ sonar.projectName=bpmn-visualization sonar.projectVersion=0.7.0 # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. -sonar.sources=src +#sonar.sources=src #sonar.exclusions= #sonar.inclusions= From 201f7719822d13a8ae4397b5263461ff15bea7b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9line=20Souchet?= Date: Thu, 26 Nov 2020 15:47:23 +0100 Subject: [PATCH 17/28] Change path of source & test for Sonar config --- sonar-project.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sonar-project.properties b/sonar-project.properties index 25e6385c2b..4f02905be6 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -7,12 +7,12 @@ sonar.projectName=bpmn-visualization sonar.projectVersion=0.7.0 # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. -#sonar.sources=src +sonar.sources=./src #sonar.exclusions= #sonar.inclusions= # Path to tests -sonar.tests=test +sonar.tests=./test #sonar.test.exclusions= #sonar.test.inclusions= From e78c05c803a29829a022e91b977cb4e2ca43ed67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9line=20Souchet?= Date: Thu, 26 Nov 2020 16:13:54 +0100 Subject: [PATCH 18/28] Fix source encoding for Sonar --- sonar-project.properties | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sonar-project.properties b/sonar-project.properties index 4f02905be6..80d73636ad 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -7,12 +7,14 @@ sonar.projectName=bpmn-visualization sonar.projectVersion=0.7.0 # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. -sonar.sources=./src +sonar.sources=src #sonar.exclusions= #sonar.inclusions= +# Encoding of the source code. Default is default system encoding +sonar.sourceEncoding=UTF-8 # Path to tests -sonar.tests=./test +sonar.tests=test #sonar.test.exclusions= #sonar.test.inclusions= @@ -25,6 +27,3 @@ sonar.typescript.tsconfigPath=tsconfig.json # Exclusions for copy-paste detection #sonar.cpd.exclusions= - -# Encoding of the source code. Default is default system encoding -#sonar.sourceEncoding=UTF-8 From 6fd6757af96b531142f277aaea6566871a189bbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9line=20Souchet?= Date: Thu, 26 Nov 2020 16:16:15 +0100 Subject: [PATCH 19/28] exclude jest config files for the Sonar analysis --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 80d73636ad..8fda882009 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -15,7 +15,7 @@ sonar.sourceEncoding=UTF-8 # Path to tests sonar.tests=test -#sonar.test.exclusions= +sonar.test.exclusions=**/jest.config.js #sonar.test.inclusions= sonar.javascript.lcov.reportPaths=build/test-report/unit/lcov.info,build/test-report/e2e/lcov.info From f1b2e1c81ce70d379c55d23f6add691228959f14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9line=20Souchet?= Date: Thu, 26 Nov 2020 16:37:56 +0100 Subject: [PATCH 20/28] Eclude model from Sonar analysis --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 8fda882009..ea6437122b 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -8,7 +8,7 @@ sonar.projectVersion=0.7.0 # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. sonar.sources=src -#sonar.exclusions= +sonar.exclusions=src/model #sonar.inclusions= # Encoding of the source code. Default is default system encoding sonar.sourceEncoding=UTF-8 From 7574e127a51af31e1854cd5a95a5c1ffd445a6d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9line=20Souchet?= Date: Thu, 26 Nov 2020 16:38:25 +0100 Subject: [PATCH 21/28] Disable shallow clone for Sonar --- .github/workflows/build.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d838139c16..0c7ac7f72d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -37,7 +37,15 @@ jobs: - { name: macos-10.15 } - { name: windows-2019 } steps: - - uses: actions/checkout@v2 + - name: Checkout with shallow clone + uses: actions/checkout@v2 + if: ${{ !contains(matrix.os.coverage, 'coverage') }} + - name: Checkout without shallow clone + uses: actions/checkout@v2 + if: ${{ contains(matrix.os.coverage, 'coverage') }} + with: + # Disabling shallow clone is recommended for improving relevancy of reporting + fetch-depth: 0 - name: Setup node uses: actions/setup-node@v1 with: From 168a12b3e3a880e72fb81a9e5382f157da727f4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9line=20Souchet?= Date: Thu, 26 Nov 2020 17:15:11 +0100 Subject: [PATCH 22/28] Disable tsconfig --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index ea6437122b..9f896711ac 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -23,7 +23,7 @@ sonar.testExecutionReportPaths=build/test-report/unit/sonar-report.xml,build/tes # The job failed before the sonar analysis, if the lint check failed. So no need to configure eslint for Sonar #sonar.eslint.reportPaths=build/eslint-reporter.json -sonar.typescript.tsconfigPath=tsconfig.json +#sonar.typescript.tsconfigPath=tsconfig.json # Exclusions for copy-paste detection #sonar.cpd.exclusions= From 1ad461d23a6177fb891b7311c565de52a52ae9e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9line=20Souchet?= Date: Thu, 26 Nov 2020 17:29:01 +0100 Subject: [PATCH 23/28] Disable src for Sonar config --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 9f896711ac..5f96a45e93 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -7,7 +7,7 @@ sonar.projectName=bpmn-visualization sonar.projectVersion=0.7.0 # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. -sonar.sources=src +#sonar.sources=src sonar.exclusions=src/model #sonar.inclusions= # Encoding of the source code. Default is default system encoding From 9b4e874db86658bac6df51dcff9f5079db60f62f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9line=20Souchet?= Date: Thu, 26 Nov 2020 17:39:45 +0100 Subject: [PATCH 24/28] Enable src for Sonar config & change exclusions --- sonar-project.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sonar-project.properties b/sonar-project.properties index 5f96a45e93..40171f9556 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -7,8 +7,8 @@ sonar.projectName=bpmn-visualization sonar.projectVersion=0.7.0 # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. -#sonar.sources=src -sonar.exclusions=src/model +sonar.sources=src +sonar.exclusions=model #sonar.inclusions= # Encoding of the source code. Default is default system encoding sonar.sourceEncoding=UTF-8 From 747b6257929ebb1a317898bb4abde42952bd99e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9line=20Souchet?= Date: Thu, 26 Nov 2020 19:32:01 +0100 Subject: [PATCH 25/28] Config works in local --- sonar-project.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sonar-project.properties b/sonar-project.properties index 40171f9556..038d69bc8a 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -8,14 +8,14 @@ sonar.projectVersion=0.7.0 # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. sonar.sources=src -sonar.exclusions=model +sonar.exclusions=src/model,src/demo,src/static #sonar.inclusions= # Encoding of the source code. Default is default system encoding sonar.sourceEncoding=UTF-8 # Path to tests sonar.tests=test -sonar.test.exclusions=**/jest.config.js +sonar.test.exclusions=**/jest.config.js,**/*.png #sonar.test.inclusions= sonar.javascript.lcov.reportPaths=build/test-report/unit/lcov.info,build/test-report/e2e/lcov.info @@ -23,7 +23,7 @@ sonar.testExecutionReportPaths=build/test-report/unit/sonar-report.xml,build/tes # The job failed before the sonar analysis, if the lint check failed. So no need to configure eslint for Sonar #sonar.eslint.reportPaths=build/eslint-reporter.json -#sonar.typescript.tsconfigPath=tsconfig.json +sonar.typescript.tsconfigPath=tsconfig.json # Exclusions for copy-paste detection #sonar.cpd.exclusions= From d3cac9d0e6776ade0cd3c65b99ff899176d17215 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9line=20Souchet?= Date: Fri, 27 Nov 2020 10:43:31 +0100 Subject: [PATCH 26/28] Exclude files from src/model, src/demo and src/static --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 038d69bc8a..0f46ca0135 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -8,7 +8,7 @@ sonar.projectVersion=0.7.0 # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. sonar.sources=src -sonar.exclusions=src/model,src/demo,src/static +sonar.exclusions=src/model/**/*,src/demo/**/*,src/static/**/* #sonar.inclusions= # Encoding of the source code. Default is default system encoding sonar.sourceEncoding=UTF-8 From 0880bdc1f09b72b142f988ede9dab4e767207cba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Souchet=20C=C3=A9line?= <4921914+csouchet@users.noreply.github.com> Date: Fri, 27 Nov 2020 10:50:39 +0100 Subject: [PATCH 27/28] Apply suggestions from code review Co-authored-by: Thomas Bouffard <27200110+tbouffard@users.noreply.github.com> --- .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 0c7ac7f72d..a3c68e3a83 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,7 +44,7 @@ jobs: uses: actions/checkout@v2 if: ${{ contains(matrix.os.coverage, 'coverage') }} with: - # Disabling shallow clone is recommended for improving relevancy of reporting + # Disabling shallow clone is recommended for improving relevancy of SonarCloud reporting fetch-depth: 0 - name: Setup node uses: actions/setup-node@v1 From ec1817332ae4e91d4d0c3f54d8d5e89024b295ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9line=20Souchet?= Date: Fri, 27 Nov 2020 11:51:13 +0100 Subject: [PATCH 28/28] Fix ignore test paths on test:e2e:coverage --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index aba62d1930..5464d8206d 100644 --- a/package.json +++ b/package.json @@ -62,11 +62,11 @@ "lint-check": "tsc --noEmit && eslint \"*/**/*.{js,ts,tsx}\" NOTICE --max-warnings 0", "test": "run-s test:unit test:e2e", "test:unit": "jest --runInBand --config=./test/unit/jest.config.js", - "test:unit:coverage": "jest --runInBand --config=./test/unit/jest.config.js --coverage", - "test:unit:watch": "jest --runInBand --config=./test/unit/jest.config.js --coverage --watchAll", + "test:unit:coverage": "npm run test:unit -- --coverage", + "test:unit:watch": "npm run test:unit:coverage -- --watchAll", "test:e2e": "cross-env DEBUG=test JEST_IMAGE_SNAPSHOT_TRACK_OBSOLETE=1 JEST_PUPPETEER_CONFIG=./test/e2e/jest-puppeteer.config.js jest --runInBand --detectOpenHandles --testPathIgnorePatterns ./test/e2e/performance --config=./test/e2e/jest.config.js", "test:perf": "cd ./test/e2e && jest --runInBand --detectOpenHandles --testNamePattern=performance", - "test:e2e:coverage": "cross-env JEST_IMAGE_SNAPSHOT_TRACK_OBSOLETE=1 jest --runInBand --detectOpenHandles --config=./test/e2e/jest.config.js --coverage" + "test:e2e:coverage": "npm run test:e2e -- --coverage" }, "dependencies": { "entities": "^2.1.0",