Skip to content

Commit 57c2f98

Browse files
authored
Merge branch 'main' into brad5505-patch-2
2 parents 1b833d8 + d8855b4 commit 57c2f98

120 files changed

Lines changed: 37394 additions & 20368 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Enforce LF line endings for all text files
2+
# This prevents accidental conversion to CRLF
3+
* text=auto eol=lf
4+
5+
# Explicitly handle common file types
6+
*.py text
7+
*.yaml text
8+
*.yml text
9+
*.json text
10+
*.md text
11+
*.txt text
12+
*.sh text
13+
*.zsh text
14+
15+
# Binary files should not be modified
16+
*.png binary
17+
*.jpg binary
18+
*.jpeg binary
19+
*.gif binary
20+
*.ico binary
21+
*.pdf binary

.github/workflows/black.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

.github/workflows/ci-cd.yml

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
name: CI/CD Integrated
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- "**"
8+
pull_request:
9+
schedule:
10+
- cron: "0 0 * * *"
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
quality:
18+
name: Code Quality
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v5
26+
27+
- name: Install dependencies
28+
run: uv sync --all-groups
29+
30+
- name: Run pre-commit checks
31+
run: uv run pre-commit run --all-files --show-diff-on-failure
32+
33+
mypy:
34+
name: Type Check (mypy)
35+
needs: [quality]
36+
runs-on: ubuntu-latest
37+
steps:
38+
- name: Checkout code
39+
uses: actions/checkout@v4
40+
41+
- name: Install uv
42+
uses: astral-sh/setup-uv@v5
43+
with:
44+
python-version: "3.12"
45+
46+
- name: Install dependencies
47+
run: uv sync --all-groups
48+
49+
- name: Run mypy type checking
50+
run: |
51+
echo "Running mypy in strict mode..."
52+
uv run mypy custom_components/solax_modbus tests --strict
53+
54+
hacs:
55+
name: HACS Validation
56+
needs: [quality]
57+
runs-on: ubuntu-latest
58+
steps:
59+
- name: Checkout code
60+
uses: actions/checkout@v4
61+
- name: HACS Action
62+
uses: hacs/action@main
63+
with:
64+
category: integration
65+
66+
hassfest:
67+
name: Hassfest Validation
68+
needs: [quality]
69+
runs-on: ubuntu-latest
70+
steps:
71+
- name: Checkout code
72+
uses: actions/checkout@v4
73+
- name: Hassfest Action
74+
uses: home-assistant/actions/hassfest@master
75+
76+
test-quick:
77+
name: Test Quick
78+
needs: [mypy]
79+
if: github.event_name == 'push' && github.ref != 'refs/heads/main'
80+
runs-on: ubuntu-latest
81+
strategy:
82+
matrix:
83+
python-version: ["3.12"]
84+
steps:
85+
- name: Checkout code
86+
uses: actions/checkout@v4
87+
88+
- name: Install uv
89+
uses: astral-sh/setup-uv@v5
90+
with:
91+
python-version: ${{ matrix.python-version }}
92+
93+
- name: Install dependencies
94+
run: uv sync --all-groups
95+
96+
- name: Run Quick Tests
97+
run: uv run pytest -m "not slow"
98+
99+
test-comprehensive:
100+
name: Test Comprehensive
101+
needs: [mypy]
102+
if: github.event_name == 'pull_request' || github.event_name == 'schedule' || (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch'
103+
runs-on: ubuntu-latest
104+
strategy:
105+
matrix:
106+
python-version: ["3.12", "3.13"]
107+
steps:
108+
- name: Checkout code
109+
uses: actions/checkout@v4
110+
111+
- name: Install uv
112+
uses: astral-sh/setup-uv@v5
113+
with:
114+
python-version: ${{ matrix.python-version }}
115+
116+
- name: Install dependencies
117+
run: uv sync --all-groups
118+
119+
- name: Run Full Tests
120+
run: uv run pytest
121+
122+
all-checks-passed:
123+
name: ✅ All Checks Passed
124+
if: always()
125+
needs: [hacs, hassfest, test-quick, test-comprehensive]
126+
runs-on: ubuntu-latest
127+
steps:
128+
- name: Check all results
129+
run: |
130+
HACS="${{ needs.hacs.result }}"
131+
HASSFEST="${{ needs.hassfest.result }}"
132+
QUICK="${{ needs.test-quick.result }}"
133+
COMPREHENSIVE="${{ needs.test-comprehensive.result }}"
134+
135+
echo "HACS: $HACS"
136+
echo "Hassfest: $HASSFEST"
137+
echo "Quick Tests: $QUICK"
138+
echo "Comprehensive Tests: $COMPREHENSIVE"
139+
140+
# 1. Static Analysis must pass
141+
if [[ "$HACS" != "success" ]]; then
142+
echo "❌ HACS validation failed"
143+
exit 1
144+
fi
145+
if [[ "$HASSFEST" != "success" ]]; then
146+
echo "❌ Hassfest validation failed"
147+
exit 1
148+
fi
149+
150+
# 2. Tests: One path must succeed
151+
if [[ "$COMPREHENSIVE" == "success" ]]; then
152+
echo "✅ Comprehensive tests passed"
153+
exit 0
154+
elif [[ "$QUICK" == "success" && "$COMPREHENSIVE" == "skipped" ]]; then
155+
echo "✅ Quick tests passed"
156+
exit 0
157+
elif [[ "$QUICK" == "skipped" && "$COMPREHENSIVE" == "skipped" ]]; then
158+
echo "⚠️ No tests ran?"
159+
exit 1
160+
else
161+
echo "❌ Tests failed or cancelled"
162+
exit 1
163+
fi

.github/workflows/hacs.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

.github/workflows/hassfest.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
.DS_Store
33
__pycache__
44
*.html
5+
.venv
6+
mypy-txt-report/

.pre-commit-config.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: local
5+
hooks:
6+
- id: codespell
7+
name: codespell
8+
entry: uv run codespell
9+
language: system
10+
types: [text]
11+
exclude_types: [csv, json]
12+
# Exclude translation files except English (en.json)
13+
exclude: ^custom_components/solax_modbus/translations/(?!en\.json).+
14+
15+
- id: mypy
16+
name: mypy type checking
17+
entry: uv run mypy
18+
language: system
19+
types: [python]
20+
pass_filenames: false
21+
args: ["custom_components/solax_modbus", "tests"]
22+
verbose: true
23+
24+
- repo: https://github.com/astral-sh/ruff-pre-commit
25+
rev: v0.14.14
26+
hooks:
27+
- id: ruff
28+
args: [ --fix ]
29+
- id: ruff-format

0 commit comments

Comments
 (0)