Skip to content

Commit

Permalink
Merge pull request #2463 from cta-observatory/sonarqube_src
Browse files Browse the repository at this point in the history
Add configuration for using CTAO sonarqube to check code
  • Loading branch information
kosack authored Mar 25, 2024
2 parents 3e29788 + c3cb18b commit f3e9239
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ env:
MPLBACKEND: Agg
PYTEST_ADDOPTS: --color=yes
GITHUB_PR_NUMBER: ${{ github.event.number }}
SONAR_HOST_URL: https://sonar-cta-dpps.zeuthen.desy.de

jobs:
lint:
Expand Down Expand Up @@ -133,15 +134,20 @@ jobs:
- name: Tests
if: contains(github.event.pull_request.labels.*.name, 'documentation-only') == false
run: |
cd $(mktemp -d)
pytest -n auto --dist loadscope \
--cov --cov-report=xml:$GITHUB_WORKSPACE/coverage.xml \
--cov --cov-report=xml \
--doctest-modules --doctest-glob='*.rst' \
--ignore=$GITHUB_WORKSPACE/docs/conf.py \
--pyargs ctapipe $GITHUB_WORKSPACE/docs
--ignore=docs/conf.py \
src/ctapipe docs
ctapipe-info --version
# check code quality and coverage with SonarScanner
- uses: SonarSource/sonarqube-scan-action@v2
if: contains(matrix.extra-args, 'codecov') && contains(github.event.pull_request.labels.*.name, 'documentation-only') == false
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

- uses: codecov/codecov-action@v4
if: contains(matrix.extra-args, 'codecov') && contains(github.event.pull_request.labels.*.name, 'documentation-only') == false
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ __pycache__

# ignore version cache file (generated automatically when setup.py is run)
ctapipe/_version_cache.py
ctapipe/_version.py
src/ctapipe/_version.py


Expand Down
1 change: 1 addition & 0 deletions docs/changes/2214.maintenance.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The CI system now reports to the CTA SonarQube instance for code quality tracking
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ norecursedirs = [
"build",
]

[tool.coverage.run]
include = ["src/*"]
relative_files = true

[tool.towncrier]
package = "ctapipe"
directory = "docs/changes"
Expand Down
5 changes: 5 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sonar.projectKey=ctapipe_github_9404f0f6-9294-11ed-bf3b-07aa00bdfe94
sonar.qualitygate.wait=true
sonar.language=python
sonar.python.coverage.reportPaths=coverage.xml
sonar.python.version=3.9

0 comments on commit f3e9239

Please sign in to comment.