Skip to content

Commit

Permalink
Configure sonarcloud
Browse files Browse the repository at this point in the history
  • Loading branch information
robinbobbitt authored and goneri committed Aug 14, 2023
1 parent 7d7154d commit ee17b41
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
20 changes: 18 additions & 2 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
name: Python package

on:
- push
- pull_request
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]

jobs:
build:
Expand All @@ -13,6 +16,8 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
Expand All @@ -23,3 +28,14 @@ jobs:
python -m pip install tox tox-gh-actions
- name: Test with tox
run: tox
# See https://sonarsource.atlassian.net/browse/SONARPY-1203
- name: Fix paths in coverage file
run: |
sed -i 's/\/home\/runner\/work\/anonymizer\/anonymizer/\/github\/workspace\//g' coverage.xml
- name: SonarCloud scan
# skip sonarcloud scan from PRs from a fork
if: matrix.python-version == 3.11 && !(github.event.pull_request && github.event.pull_request.head.repo.fork)
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
9 changes: 9 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
sonar.projectKey=ansible_anonymizer
sonar.organization=ansible

sonar.sources = ansible_anonymizer/
sonar.tests = tests/

sonar.python.version=3.11

sonar.python.coverage.reportPaths=coverage.xml
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ deps =
pytest-cov
commands =
pip install -U pip
pytest --cov --cov-append --cov-report=term-missing --cov-fail-under=95 {posargs:tests}
pytest --cov --cov-append --cov-report=term-missing --cov-report=xml:coverage.xml --cov-fail-under=95 {posargs:tests}
depends =
{py311}: clean
report: py311
Expand Down

0 comments on commit ee17b41

Please sign in to comment.