Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version: "2"
exclude_patterns:
- "custom_components/oig_cloud/www/**"
- "custom_components/oig_cloud/lib/**"
- "custom_components/oig_cloud/oig_cloud_battery_forecast.py"
4 changes: 4 additions & 0 deletions .codefactor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
exclude_patterns:
- "custom_components/oig_cloud/www/**"
- "custom_components/oig_cloud/lib/**"
- "custom_components/oig_cloud/oig_cloud_battery_forecast.py"
8 changes: 8 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[run]
source = custom_components/oig_cloud
relative_files = True

[report]
skip_covered = True
show_missing = False

21 changes: 21 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"env": {
"browser": true,
"es2021": true
},
"parserOptions": {
"ecmaVersion": 2021,
"sourceType": "script"
},
"rules": {
"eqeqeq": "off",
"max-depth": "off",
"max-lines-per-function": "off",
"max-params": "off",
"no-alert": "off",
"no-undef": "off",
"no-unused-vars": "off",
"no-var": "off",
"prefer-const": "off"
}
}
23 changes: 23 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[flake8]
max-line-length = 88
max-complexity = 100
extend-ignore = E203,E501
exclude =
.git,
__pycache__,
.venv,
venv,
.mypy_cache,
.pytest_cache,
.ruff_cache,
.dev_docs,
.ha-env,
.ha-env-313,
.ha-env-*,
.pyenv,
local_dev,
node_modules,
tests,
htmlcov,
build,
dist
2 changes: 0 additions & 2 deletions .github/copilot-instructions.md

This file was deleted.

5 changes: 4 additions & 1 deletion .github/workflows/hacs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ on:
schedule:
- cron: "0 0 * * *"

permissions:
contents: read

jobs:
hacs:
name: HACS Action
runs-on: "ubuntu-latest"
steps:
- name: HACS Action
uses: "hacs/action@main"
uses: "hacs/action@6f81caf1dd4cc0f615444dba4d4a3ceaa22db99c"
with:
category: "integration"
5 changes: 4 additions & 1 deletion .github/workflows/hassfest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ on:
schedule:
- cron: '0 0 * * *'

permissions:
contents: read

jobs:
validate:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v4"
- uses: "home-assistant/actions/hassfest@master"
- uses: "home-assistant/actions/hassfest@87c064c607f3c5cc673a24258d0c98d23033bfc3"
46 changes: 46 additions & 0 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Quality Checks

on:
push:
branches:
- main
- temp-into-main
pull_request:

jobs:
python-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt

- name: Run flake8
run: |
python -m flake8

frontend-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "22"

- name: Install frontend dependencies
run: npm ci

- name: Run frontend lint
run: npm test
63 changes: 54 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ on:
required: true
default: 'false'

permissions:
contents: write

jobs:
release:
runs-on: ubuntu-latest
Expand All @@ -19,6 +22,16 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Validate version input
id: validate_version
run: |
VERSION="${{ github.event.inputs.version }}"
if [ "$VERSION" != "dev" ] && ! [[ "$VERSION" =~ ^[0-9]+(\.[0-9]+)*(-[0-9A-Za-z.-]+)?$ ]]; then
echo "Invalid version: $VERSION"
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"

- name: Set up Node.js
uses: actions/setup-node@v4
with:
Expand All @@ -27,8 +40,9 @@ jobs:
- name: Replace version and service in release_const.py
working-directory: ./custom_components/oig_cloud
run: |
echo 'COMPONENT_VERSION = "${{ github.event.inputs.version }}"' > release_const.py
if [ "${{ github.event.inputs.version }}" == "dev" ]; then
VERSION="${{ steps.validate_version.outputs.version }}"
echo "COMPONENT_VERSION = \"$VERSION\"" > release_const.py
if [ "$VERSION" == "dev" ]; then
echo 'SERVICE_NAME = "oig_cloud_dev"' >> release_const.py
else
echo 'SERVICE_NAME = "oig_cloud"' >> release_const.py
Expand All @@ -37,10 +51,11 @@ jobs:
- name: Update version property in manifest.json
working-directory: ./custom_components/oig_cloud
run: |
if [ "${{ github.event.inputs.version }}" == "dev" ]; then
VERSION="${{ steps.validate_version.outputs.version }}"
if [ "$VERSION" == "dev" ]; then
jq --arg version '0.0.0' '.version = $version' manifest.json > manifest.tmp && mv manifest.tmp manifest.json
else
jq --arg version ${{ github.event.inputs.version }} '.version = $version' manifest.json > manifest.tmp && mv manifest.tmp manifest.json
jq --arg version "$VERSION" '.version = $version' manifest.json > manifest.tmp && mv manifest.tmp manifest.json
fi


Expand All @@ -50,7 +65,7 @@ jobs:
git config --global user.name "Pavel Simsa"
git config --global user.email "pavel@simsa.cz"
git add release_const.py manifest.json
git commit -m "Setting release variables to ${{ github.event.inputs.version }}"
git commit -m "Setting release variables to ${{ steps.validate_version.outputs.version }}"

- name: Push changes
working-directory: ./custom_components/oig_cloud
Expand All @@ -62,16 +77,46 @@ jobs:
if: ${{ github.event.inputs.create-tag == 'true' }}
working-directory: ./custom_components/oig_cloud
run: |
git tag -a v${{ github.event.inputs.version }} -m "Version ${{ github.event.inputs.version }}"
git tag -a v${{ steps.validate_version.outputs.version }} -m "Version ${{ steps.validate_version.outputs.version }}"
git push --tags

- name: Extract release notes from CHANGELOG.md
id: changelog
if: ${{ github.event.inputs.create-tag == 'true' }}
run: |
VERSION="${{ steps.validate_version.outputs.version }}"
if [ ! -f CHANGELOG.md ]; then
{
echo "notes<<EOF"
echo "Release ${VERSION}"
echo "EOF"
} >> "$GITHUB_OUTPUT"
exit 0
fi

NOTES="$(awk -v ver="$VERSION" '
$0 ~ "^## \\[" ver "\\]" { in_section=1 }
in_section && $0 ~ "^## \\[" && $0 !~ "^## \\[" ver "\\]" { exit }
in_section { print }
' CHANGELOG.md)"

if [ -z "$NOTES" ]; then
NOTES="Release ${VERSION}"
fi

{
echo "notes<<EOF"
echo "$NOTES"
echo "EOF"
} >> "$GITHUB_OUTPUT"

- name: Create draft release
uses: actions/create-release@v1
if: ${{ github.event.inputs.create-tag == 'true' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ github.event.inputs.version }}
release_name: Release ${{ github.event.inputs.version }}
tag_name: v${{ steps.validate_version.outputs.version }}
release_name: Release ${{ steps.validate_version.outputs.version }}
body: ${{ steps.changelog.outputs.notes }}
draft: true

65 changes: 37 additions & 28 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,49 @@ on:
pull_request:
branches:
- main
- temp
push:
branches:
- main
- temp

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
restore-keys: |
${{ runner.os }}-pip-

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-dev.txt || true

- name: Set PYTHONPATH
run: echo "PYTHONPATH=$(pwd)" >> $GITHUB_ENV

- name: Run tests
run: |
pytest
- name: Checkout repository
uses: actions/checkout@v4

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
restore-keys: |
${{ runner.os }}-pip-

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt

- name: Run tests (with coverage)
env:
PYTHONPATH: ${{ github.workspace }}
run: |
pytest -v --tb=short --cov=custom_components/oig_cloud --cov-report=xml --cov-report=term-missing:skip-covered

- name: Upload coverage artifact
uses: actions/upload-artifact@v4
with:
name: coverage-xml
path: coverage.xml
Loading