Stash initial SonarQube work
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
14
.codecov.yml
14
.codecov.yml
@@ -1,14 +0,0 @@
|
||||
comment: off
|
||||
|
||||
coverage:
|
||||
status:
|
||||
project:
|
||||
default:
|
||||
target: 0 # Target % coverage, can be auto. Turned off for now
|
||||
threshold: null
|
||||
base: auto
|
||||
patch:
|
||||
default:
|
||||
target: 0
|
||||
threshold: null
|
||||
base: auto
|
||||
@@ -1,8 +1,8 @@
|
||||
[run]
|
||||
branch = True
|
||||
parallel = True
|
||||
include=$TOP/synapse/*
|
||||
data_file = $TOP/.coverage
|
||||
include=synapse/*
|
||||
data_file = .coverage
|
||||
|
||||
[report]
|
||||
precision = 2
|
||||
|
||||
37
.github/workflows/sonarqube.yml
vendored
Normal file
37
.github/workflows/sonarqube.yml
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
name: SonarQube
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: [ "Tests" ]
|
||||
types:
|
||||
- completed
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.workflow_run.head_branch }}
|
||||
cancel-in-progress: true
|
||||
jobs:
|
||||
prdetails:
|
||||
name: PR Details
|
||||
if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request'
|
||||
uses: matrix-org/matrix-js-sdk/.github/workflows/pr_details.yml@develop
|
||||
with:
|
||||
owner: ${{ github.event.workflow_run.head_repository.owner.login }}
|
||||
branch: ${{ github.event.workflow_run.head_branch }}
|
||||
|
||||
sonarqube:
|
||||
name: 🩻 SonarQube
|
||||
needs: prdetails
|
||||
# Only wait for prdetails if it isn't skipped
|
||||
if: |
|
||||
always() &&
|
||||
(needs.prdetails.result == 'success' || needs.prdetails.result == 'skipped') &&
|
||||
github.event.workflow_run.conclusion == 'success'
|
||||
uses: matrix-org/matrix-js-sdk/.github/workflows/sonarcloud.yml@develop
|
||||
with:
|
||||
repo: ${{ github.event.workflow_run.head_repository.full_name }}
|
||||
pr_id: ${{ needs.prdetails.outputs.pr_id }}
|
||||
head_branch: ${{ needs.prdetails.outputs.head_branch || github.event.workflow_run.head_branch }}
|
||||
base_branch: ${{ needs.prdetails.outputs.base_branch }}
|
||||
revision: ${{ github.event.workflow_run.head_sha }}
|
||||
coverage_workflow_name: tests.yml
|
||||
coverage_run_id: ${{ github.event.workflow_run.id }}
|
||||
secrets:
|
||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||
35
.github/workflows/tests.yml
vendored
35
.github/workflows/tests.yml
vendored
@@ -93,11 +93,13 @@ jobs:
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
extras: ${{ matrix.extras }}
|
||||
- name: Install Coverage.py
|
||||
run: pip install coverage
|
||||
- name: Await PostgreSQL
|
||||
if: ${{ matrix.postgres-version }}
|
||||
timeout-minutes: 2
|
||||
run: until pg_isready -h localhost; do sleep 1; done
|
||||
- run: poetry run trial --jobs=2 tests
|
||||
- run: coverage run --branch --source=synapse poetry run trial --jobs=2 tests
|
||||
env:
|
||||
SYNAPSE_POSTGRES: ${{ matrix.database == 'postgres' || '' }}
|
||||
SYNAPSE_POSTGRES_HOST: localhost
|
||||
@@ -115,6 +117,12 @@ jobs:
|
||||
-exec cat {} \;
|
||||
-exec echo "::endgroup::" \;
|
||||
|| true
|
||||
- name: Upload coverage
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: coverage-${{ matrix.postgres-version }}-${{ matrix.database }}-${{ matrix.postgres-version }}
|
||||
path: .coverage*
|
||||
retention-days: 1
|
||||
|
||||
trial-olddeps:
|
||||
# Note: sqlite only; no postgres
|
||||
@@ -360,7 +368,29 @@ jobs:
|
||||
shell: bash
|
||||
name: Run Complement Tests
|
||||
|
||||
# a job which marks all the other jobs as complete, thus allowing PRs to be merged.
|
||||
# a job which combines the coverage reports from all trials runs, ready for upload to SonarQube.
|
||||
coverage:
|
||||
needs: trial
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
path: .
|
||||
- name: Install Coverage.py
|
||||
run: pip install coverage
|
||||
- name: Combine coverage reports
|
||||
run: coverage combine
|
||||
- name: Write coverage to XML
|
||||
run: coverage xml -i -o coverage/coverage.xml
|
||||
- name: Upload combined coverage
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: coverage-combined
|
||||
path: coverage
|
||||
retention-days: 1
|
||||
|
||||
# a job which marks all the other jobs as complete, thus allowing PRs to be merged.
|
||||
tests-done:
|
||||
if: ${{ always() }}
|
||||
needs:
|
||||
@@ -374,6 +404,7 @@ jobs:
|
||||
- export-data
|
||||
- portdb
|
||||
- complement
|
||||
- coverage
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: matrix-org/done-action@v2
|
||||
|
||||
15
sonar-project.properties
Normal file
15
sonar-project.properties
Normal file
@@ -0,0 +1,15 @@
|
||||
sonar.projectKey=matrix-org_synapse
|
||||
sonar.organization=matrix-org
|
||||
|
||||
# Encoding of the source code. Default is default system encoding
|
||||
#sonar.sourceEncoding=UTF-8
|
||||
|
||||
sonar.sources=synapse
|
||||
sonar.tests=tests
|
||||
sonar.exclusions=changelog.d,debian,demo,docker,docs
|
||||
|
||||
sonar.coverage.exclusions=tests/**/*
|
||||
|
||||
sonar.python.coverage.reportPaths=coverage/coverage.xml
|
||||
sonar.python.version=3.10
|
||||
|
||||
Reference in New Issue
Block a user