Skip to content

Commit

Permalink
ci: Move sonarlint analysis to Github action for coverage and remote …
Browse files Browse the repository at this point in the history
…PR support (#737)
  • Loading branch information
gmuloc authored Jul 4, 2024
1 parent b8fbeac commit 2329e8f
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/code-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ jobs:
test-documentation:
name: Build offline documentation for testing
runs-on: ubuntu-20.04
needs: [lint-python, type-python, test-python]
needs: [test-python]
steps:
- uses: actions/checkout@v4
- name: Setup Python
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: Analysis with Sonarlint and publish to SonarCloud
on:
push:
branches:
- main
# Need to do this to be able to have coverage on PR across forks.
pull_request_target:

# TODO this can be made better by running only coverage, it happens that today
# in tox gh-actions we have configured 3.11 to run the report side in
# pyproject.toml

jobs:
sonarcloud:
name: Run Sonarlint analysis and upload to SonarCloud.
runs-on: ubuntu-latest
needs: [test-python]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Install dependencies
run: pip install tox tox-gh-actions
- name: "Run pytest via tox for ${{ matrix.python }}"
run: tox
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
5 changes: 5 additions & 0 deletions .sonarcloud.properties → sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
sonar.projectKey=aristanetworks_anta
sonar.organization=aristanetworks-1

# Path to sources
sonar.sources=anta/,asynceapi/
#sonar.exclusions=
Expand All @@ -16,3 +19,5 @@ sonar.python.version=3.9,3.10,3.11,3.12

# Exclusions for copy-paste detection
#sonar.cpd.exclusions=,

sonar.python.coverage.reportPaths=.coverage.xml

0 comments on commit 2329e8f

Please sign in to comment.