Skip to content

Commit d190cdc

Browse files
authored
Switch coverage to SonarQube (matrix-org#2334)
1 parent b896111 commit d190cdc

File tree

7 files changed

+149
-43
lines changed

7 files changed

+149
-43
lines changed

.github/codecov.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

.github/workflows/sonarqube.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: SonarQube
2+
on:
3+
workflow_run:
4+
workflows: [ "Tests" ]
5+
types:
6+
- completed
7+
jobs:
8+
sonarqube:
9+
name: SonarQube
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
with:
14+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
15+
16+
# There's a 'download artifact' action, but it hasn't been updated for the workflow_run action
17+
# (https://github.com/actions/download-artifact/issues/60) so instead we get this mess:
18+
- name: Download Coverage Report
19+
uses: actions/[email protected]
20+
if: github.event.workflow_run.conclusion == 'success'
21+
with:
22+
script: |
23+
const artifacts = await github.actions.listWorkflowRunArtifacts({
24+
owner: context.repo.owner,
25+
repo: context.repo.repo,
26+
run_id: ${{ github.event.workflow_run.id }},
27+
});
28+
const matchArtifact = artifacts.data.artifacts.filter((artifact) => {
29+
return artifact.name == "coverage"
30+
})[0];
31+
const download = await github.actions.downloadArtifact({
32+
owner: context.repo.owner,
33+
repo: context.repo.repo,
34+
artifact_id: matchArtifact.id,
35+
archive_format: 'zip',
36+
});
37+
const fs = require('fs');
38+
fs.writeFileSync('${{github.workspace}}/coverage.zip', Buffer.from(download.data));
39+
40+
- name: Extract Coverage Report
41+
run: unzip -d coverage coverage.zip && rm coverage.zip
42+
if: github.event.workflow_run.conclusion == 'success'
43+
44+
- name: SonarCloud Scan
45+
uses: SonarSource/sonarcloud-github-action@master
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
48+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

.github/workflows/static_analysis.yml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,3 @@ jobs:
5151

5252
- name: Generate Docs
5353
run: "yarn run gendoc"
54-
55-
sonarqube:
56-
name: SonarQube
57-
runs-on: ubuntu-latest
58-
steps:
59-
- uses: actions/checkout@v2
60-
with:
61-
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
62-
- name: SonarCloud Scan
63-
uses: SonarSource/sonarcloud-github-action@master
64-
env:
65-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
66-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

.github/workflows/tests.yml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,11 @@ on:
55
branches: [ develop, main, master ]
66
jobs:
77
jest:
8-
name: Jest with Codecov
8+
name: Jest
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Checkout code
1212
uses: actions/checkout@v2
13-
with:
14-
# If this is a pull request, make sure we check out its head rather than the
15-
# automatically generated merge commit, so that the coverage diff excludes
16-
# unrelated changes in the base branch
17-
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || '' }}
1813

1914
- name: Yarn cache
2015
uses: actions/setup-node@v3
@@ -28,11 +23,12 @@ jobs:
2823
run: "yarn build"
2924

3025
- name: Run tests with coverage
31-
run: "yarn coverage"
26+
run: "yarn coverage --ci"
3227

33-
- name: Upload coverage
34-
uses: codecov/codecov-action@v2
28+
- name: Upload Artifact
29+
uses: actions/upload-artifact@v2
3530
with:
36-
fail_ci_if_error: false
37-
verbose: true
38-
override_commit: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || '' }}
31+
name: coverage
32+
path: |
33+
coverage
34+
!coverage/lcov-report

package.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
"fake-indexeddb": "^3.1.2",
101101
"jest": "^26.6.3",
102102
"jest-localstorage-mock": "^2.4.6",
103+
"jest-sonar-reporter": "^2.0.0",
103104
"jsdoc": "^3.6.6",
104105
"matrix-mock-request": "^1.2.3",
105106
"rimraf": "^3.0.2",
@@ -116,8 +117,13 @@
116117
"<rootDir>/src/**/*.{js,ts}"
117118
],
118119
"coverageReporters": [
119-
"text",
120-
"json"
121-
]
120+
"text-summary",
121+
"lcov"
122+
],
123+
"testResultsProcessor": "jest-sonar-reporter"
124+
},
125+
"jestSonar": {
126+
"reportPath": "coverage",
127+
"sonar56x": true
122128
}
123129
}

sonar-project.properties

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,9 @@ sonar.organization=matrix-org
1414
sonar.sources=src
1515
sonar.tests=spec
1616
sonar.exclusions=docs,examples,git-hooks
17+
18+
sonar.typescript.tsconfigPath=./tsconfig.json
19+
sonar.javascript.lcov.reportPaths=coverage/lcov.info
20+
sonar.coverage.exclusions=spec/*.ts
21+
sonar.testExecutionReportPaths=coverage/test-report.xml
22+
sonar.genericcoverage.unitTestReportPaths=coverage/test-report.xml

yarn.lock

Lines changed: 78 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,15 @@
108108
jsesc "^2.5.1"
109109
source-map "^0.5.0"
110110

111+
"@babel/generator@^7.17.10":
112+
version "7.17.10"
113+
resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.17.10.tgz#c281fa35b0c349bbe9d02916f4ae08fc85ed7189"
114+
integrity sha512-46MJZZo9y3o4kmhBVc7zW7i8dtR1oIK/sdO5NcfcZRhTGYi+KKJRtHNgsU6c4VUcJmUNV/LQdebD/9Dlv4K+Tg==
115+
dependencies:
116+
"@babel/types" "^7.17.10"
117+
"@jridgewell/gen-mapping" "^0.1.0"
118+
jsesc "^2.5.1"
119+
111120
"@babel/helper-annotate-as-pure@^7.16.7":
112121
version "7.16.7"
113122
resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.16.7.tgz#bb2339a7534a9c128e3102024c60760a3a7f3862"
@@ -321,6 +330,11 @@
321330
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.17.9.tgz#9c94189a6062f0291418ca021077983058e171ef"
322331
integrity sha512-vqUSBLP8dQHFPdPi9bc5GK9vRkYHJ49fsZdtoJ8EQ8ibpwk5rPKfvNIwChB0KVXcIjcepEBBd2VHC5r9Gy8ueg==
323332

333+
"@babel/parser@^7.17.10":
334+
version "7.17.10"
335+
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.17.10.tgz#873b16db82a8909e0fbd7f115772f4b739f6ce78"
336+
integrity sha512-n2Q6i+fnJqzOaq2VkdXxy2TCPCWQZHiCo0XqmrCvDWcZQKRyZzYi4Z0yxlBuN0w+r2ZHmre+Q087DSrw3pbJDQ==
337+
324338
"@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@^7.16.7":
325339
version "7.16.7"
326340
resolved "https://registry.yarnpkg.com/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/-/plugin-bugfix-safari-id-destructuring-collision-in-function-expression-7.16.7.tgz#4eda6d6c2a0aa79c70fa7b6da67763dfe2141050"
@@ -982,7 +996,23 @@
982996
"@babel/parser" "^7.16.7"
983997
"@babel/types" "^7.16.7"
984998

985-
"@babel/traverse@^7.1.0", "@babel/traverse@^7.1.6", "@babel/traverse@^7.13.0", "@babel/traverse@^7.16.7", "@babel/traverse@^7.16.8", "@babel/traverse@^7.17.3", "@babel/traverse@^7.17.9":
999+
"@babel/traverse@^7.1.0":
1000+
version "7.17.10"
1001+
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.17.10.tgz#1ee1a5ac39f4eac844e6cf855b35520e5eb6f8b5"
1002+
integrity sha512-VmbrTHQteIdUUQNTb+zE12SHS/xQVIShmBPhlNP12hD5poF2pbITW1Z4172d03HegaQWhLffdkRJYtAzp0AGcw==
1003+
dependencies:
1004+
"@babel/code-frame" "^7.16.7"
1005+
"@babel/generator" "^7.17.10"
1006+
"@babel/helper-environment-visitor" "^7.16.7"
1007+
"@babel/helper-function-name" "^7.17.9"
1008+
"@babel/helper-hoist-variables" "^7.16.7"
1009+
"@babel/helper-split-export-declaration" "^7.16.7"
1010+
"@babel/parser" "^7.17.10"
1011+
"@babel/types" "^7.17.10"
1012+
debug "^4.1.0"
1013+
globals "^11.1.0"
1014+
1015+
"@babel/traverse@^7.1.6", "@babel/traverse@^7.13.0", "@babel/traverse@^7.16.7", "@babel/traverse@^7.16.8", "@babel/traverse@^7.17.3", "@babel/traverse@^7.17.9":
9861016
version "7.17.9"
9871017
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.17.9.tgz#1f9b207435d9ae4a8ed6998b2b82300d83c37a0d"
9881018
integrity sha512-PQO8sDIJ8SIwipTPiR71kJQCKQYB5NGImbOviK8K+kg5xkNSYXLBupuX9QhatFowrsvo9Hj8WgArg3W7ijNAQw==
@@ -1006,6 +1036,14 @@
10061036
"@babel/helper-validator-identifier" "^7.16.7"
10071037
to-fast-properties "^2.0.0"
10081038

1039+
"@babel/types@^7.17.10":
1040+
version "7.17.10"
1041+
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.17.10.tgz#d35d7b4467e439fcf06d195f8100e0fea7fc82c4"
1042+
integrity sha512-9O26jG0mBYfGkUYCYZRnBwbVLd1UZOICEr2Em6InB6jVfsAv1GKgwXHmrSg+WFWDmeKTA6vyTZiN8tCSM5Oo3A==
1043+
dependencies:
1044+
"@babel/helper-validator-identifier" "^7.16.7"
1045+
to-fast-properties "^2.0.0"
1046+
10091047
"@bcoe/v8-coverage@^0.2.3":
10101048
version "0.2.3"
10111049
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
@@ -1235,11 +1273,24 @@
12351273
"@types/yargs" "^15.0.0"
12361274
chalk "^4.0.0"
12371275

1276+
"@jridgewell/gen-mapping@^0.1.0":
1277+
version "0.1.1"
1278+
resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz#e5d2e450306a9491e3bd77e323e38d7aff315996"
1279+
integrity sha512-sQXCasFk+U8lWYEe66WxRDOE9PjVz4vSM51fTu3Hw+ClTpUSQb718772vH3pyS5pShp6lvQM7SxgIDXXXmOX7w==
1280+
dependencies:
1281+
"@jridgewell/set-array" "^1.0.0"
1282+
"@jridgewell/sourcemap-codec" "^1.4.10"
1283+
12381284
"@jridgewell/resolve-uri@^3.0.3":
12391285
version "3.0.5"
12401286
resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.0.5.tgz#68eb521368db76d040a6315cdb24bf2483037b9c"
12411287
integrity sha512-VPeQ7+wH0itvQxnG+lIzWgkysKIr3L9sslimFW55rHMdGu/qCQ5z5h9zq4gI8uBtqkpHhsF4Z/OwExufUCThew==
12421288

1289+
"@jridgewell/set-array@^1.0.0":
1290+
version "1.1.0"
1291+
resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.0.tgz#1179863356ac8fbea64a5a4bcde93a4871012c01"
1292+
integrity sha512-SfJxIxNVYLTsKwzB3MoOQ1yxf4w/E6MdkvTgrgAt1bfxjSrLUoHMKrDOykwN14q65waezZIdqDneUIPh4/sKxg==
1293+
12431294
"@jridgewell/sourcemap-codec@^1.4.10":
12441295
version "1.4.11"
12451296
resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.11.tgz#771a1d8d744eeb71b6adb35808e1a6c7b9b8c8ec"
@@ -1434,13 +1485,20 @@
14341485
"@babel/parser" "^7.1.0"
14351486
"@babel/types" "^7.0.0"
14361487

1437-
"@types/babel__traverse@*", "@types/babel__traverse@^7.0.4", "@types/babel__traverse@^7.0.6":
1488+
"@types/babel__traverse@*", "@types/babel__traverse@^7.0.6":
14381489
version "7.17.0"
14391490
resolved "https://registry.yarnpkg.com/@types/babel__traverse/-/babel__traverse-7.17.0.tgz#7a9b80f712fe2052bc20da153ff1e552404d8e4b"
14401491
integrity sha512-r8aveDbd+rzGP+ykSdF3oPuTVRWRfbBiHl0rVDM2yNEmSMXfkObQLV46b4RnCv3Lra51OlfnZhkkFaDl2MIRaA==
14411492
dependencies:
14421493
"@babel/types" "^7.3.0"
14431494

1495+
"@types/babel__traverse@^7.0.4":
1496+
version "7.17.1"
1497+
resolved "https://registry.yarnpkg.com/@types/babel__traverse/-/babel__traverse-7.17.1.tgz#1a0e73e8c28c7e832656db372b779bfd2ef37314"
1498+
integrity sha512-kVzjari1s2YVi77D3w1yuvohV2idweYXMCDzqBiVNN63TcDWrIlTVOYpqVrvbbyOE/IyzBoTKF0fdnLPEORFxA==
1499+
dependencies:
1500+
"@babel/types" "^7.3.0"
1501+
14441502
"@types/babylon@^6.16.2":
14451503
version "6.16.6"
14461504
resolved "https://registry.yarnpkg.com/@types/babylon/-/babylon-6.16.6.tgz#a1e7e01567b26a5ebad321a74d10299189d8d932"
@@ -1731,7 +1789,12 @@ acorn@^7.0.0, acorn@^7.1.1:
17311789
resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa"
17321790
integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==
17331791

1734-
acorn@^8.2.4, acorn@^8.5.0, acorn@^8.7.0:
1792+
acorn@^8.2.4:
1793+
version "8.7.1"
1794+
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.7.1.tgz#0197122c843d1bf6d0a5e83220a788f278f63c30"
1795+
integrity sha512-Xx54uLJQZ19lKygFXOWsscKUbsBZW0CPykPhVQdhIeIwrbPmJzqeASDInc8nKBnp/JT6igTs82qPXz069H8I/A==
1796+
1797+
acorn@^8.5.0, acorn@^8.7.0:
17351798
version "8.7.0"
17361799
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.7.0.tgz#90951fde0f8f09df93549481e5fc141445b791cf"
17371800
integrity sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==
@@ -5000,6 +5063,13 @@ jest-snapshot@^26.6.2:
50005063
pretty-format "^26.6.2"
50015064
semver "^7.3.2"
50025065

5066+
jest-sonar-reporter@^2.0.0:
5067+
version "2.0.0"
5068+
resolved "https://registry.yarnpkg.com/jest-sonar-reporter/-/jest-sonar-reporter-2.0.0.tgz#faa54a7d2af7198767ee246a82b78c576789cf08"
5069+
integrity sha512-ZervDCgEX5gdUbdtWsjdipLN3bKJwpxbvhkYNXTAYvAckCihobSLr9OT/IuyNIRT1EZMDDwR6DroWtrq+IL64w==
5070+
dependencies:
5071+
xml "^1.0.1"
5072+
50035073
jest-util@^26.6.2:
50045074
version "26.6.2"
50055075
resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-26.6.2.tgz#907535dbe4d5a6cb4c47ac9b926f6af29576cbc1"
@@ -7970,6 +8040,11 @@ xml-name-validator@^3.0.0:
79708040
resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a"
79718041
integrity sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw==
79728042

8043+
xml@^1.0.1:
8044+
version "1.0.1"
8045+
resolved "https://registry.yarnpkg.com/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5"
8046+
integrity sha1-eLpyAgApxbyHuKgaPPzXS0ovweU=
8047+
79738048
xmlchars@^2.2.0:
79748049
version "2.2.0"
79758050
resolved "https://registry.yarnpkg.com/xmlchars/-/xmlchars-2.2.0.tgz#060fe1bcb7f9c76fe2a17db86a9bc3ab894210cb"

0 commit comments

Comments
 (0)