From b8d7f0239f4a48dfc407ed12ffdf01913dec37a4 Mon Sep 17 00:00:00 2001
From: GeoDerp <18461782+GeoDerp@users.noreply.github.com>
Date: Sat, 1 Feb 2025 23:57:33 +0000
Subject: [PATCH 1/9] feat(SonarQube): add SonarQube to readme
---
.devcontainer/devcontainer.json | 3 ++-
.vscode/settings.json | 4 ++--
README.md | 22 +++++++++++++++++++---
3 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
index 621fff42..c40475d3 100644
--- a/.devcontainer/devcontainer.json
+++ b/.devcontainer/devcontainer.json
@@ -35,7 +35,8 @@
"ms-python.debugpy",
"ms-python.python",
"charliermarsh.ruff",
- "SonarSource.sonarlint-vscode"
+ "SonarSource.sonarlint-vscode",
+ "redhat.vscode-yaml"
],
"settings": {
"[python]": {
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 0385c022..2a43e909 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -15,8 +15,8 @@
"automations"
],
"sonarlint.connectedMode.project": {
- "connectionId": "geoderp-emhass",
- "projectKey": "GeoDerp_emhass"
+ "connectionId": "emhass",
+ "projectKey": "davidusb-geek_emhass",
},
"sonarlint.disableTelemetry": true,
"sonarlint.focusOnNewCode": true,
diff --git a/README.md b/README.md
index 311b9254..4123e23b 100644
--- a/README.md
+++ b/README.md
@@ -13,9 +13,6 @@
-
-
-
@@ -28,6 +25,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From d12eebaecd92cb776460c5956cbccc4c5d6e3e3c Mon Sep 17 00:00:00 2001
From: GeoDerp <18461782+GeoDerp@users.noreply.github.com>
Date: Sun, 2 Feb 2025 03:09:16 +0000
Subject: [PATCH 2/9] fix(actions): slight tweak actions
---
.github/workflows/code-quality.yml | 14 ++++++++------
.github/workflows/codecov.yaml | 2 +-
.github/workflows/python-test.yml | 8 +++-----
.github/workflows/upload-package-to-pypi.yaml | 2 +-
4 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml
index 3927f735..dca09079 100644
--- a/.github/workflows/code-quality.yml
+++ b/.github/workflows/code-quality.yml
@@ -6,6 +6,8 @@ on:
branches: [master]
pull_request:
branches: [master]
+ workflow_dispatch:
+
jobs:
build:
runs-on: ${{ matrix.os }}
@@ -21,10 +23,10 @@ jobs:
OS: ${{ matrix.os }}
steps:
- uses: actions/checkout@master
-
+
- name: Install uv
uses: astral-sh/setup-uv@v5
-
+
- name: Set up Python
uses: actions/setup-python@v5
with:
@@ -38,15 +40,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:
@@ -60,4 +62,4 @@ jobs:
permissions:
security-events: write
contents: read
- actions: read
\ No newline at end of file
+ actions: read
diff --git a/.github/workflows/codecov.yaml b/.github/workflows/codecov.yaml
index a173016f..e6163fc8 100644
--- a/.github/workflows/codecov.yaml
+++ b/.github/workflows/codecov.yaml
@@ -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
diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml
index 21cb7a4e..5c406f6b 100644
--- a/.github/workflows/python-test.yml
+++ b/.github/workflows/python-test.yml
@@ -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
@@ -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
diff --git a/.github/workflows/upload-package-to-pypi.yaml b/.github/workflows/upload-package-to-pypi.yaml
index 0f026444..3d7c4e2e 100644
--- a/.github/workflows/upload-package-to-pypi.yaml
+++ b/.github/workflows/upload-package-to-pypi.yaml
@@ -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:
From f34717fe574a6461ccb4fcf5310a57b30cd16fb0 Mon Sep 17 00:00:00 2001
From: GeoDerp <18461782+GeoDerp@users.noreply.github.com>
Date: Sun, 2 Feb 2025 03:15:13 +0000
Subject: [PATCH 3/9] fix(pytoml): adjust package scope
---
pyproject.toml | 47 +++++++++++++++++++++++++----------------------
1 file changed, 25 insertions(+), 22 deletions(-)
diff --git a/pyproject.toml b/pyproject.toml
index 9432c648..63e3e33d 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,9 +1,15 @@
[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"
@@ -11,7 +17,7 @@ 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",
@@ -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]
From 42305ff4f41bd30b1699728a1f3eca4520c1bf28 Mon Sep 17 00:00:00 2001
From: GeoDerp <18461782+GeoDerp@users.noreply.github.com>
Date: Sun, 2 Feb 2025 03:32:55 +0000
Subject: [PATCH 4/9] test(SonarQube): add scope for sonar
---
.vscode/settings.json | 4 ++--
sonar-project.properties | 3 +++
2 files changed, 5 insertions(+), 2 deletions(-)
create mode 100644 sonar-project.properties
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 2a43e909..f0190007 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -16,10 +16,10 @@
],
"sonarlint.connectedMode.project": {
"connectionId": "emhass",
- "projectKey": "davidusb-geek_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"
diff --git a/sonar-project.properties b/sonar-project.properties
new file mode 100644
index 00000000..1a7a7bb6
--- /dev/null
+++ b/sonar-project.properties
@@ -0,0 +1,3 @@
+sonar.projectKey=davidusb-geek_emhass
+sonar.sources=./src
+sonar.tests=./tests
\ No newline at end of file
From 559d66a12574afe984703a7d324809e9eb385de7 Mon Sep 17 00:00:00 2001
From: GeoDerp <18461782+GeoDerp@users.noreply.github.com>
Date: Sun, 2 Feb 2025 03:42:53 +0000
Subject: [PATCH 5/9] test(Dockerfile-build): try and remove meson build
package
---
Dockerfile | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/Dockerfile b/Dockerfile
index e958a384..80346b4b 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -54,11 +54,11 @@ 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 \
+ # python3-setuptools \
gcc \
patchelf \
cmake \
- meson \
+ # meson \
ninja-build
# Install uv (pip alternative)
@@ -121,11 +121,11 @@ RUN uv lock
# remove build only packages
RUN apt-get remove --purge -y --auto-remove \
- python3-setuptools \
+ # python3-setuptools \
gcc \
patchelf \
cmake \
- meson \
+ # meson \
ninja-build \
&& rm -rf /var/lib/apt/lists/*
From f1d8855207e5349c821a50a1bf8663a1db67a5e9 Mon Sep 17 00:00:00 2001
From: GeoDerp <18461782+GeoDerp@users.noreply.github.com>
Date: Sun, 2 Feb 2025 03:51:15 +0000
Subject: [PATCH 6/9] test(Dockerfile-build): rm meson build package
---
Dockerfile | 4 ----
1 file changed, 4 deletions(-)
diff --git a/Dockerfile b/Dockerfile
index 80346b4b..b80a208d 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -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)
@@ -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/*
From f97891a5a14621e05880ff617d22087d49bd33da Mon Sep 17 00:00:00 2001
From: GeoDerp <18461782+GeoDerp@users.noreply.github.com>
Date: Sun, 2 Feb 2025 07:02:46 +0000
Subject: [PATCH 7/9] test(actions): change pull request type on code-quality
workflow
---
.github/workflows/code-quality.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml
index dca09079..59777503 100644
--- a/.github/workflows/code-quality.yml
+++ b/.github/workflows/code-quality.yml
@@ -5,7 +5,7 @@ on:
push:
branches: [master]
pull_request:
- branches: [master]
+ types: [opened, synchronize, reopened]
workflow_dispatch:
jobs:
From 18bb858455196ff178b013b3f668055fe55549df Mon Sep 17 00:00:00 2001
From: GeoDerp <18461782+GeoDerp@users.noreply.github.com>
Date: Sun, 2 Feb 2025 07:04:53 +0000
Subject: [PATCH 8/9] feat(SonarQube): add organization id to properties
---
sonar-project.properties | 1 +
1 file changed, 1 insertion(+)
diff --git a/sonar-project.properties b/sonar-project.properties
index 1a7a7bb6..0f5023a7 100644
--- a/sonar-project.properties
+++ b/sonar-project.properties
@@ -1,3 +1,4 @@
+sonar.organization=davidusb-geek
sonar.projectKey=davidusb-geek_emhass
sonar.sources=./src
sonar.tests=./tests
\ No newline at end of file
From 00beafe2eec12bf93f808c55771417f49472113a Mon Sep 17 00:00:00 2001
From: GeoDerp <18461782+GeoDerp@users.noreply.github.com>
Date: Sun, 2 Feb 2025 10:36:03 +0000
Subject: [PATCH 9/9] test(actions): add fetch-depth to code-quality action
---
.github/workflows/code-quality.yml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml
index 59777503..662e07ff 100644
--- a/.github/workflows/code-quality.yml
+++ b/.github/workflows/code-quality.yml
@@ -23,6 +23,8 @@ jobs:
OS: ${{ matrix.os }}
steps:
- uses: actions/checkout@master
+ with:
+ fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v5