From a1342dfbdf6066b43805376f4c47cb727ea19057 Mon Sep 17 00:00:00 2001 From: Juan Ezquerro LLanes Date: Thu, 24 Sep 2026 01:02:56 +0200 Subject: [PATCH] ci: configure SonarQube Cloud coverage and GitHub Actions workflow --- .github/workflows/sonarcloud.yml | 46 ++++++++++++++++++++++++++++++++ .gitignore | 3 +++ .sonarcloud.properties | 6 +++++ pyproject.toml | 17 ++++++++++++ sonar-project.properties | 6 +++++ 5 files changed, 78 insertions(+) create mode 100644 .github/workflows/sonarcloud.yml create mode 100644 .sonarcloud.properties create mode 100644 sonar-project.properties diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml new file mode 100644 index 0000000..213bd3f --- /dev/null +++ b/.github/workflows/sonarcloud.yml @@ -0,0 +1,46 @@ +name: SonarQube Cloud Analysis + +on: + push: + branches: + - main + - master + pull_request: + types: [opened, synchronize, reopened] + +permissions: + contents: read + +jobs: + sonarcloud: + name: SonarQube Cloud Scan + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Install system dependencies + run: | + sudo apt-get update && sudo apt-get install -y libgl1 libegl1 libxkbcommon-x11-0 libasound2-dev + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e .[test] + + - name: Run tests with coverage + run: | + pytest --cov=eloquent_notes --cov-report=xml:coverage.xml --cov-report=term + + - name: SonarQube Cloud Scan + uses: SonarSource/sonarqube-scan-action@v6 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.gitignore b/.gitignore index ed9d7a1..9ec2143 100644 --- a/.gitignore +++ b/.gitignore @@ -157,3 +157,6 @@ build # Code-Reducer Lockfile .code-reducer.lock + +# SonarQube +.scannerwork/ diff --git a/.sonarcloud.properties b/.sonarcloud.properties new file mode 100644 index 0000000..dc59331 --- /dev/null +++ b/.sonarcloud.properties @@ -0,0 +1,6 @@ +sonar.organization=arrase +sonar.projectKey=arrase_eloquent-notes +sonar.sources=eloquent_notes +sonar.tests=tests +sonar.python.version=3.10, 3.11, 3.12, 3.13, 3.14 +sonar.python.coverage.reportPaths=coverage.xml diff --git a/pyproject.toml b/pyproject.toml index 9fa68a9..cde87cb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,9 +26,26 @@ dependencies = [ [project.scripts] eloquent-notes = "eloquent_notes.main:main" +[project.optional-dependencies] +test = [ + "pytest>=8.0.0", + "pytest-cov>=5.0.0", +] + [tool.setuptools.packages.find] where = ["."] include = ["eloquent_notes*"] [tool.setuptools.package-data] eloquent_notes = ["config.yaml", "prompts/*.md", "templates/*.md"] + +[tool.pytest.ini_options] +testpaths = ["tests"] +python_files = ["test_*.py"] + +[tool.coverage.run] +source = ["eloquent_notes"] +relative_files = true + +[tool.coverage.report] +show_missing = true diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..dc59331 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,6 @@ +sonar.organization=arrase +sonar.projectKey=arrase_eloquent-notes +sonar.sources=eloquent_notes +sonar.tests=tests +sonar.python.version=3.10, 3.11, 3.12, 3.13, 3.14 +sonar.python.coverage.reportPaths=coverage.xml