-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[INFRA] Add SonarCloud analysis on CI build #906
Changes from all commits
a57bce3
b50b176
78ccba8
263ac74
410ea9f
2be0664
62fadcf
05d44ca
074bdf8
7d79cb8
47e9dc0
09731fc
bafe09b
e12e44d
eb3e37f
246bb0e
201f771
e78c05c
6fd6757
f1b2e1c
7574e12
168a12b
1ad461d
9b4e874
747b625
d3cac9d
0880bdc
ec18173
ff38e70
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,11 +33,19 @@ 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: | ||
- 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 SonarCloud reporting | ||
fetch-depth: 0 | ||
- name: Setup node | ||
uses: actions/setup-node@v1 | ||
with: | ||
|
@@ -54,7 +62,7 @@ jobs: | |
run: npm run build | ||
- name: Test Application | ||
id: 'test_unit' | ||
run: npm run test:unit | ||
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 | ||
|
@@ -63,7 +71,7 @@ jobs: | |
path: build/test-report/unit | ||
- name: Test Application End to End | ||
id: 'test_e2e' | ||
run: npm run test:e2e | ||
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 | ||
|
@@ -73,3 +81,11 @@ jobs: | |
# Ensure we don't break scripts | ||
- name: Build utils | ||
run: npm run build-utils | ||
|
||
# No need to run the analysis from all environments | ||
- name: SonarCloud Scan | ||
if: ${{ success() && contains(matrix.os.coverage, 'coverage') }} | ||
uses: SonarSource/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,9 @@ | |
<a href="https://github.com/process-analytics/bpmn-visualization-js/actions"> | ||
<img alt="Build" src="https://github.com/process-analytics/bpmn-visualization-js/workflows/Build/badge.svg"> | ||
</a> | ||
<a href="https://sonarcloud.io/dashboard?id=process-analytics_bpmn-visualization-js"> | ||
<img alt="Coverage" src="https://sonarcloud.io/api/project_badges/measure?project=process-analytics_bpmn-visualization-js&metric=coverage"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
</a> | ||
<a href="https://gitpod.io/#https://github.com/process-analytics/bpmn-visualization-js" target="_blank"> | ||
<img alt="Gitpod" src="https://img.shields.io/badge/Gitpod-ready--to--code-chartreuse?logo=gitpod"> | ||
</a> | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❓ did you try There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't think to do that ^^ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it's adapted to what we want to do. I tried with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So let's keep it |
||
"test:unit:watch": "npm run test:unit:coverage -- --watchAll", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, the coverage was already run as part of the 'watch', so there is no behaviour change. |
||
"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", | ||
|
@@ -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", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❓ do you know if this has perf impact on our local dev i.e if you have seen processing time increase when running tests? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't check yet. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. UbuntuBefore jest-sonar integration
After jest-sonar integration
MacOSBefore jest-sonar integration
After jest-sonar integration
WindowsBefore jest-sonar integration
After jest-sonar integration
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, thanks for the figures |
||
"lint-staged": "^10.5.2", | ||
"minimist": "^1.2.5", | ||
"mxgraph-type-definitions": "^1.0.4", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# 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 | ||
|
||
# This is the name and version displayed in the SonarCloud UI. | ||
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/**/*,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,**/*.png | ||
#sonar.test.inclusions= | ||
|
||
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 | ||
|
||
# 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 | ||
#sonar.cpd.exclusions= |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,29 +14,23 @@ | |
* 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'], | ||
coverageThreshold: { | ||
global: { | ||
branches: 80, | ||
functions: 80, | ||
lines: 80, | ||
statements: 80, | ||
}, | ||
}, | ||
Comment on lines
-30
to
-37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❓ I guess this disable the 'fail build' detection when we are under the threshold? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes ^^ |
||
coverageReporters: ['json', 'json-summary', 'lcov', 'text', 'text-summary', 'clover'], | ||
setupFiles: ['./jest.globals.ts'], | ||
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'], | ||
reporters: [ | ||
'default', | ||
[ | ||
|
@@ -48,5 +42,11 @@ module.exports = { | |
includeSuiteFailure: true, | ||
}, | ||
], | ||
[ | ||
'jest-sonar', | ||
{ | ||
outputDirectory: 'build/test-report/unit', | ||
}, | ||
], | ||
], | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good way to configure the step according to the os! I am not this is the best name, for now, it is ok (I don't have any best proposal 😸)