Skip to content

Commit

Permalink
Merge pull request #443 from GeoDerp/custom_cec
Browse files Browse the repository at this point in the history
feat(SonarQube): add SonarQube to readme
  • Loading branch information
davidusb-geek authored Feb 2, 2025
2 parents f0b8e0d + 00beafe commit 3464b40
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 47 deletions.
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"ms-python.debugpy",
"ms-python.python",
"charliermarsh.ruff",
"SonarSource.sonarlint-vscode"
"SonarSource.sonarlint-vscode",
"redhat.vscode-yaml"
],
"settings": {
"[python]": {
Expand Down
18 changes: 11 additions & 7 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ on:
push:
branches: [master]
pull_request:
branches: [master]
types: [opened, synchronize, reopened]
workflow_dispatch:

jobs:
build:
runs-on: ${{ matrix.os }}
Expand All @@ -21,10 +23,12 @@ jobs:
OS: ${{ matrix.os }}
steps:
- uses: actions/checkout@master

with:
fetch-depth: 0

- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Set up Python
uses: actions/setup-python@v5
with:
Expand All @@ -38,15 +42,15 @@ jobs:

- name: Run Ruff
run: uvx ruff check --output-format=github .

# - name: Type Check with Mypy
# shell: bash
# run: |
# uv run mypy ./src/

- name: SonarQube Scan
uses: SonarSource/sonarqube-scan-action@v4
env:
uses: SonarSource/sonarqube-scan-action@v4.2.1
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
scan-pr:
needs:
Expand All @@ -60,4 +64,4 @@ jobs:
permissions:
security-events: write
contents: read
actions: read
actions: read
2 changes: 1 addition & 1 deletion .github/workflows/codecov.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Generate Report
run: |
uv venv
uv pip install .[test]
uv sync --reinstall --extra test
uv run coverage run -m --source=emhass unittest
uv run coverage report
uv run coverage xml
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.12"]
os: [ubuntu-latest, macos-latest, windows-latest]
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}


steps:
- uses: actions/checkout@v4
- name: Install uv
Expand All @@ -41,10 +39,10 @@ jobs:
if: ${{ matrix.os == 'macos-latest' }}
- name: Install EMHASS with test dependencies
run: |
uv pip install .[test] && uv lock
uv sync --reinstall --extra test
- name: Test with pytest
run: |
uv run pytest
uv run pytest
scan-pr:
needs:
- build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/upload-package-to-pypi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
with:
python-version-file: ".python-version"
- name: Build a binary wheel and a source tarball
run: uv build
run: uv build
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
Expand Down
6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
"automations"
],
"sonarlint.connectedMode.project": {
"connectionId": "geoderp-emhass",
"projectKey": "GeoDerp_emhass"
"connectionId": "emhass",
"projectKey": "davidusb-geek_emhass"
},
"sonarlint.disableTelemetry": true,
"sonarlint.focusOnNewCode": true,
"sonarlint.focusOnNewCode": false,
"sonarlint.analyzerProperties": {},
"mypy-type-checker.reportingScope": "workspace",
"editor.defaultFormatter": "charliermarsh.ruff"
Expand Down
4 changes: 0 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,9 @@ RUN apt-get update \
# add build packadges (just in case wheel does not exist)
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
python3-setuptools \
gcc \
patchelf \
cmake \
meson \
ninja-build

# Install uv (pip alternative)
Expand Down Expand Up @@ -121,11 +119,9 @@ RUN uv lock

# remove build only packages
RUN apt-get remove --purge -y --auto-remove \
python3-setuptools \
gcc \
patchelf \
cmake \
meson \
ninja-build \
&& rm -rf /var/lib/apt/lists/*

Expand Down
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
<a style="text-decoration:none" href="https://github.com/davidusb-geek/emhass/actions">
<img alt="EMHASS GitHub Workflow Status" src="https://github.com/davidusb-geek/emhass/actions/workflows/publish_docker.yaml/badge.svg?event=release">
</a>
<a hstyle="text-decoration:none" ref="https://codecov.io/github/davidusb-geek/emhass" >
<img src="https://codecov.io/github/davidusb-geek/emhass/branch/master/graph/badge.svg?token=BW7KSCHN90"/>
</a>
<a style="text-decoration:none" href="https://github.com/davidusb-geek/emhass/blob/master/LICENSE">
<img alt="GitHub" src="https://img.shields.io/github/license/davidusb-geek/emhass">
</a>
Expand All @@ -28,6 +25,25 @@
<a style="text-decoration:none" href="https://emhass.readthedocs.io/en/latest/">
<img alt="Read the Docs" src="https://img.shields.io/readthedocs/emhass">
</a>
<a hstyle="text-decoration:none" ref="https://codecov.io/github/davidusb-geek/emhass" >
<img src="https://codecov.io/github/davidusb-geek/emhass/branch/master/graph/badge.svg?token=BW7KSCHN90"/>
</a>
<a hstyle="text-decoration:none" ref="https://github.com/davidusb-geek/emhass/actions/workflows/codeql.yml" >
<img src="https://github.com/davidusb-geek/emhass/actions/workflows/codeql.yml/badge.svg?branch=master&event=schedule"/>
</a>
<a style="text-decoration:none" href=https://sonarcloud.io/summary/new_code?id=davidusb-geek_emhass">
<img alt="SonarQube security rating" src="https://sonarcloud.io/api/project_badges/measure?project=davidusb-geek_emhass&metric=security_rating">
</a>
<a style="text-decoration:none" href=https://sonarcloud.io/summary/new_code?id=davidusb-geek_emhass">
<img alt="SonarQube security Vulnerabilities" src="https://sonarcloud.io/api/project_badges/measure?project=davidusb-geek_emhass&metric=vulnerabilities">
</a>
<a style="text-decoration:none" href=https://sonarcloud.io/summary/new_code?id=davidusb-geek_emhass">
<img alt="SonarQube reliability" src="https://sonarcloud.io/api/project_badges/measure?project=davidusb-geek_emhass&metric=reliability_rating">
</a>
<a style="text-decoration:none" href=https://sonarcloud.io/summary/new_code?id=davidusb-geek_emhass">
<img alt="SonarQube bugs" src="https://sonarcloud.io/api/project_badges/measure?project=davidusb-geek_emhass&metric=bugs">
</a>

</p>

<div align="center">
Expand Down
47 changes: 25 additions & 22 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
[build-system]
# These are the assumed default build requirements from pip:
# https://pip.pypa.io/en/stable/reference/pip/#pep-517-and-518-support
requires = ["hatchling"]
requires = ["hatchling>=1.27.0"]
build-backend = "hatchling.build"

[tool.uv.workspace]
members = ["emhass"]

[tool.hatch.build.targets.wheel]
packages = ["src/emhass"]

[project]
name = "emhass"
version = "0.12.4"
description = "An Energy Management System for Home Assistant"
readme = "README.md"
requires-python = ">=3.10, <3.13"
authors = [{ name = "David HERNANDEZ", email = "davidusb@gmail.com" }]
license = { text = "MIT" }
license = "MIT"
keywords = ["energy", "management", "optimization", "hass"]
classifiers = [
"Development Status :: 5 - Production/Stable",
Expand Down Expand Up @@ -46,28 +52,25 @@ docs = ["sphinx", "sphinx-rtd-theme", "myst-parser"]
# can add "mypy"
test = ["requests_mock", "pytest", "coverage", "snakeviz", "ruff", "tabulate", "hatchling"]

[tool.uv.workspace]
members = ["emhass"]

[tool.hatch.build.targets.sdist]
include = [
"/emhass/templates/index.html",
"/emhass/templates/template.html",
"/emhass/templates/configuration.html",
"/emhass/static/advanced.html",
"/emhass/static/basic.html",
"/emhass/static/script.js",
"/emhass/static/configuration_script.js",
"/emhass/static/style.css",
"/emhass/static/configuration_list.html",
"/emhass/static/img/emhass_icon.png",
"/emhass/static/img/emhass_logo_short.svg",
"/emhass/static/img/feather-sprite.svg",
"/emhass/static/data/param_definitions.json",
"/emhass/data/cec_modules.pbz2",
"/emhass/data/cec_inverters.pbz2",
"/emhass/data/associations.csv",
"/emhass/data/config_defaults.json",
"/src/emhass/templates/index.html",
"/src/emhass/templates/template.html",
"/src/emhass/templates/configuration.html",
"/src/emhass/static/advanced.html",
"/src/emhass/static/basic.html",
"/src/emhass/static/script.js",
"/src/emhass/static/configuration_script.js",
"/src/emhass/static/style.css",
"/src/emhass/static/configuration_list.html",
"/src/emhass/static/img/emhass_icon.png",
"/src/emhass/static/img/emhass_logo_short.svg",
"/src/emhass/static/img/feather-sprite.svg",
"/src/emhass/static/data/param_definitions.json",
"/src/emhass/data/cec_modules.pbz2",
"/src/emhass/data/cec_inverters.pbz2",
"/src/emhass/data/associations.csv",
"/src/emhass/data/config_defaults.json"
]

[project.scripts]
Expand Down
4 changes: 4 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sonar.organization=davidusb-geek
sonar.projectKey=davidusb-geek_emhass
sonar.sources=./src
sonar.tests=./tests

0 comments on commit 3464b40

Please sign in to comment.