Skip to content

Commit c0766e9

Browse files
committed
Try get sucessful test
1 parent 984fe89 commit c0766e9

6 files changed

Lines changed: 63 additions & 15 deletions

File tree

.github/workflows/coverage.yml

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ permissions:
1010
jobs:
1111
test:
1212
runs-on: ubuntu-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
include:
17+
- ha: "2025.12"
18+
constraints: constraints-ha2025.txt
19+
- ha: "2026.1"
20+
constraints: constraints-ha2026.txt
1321
steps:
1422
- uses: actions/checkout@v4
1523
with:
@@ -18,28 +26,41 @@ jobs:
1826
- name: Set up Python
1927
uses: actions/setup-python@v5
2028
with:
21-
python-version: "3.13"
29+
python-version: "3.13.11"
2230
cache: "pip"
2331
cache-dependency-path: |
2432
requirements.test.txt
33+
constraints-ha2025.txt
34+
constraints-ha2026.txt
2535
2636
- name: Install test dependencies
2737
run: |
2838
python -m pip install --upgrade pip
29-
pip install -r requirements.test.txt
3039
31-
- name: Run tests with coverage
40+
python -c "import json; print('\\n'.join(json.load(open('custom_components/redsea/manifest.json'))['requirements']))" > /tmp/manifest_requirements.txt
41+
pip install -r /tmp/manifest_requirements.txt -c ${{ matrix.constraints }}
42+
pip install -r requirements.test.txt -c ${{ matrix.constraints }}
43+
44+
- name: Run tests with coverage (HA ${{ matrix.ha }})
45+
if: matrix.ha == '2026.1'
3246
run: |
3347
pytest -q \
3448
--cov=custom_components \
3549
--cov-report=term-missing \
3650
--cov-report=xml:coverage.xml
3751
52+
- name: Run tests (HA ${{ matrix.ha }})
53+
if: matrix.ha != '2026.1'
54+
run: |
55+
pytest -q
56+
3857
- name: Generate coverage badge (repo-local)
58+
if: matrix.ha == '2026.1'
3959
run: |
4060
python -m coverage_badge -o badges/coverage.svg -f
4161
4262
- name: Upload coverage.xml to Codecov
63+
if: matrix.ha == '2026.1'
4364
uses: codecov/codecov-action@v4
4465
with:
4566
files: coverage.xml
@@ -48,7 +69,7 @@ jobs:
4869
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
4970

5071
- name: Commit updated badge
51-
if: github.event_name == 'push' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
72+
if: matrix.ha == '2026.1' && github.event_name == 'push' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
5273
run: |
5374
if git diff --quiet -- badges/coverage.svg; then
5475
echo "No badge changes"

README_TESTS.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,34 @@ These tests are intended for `pytest-homeassistant-custom-component`.
55
## Install test deps
66

77
Typical:
8+
89
- pytest
910
- pytest-asyncio
1011
- pytest-homeassistant-custom-component
1112

13+
This repo supports two Home Assistant targets via constraints (while `requirements.test.txt` provides minimum versions).
14+
15+
Note: some dependencies are **runtime requirements of the integration** (declared in `custom_components/redsea/manifest.json`).
16+
Home Assistant installs these automatically; for local test runs we install them explicitly.
17+
18+
- **Default (minimums)**: install with lower bounds (pip may choose newer):
19+
20+
- `pip install -r requirements.test.txt`
21+
- `python -c "import json; print('\\n'.join(json.load(open('custom_components/redsea/manifest.json'))['requirements']))" | pip install -r /dev/stdin`
22+
- **2025.x compatibility** ("anything 2025 should work"):
23+
24+
- `python -c "import json; print('\\n'.join(json.load(open('custom_components/redsea/manifest.json'))['requirements']))" | pip install -r /dev/stdin -c constraints-ha2025.txt`
25+
- `pip install -r requirements.test.txt -c constraints-ha2025.txt`
26+
- **2026.1.x / production**:
27+
28+
- `python -c "import json; print('\\n'.join(json.load(open('custom_components/redsea/manifest.json'))['requirements']))" | pip install -r /dev/stdin -c constraints-ha2026.txt`
29+
- `pip install -r requirements.test.txt -c constraints-ha2026.txt`
30+
1231
## Run
1332

1433
pytest -q
1534

1635
## Notes
36+
1737
- Network is disabled by monkeypatching `ReefBeatAPI.fetch_data()` to load captured fixture payloads.
1838
- Fixtures included under `tests/fixtures/`.

constraints-ha2025.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# CI/local testing constraints for "any 2025.x should work".
2+
# This PHACC release pins Home Assistant 2025.12.4.
3+
pytest-homeassistant-custom-component==0.13.301

constraints-ha2026.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# CI/local testing constraints for "latest/production".
2+
# This PHACC release pins Home Assistant 2026.1.2.
3+
pytest-homeassistant-custom-component==0.13.307

custom_components/redsea/manifest.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
"documentation": "https://github.com/Elwinmage/ha-reefbeat-component",
88
"iot_class": "local_polling",
99
"issue_tracker": "https://github.com/Elwinmage/ha-reefbeat-component/issues",
10-
"requirements": ["jsonpath-ng>=1.7.0"],
10+
"requirements": [
11+
"jsonpath-ng>=1.7.0",
12+
"lxml>=6.0.2",
13+
"netifaces>=0.11.0",
14+
"numpy>=2.3.2"
15+
],
1116
"version": "1.4.0"
1217
}

requirements.test.txt

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
pytest
2-
pytest-cov
3-
pytest-asyncio
4-
pytest-homeassistant-custom-component
5-
coverage-badge
6-
jsonpath-ng>=1.7.0
7-
numpy>=2.3.5
8-
dotenv
9-
lxml
10-
netifaces
1+
pytest>=9.0.0
2+
pytest-cov>=7.0.0
3+
pytest-asyncio>=1.3.0
4+
pytest-homeassistant-custom-component>=0.13.301
5+
coverage-badge>=1.1.2
6+
dotenv>=0.9.9

0 commit comments

Comments
 (0)