mirror of https://github.com/vector-im/riot-web
Switch coverage over to SonarQube (#8463)
parent
3e31fdb6a7
commit
7477a2df7d
|
@ -1,12 +0,0 @@
|
||||||
codecov:
|
|
||||||
allow_coverage_offsets: True
|
|
||||||
coverage:
|
|
||||||
status:
|
|
||||||
project: off
|
|
||||||
patch: off
|
|
||||||
comment:
|
|
||||||
layout: "diff, files"
|
|
||||||
behavior: default
|
|
||||||
require_changes: false
|
|
||||||
require_base: no
|
|
||||||
require_head: no
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
name: SonarQube
|
||||||
|
on:
|
||||||
|
workflow_run:
|
||||||
|
workflows: [ "Tests" ]
|
||||||
|
types:
|
||||||
|
- completed
|
||||||
|
jobs:
|
||||||
|
sonarqube:
|
||||||
|
name: SonarQube
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
|
||||||
|
|
||||||
|
# There's a 'download artifact' action, but it hasn't been updated for the workflow_run action
|
||||||
|
# (https://github.com/actions/download-artifact/issues/60) so instead we get this mess:
|
||||||
|
- name: Download Coverage Report
|
||||||
|
uses: actions/github-script@v3.1.0
|
||||||
|
if: github.event.workflow_run.conclusion == 'success'
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const artifacts = await github.actions.listWorkflowRunArtifacts({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
run_id: ${{ github.event.workflow_run.id }},
|
||||||
|
});
|
||||||
|
const matchArtifact = artifacts.data.artifacts.filter((artifact) => {
|
||||||
|
return artifact.name == "coverage"
|
||||||
|
})[0];
|
||||||
|
const download = await github.actions.downloadArtifact({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
artifact_id: matchArtifact.id,
|
||||||
|
archive_format: 'zip',
|
||||||
|
});
|
||||||
|
const fs = require('fs');
|
||||||
|
fs.writeFileSync('${{github.workspace}}/coverage.zip', Buffer.from(download.data));
|
||||||
|
- name: Extract Coverage Report
|
||||||
|
run: unzip -d coverage coverage.zip && rm coverage.zip
|
||||||
|
if: github.event.workflow_run.conclusion == 'success'
|
||||||
|
|
||||||
|
- 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 }}
|
|
@ -87,16 +87,3 @@ jobs:
|
||||||
|
|
||||||
- name: Run Linter
|
- name: Run Linter
|
||||||
run: "yarn run lint:style"
|
run: "yarn run lint:style"
|
||||||
|
|
||||||
sonarqube:
|
|
||||||
name: "SonarQube"
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
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 }}
|
|
||||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
|
||||||
|
|
|
@ -11,16 +11,11 @@ env:
|
||||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||||
jobs:
|
jobs:
|
||||||
jest:
|
jest:
|
||||||
name: Jest with Codecov
|
name: Jest
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
with:
|
|
||||||
# If this is a pull request, make sure we check out its head rather than the
|
|
||||||
# automatically generated merge commit, so that the coverage diff excludes
|
|
||||||
# unrelated changes in the base branch
|
|
||||||
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || '' }}
|
|
||||||
|
|
||||||
- name: Yarn cache
|
- name: Yarn cache
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
|
@ -31,11 +26,12 @@ jobs:
|
||||||
run: "./scripts/ci/install-deps.sh --ignore-scripts"
|
run: "./scripts/ci/install-deps.sh --ignore-scripts"
|
||||||
|
|
||||||
- name: Run tests with coverage
|
- name: Run tests with coverage
|
||||||
run: "yarn coverage"
|
run: "yarn coverage --ci"
|
||||||
|
|
||||||
- name: Upload coverage
|
- name: Upload Artifact
|
||||||
uses: codecov/codecov-action@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
fail_ci_if_error: false
|
name: coverage
|
||||||
verbose: true
|
path: |
|
||||||
override_commit: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || '' }}
|
coverage
|
||||||
|
!coverage/lcov-report
|
||||||
|
|
12
package.json
12
package.json
|
@ -184,6 +184,7 @@
|
||||||
"jest-fetch-mock": "^3.0.3",
|
"jest-fetch-mock": "^3.0.3",
|
||||||
"jest-mock": "^27.5.1",
|
"jest-mock": "^27.5.1",
|
||||||
"jest-raw-loader": "^1.0.1",
|
"jest-raw-loader": "^1.0.1",
|
||||||
|
"jest-sonar-reporter": "^2.0.0",
|
||||||
"matrix-mock-request": "^1.2.3",
|
"matrix-mock-request": "^1.2.3",
|
||||||
"matrix-react-test-utils": "^0.2.3",
|
"matrix-react-test-utils": "^0.2.3",
|
||||||
"matrix-web-i18n": "^1.2.0",
|
"matrix-web-i18n": "^1.2.0",
|
||||||
|
@ -233,9 +234,14 @@
|
||||||
"<rootDir>/src/**/*.{js,ts,tsx}"
|
"<rootDir>/src/**/*.{js,ts,tsx}"
|
||||||
],
|
],
|
||||||
"coverageReporters": [
|
"coverageReporters": [
|
||||||
"text",
|
"text-summary",
|
||||||
"json"
|
"lcov"
|
||||||
]
|
],
|
||||||
|
"testResultsProcessor": "jest-sonar-reporter"
|
||||||
|
},
|
||||||
|
"jestSonar": {
|
||||||
|
"reportPath": "coverage",
|
||||||
|
"sonar56x": true
|
||||||
},
|
},
|
||||||
"typings": "./lib/index.d.ts"
|
"typings": "./lib/index.d.ts"
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,3 +14,9 @@ sonar.organization=matrix-org
|
||||||
sonar.sources=src,res
|
sonar.sources=src,res
|
||||||
sonar.tests=test,cypress
|
sonar.tests=test,cypress
|
||||||
sonar.exclusions=__mocks__,docs
|
sonar.exclusions=__mocks__,docs
|
||||||
|
|
||||||
|
sonar.typescript.tsconfigPath=./tsconfig.json
|
||||||
|
sonar.javascript.lcov.reportPaths=coverage/lcov.info
|
||||||
|
sonar.coverage.exclusions=spec/*.ts
|
||||||
|
sonar.testExecutionReportPaths=coverage/test-report.xml
|
||||||
|
sonar.genericcoverage.unitTestReportPaths=coverage/test-report.xml
|
||||||
|
|
12
yarn.lock
12
yarn.lock
|
@ -6072,6 +6072,13 @@ jest-snapshot@^27.5.1:
|
||||||
pretty-format "^27.5.1"
|
pretty-format "^27.5.1"
|
||||||
semver "^7.3.2"
|
semver "^7.3.2"
|
||||||
|
|
||||||
|
jest-sonar-reporter@^2.0.0:
|
||||||
|
version "2.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/jest-sonar-reporter/-/jest-sonar-reporter-2.0.0.tgz#faa54a7d2af7198767ee246a82b78c576789cf08"
|
||||||
|
integrity sha512-ZervDCgEX5gdUbdtWsjdipLN3bKJwpxbvhkYNXTAYvAckCihobSLr9OT/IuyNIRT1EZMDDwR6DroWtrq+IL64w==
|
||||||
|
dependencies:
|
||||||
|
xml "^1.0.1"
|
||||||
|
|
||||||
jest-util@^26.6.2:
|
jest-util@^26.6.2:
|
||||||
version "26.6.2"
|
version "26.6.2"
|
||||||
resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-26.6.2.tgz#907535dbe4d5a6cb4c47ac9b926f6af29576cbc1"
|
resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-26.6.2.tgz#907535dbe4d5a6cb4c47ac9b926f6af29576cbc1"
|
||||||
|
@ -9538,6 +9545,11 @@ xml-name-validator@^3.0.0:
|
||||||
resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a"
|
resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a"
|
||||||
integrity sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw==
|
integrity sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw==
|
||||||
|
|
||||||
|
xml@^1.0.1:
|
||||||
|
version "1.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5"
|
||||||
|
integrity sha1-eLpyAgApxbyHuKgaPPzXS0ovweU=
|
||||||
|
|
||||||
xmlchars@^2.2.0:
|
xmlchars@^2.2.0:
|
||||||
version "2.2.0"
|
version "2.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/xmlchars/-/xmlchars-2.2.0.tgz#060fe1bcb7f9c76fe2a17db86a9bc3ab894210cb"
|
resolved "https://registry.yarnpkg.com/xmlchars/-/xmlchars-2.2.0.tgz#060fe1bcb7f9c76fe2a17db86a9bc3ab894210cb"
|
||||||
|
|
Loading…
Reference in New Issue