Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Tests

on:
push:
branches: [main]
pull_request:

permissions:
contents: read

jobs:
pytest:
runs-on: ubuntu-24.04
timeout-minutes: 15
steps:
- uses: actions/checkout@v7

- uses: actions/setup-python@v7
with:
python-version: "3.12"
cache: pip
cache-dependency-path: requirements-test.lock

- name: Install test dependencies
run: make test-install

- name: Run pytest
timeout-minutes: 5
run: python -m pytest tests/ -n 4
19 changes: 18 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
.PHONY: test dev dev-stop dev-logs dev-restart
SHELL := /bin/bash
.SHELLFLAGS := -eu -o pipefail -c

.PHONY: test test-v test-install test-lock-regen dev stop logs restart

# --- Tests ---

SDIST_ONLY := fnvhash,mock-open,paho-mqtt,pyric

test-install:
awk '/^setuptools==/{f=1} f && $$0 !~ /^setuptools==/ && /^[A-Za-z0-9_.-]+==/{exit} f{print} \
END{if (!f) { print "setuptools not found in requirements-test.lock" > "/dev/stderr"; exit 1 }}' \
requirements-test.lock | pip install --require-hashes -r /dev/stdin
pip install --require-hashes --no-build-isolation --only-binary :all: --no-binary $(SDIST_ONLY) -r requirements-test.lock

test-lock-regen:
pip install -q uv==0.5.8
uv pip compile --universal --python-version 3.12 --generate-hashes \
--custom-compile-command "make test-lock-regen" \
requirements-test.txt -o requirements-test.lock

test:
python3 -m pytest tests/ -q

Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,13 @@ make stop # stop the container
### Running tests

```bash
pip install pytest pytest-asyncio pytest-timeout awsiotsdk
make test-install
python3 -m pytest tests/ -v
```

Tests are isolated from Home Assistant - no HA installation required to run them.
`requirements-test.txt` is the human-edited top-level list. `requirements-test.lock` is
the fully pinned, hash-checked lock that CI, the Makefile and this install step all use.
Regenerate it after changing `requirements-test.txt` with `make test-lock-regen`.

### Verifying the MQTT outage-reconnect fix

Expand Down
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
asyncio_mode = auto
asyncio_default_fixture_loop_scope = function
timeout = 30
timeout_method = thread
required_plugins = pytest-timeout
Loading
Loading