Skip to content

Commit

Permalink
add sonar cloud
Browse files Browse the repository at this point in the history
  • Loading branch information
Yang committed Jul 4, 2023
1 parent c5c1077 commit c13879d
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
40 changes: 40 additions & 0 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: sonarcloud

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

jobs:

sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: 3.10
- name: Python info
shell: bash -l {0}
run: |
which python3
python3 --version
- name: Install dependencies
run: python3 -m pip install hatch --upgrade
- name: Run unit tests with coverage
run: hatch run coverage
- name: Correct coverage paths
run: sed -i "s+$PWD/++g" coverage.xml
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{secrets.SONAR_TOKEN }}
13 changes: 13 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
sonar.organization=ecoextreml
sonar.projectKey=EcoExtreML_zampy
sonar.host.url=https://sonarcloud.io
sonar.sources=zampy/
sonar.tests=tests/
sonar.links.homepage=https://github.com/EcoExtreML/zampy
sonar.links.scm=https://github.com/EcoExtreML/zampy
sonar.links.issue=https://github.com/EcoExtreML/zampy/issues
sonar.links.ci=https://github.com/EcoExtreML/zampy/actions
sonar.python.coverage.reportPaths=coverage.xml
sonar.python.xunit.reportPath=xunit-result.xml
sonar.python.pylint.reportPaths=pylint-report.txt
sonar.python.version=3.8, 3.9, 3.10
2 changes: 1 addition & 1 deletion tests/test_dataset_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def test_read_properties():
variable_names,
) = dataset_protocol.read_properties_file(dataset_folder)

# Verify the returned values
# Verify the returned values
assert spatial_bounds.north == 54
assert spatial_bounds.east == 6
assert spatial_bounds.south == 51
Expand Down

0 comments on commit c13879d

Please sign in to comment.