Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure sonarcloud #67

Merged
merged 1 commit into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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