Commit Graph
4 Commits
Author SHA1 Message Date
Bobby NoelteandClaude Opus 5.5 3256bca88e docs(ai): group the tests of one unit in a test class
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: Claude Code (claude-opus-5-5)
2026-11-24 11:52:08 +01:00
57905b2024 ci: run the tests in parallel jobs and speed up the Sphinx build
The single test job ran all tests one after the other on one runner,
including the Sphinx build and the Docker checks (11-19 min). It is now
split so that every test still runs exactly once:

- docs-test, docker-test: the Sphinx build (new marker "docs") and the
  Docker / Home Assistant add-on checks ("docker") in jobs of their own.
- test-server: the tests that start EOS or EOSdash on the fixed ports.
  The collection hook marks every test that uses the xprocess fixture
  with "eos_server" and puts them into one xdist group, so
  "pytest -n auto --dist loadgroup" also works locally. A test that
  binds the ports without a fixture carries the marker itself.
- test-shard: all other tests in four shards of about equal runtime
  (scripts/shard_test_files.py, runtimes in scripts/test_durations.json),
  each with pytest-xdist.
- test-count: fails if these parts do not add up to the tests of one
  plain run.
- test: keeps the name of the required check. It prints the combined
  coverage report and fails if any of the jobs above failed.

COVERAGE_CORE=sysmon measures line coverage through sys.monitoring:
the report is the same, the test time drops by about a third. The
combined report misses 1-3 statements more than a single run, in lines
that only run when a test finds state left by an earlier test.

The Sphinx build spent 74 % of its time in one search of
PythonDomain.find_obj (sphinx-doc/sphinx#11282). The local extension
docs/_ext/pyxrefindex.py answers it from an index of name endings with
the same matches in the same order; a build has a byte-identical
objects.inv. It copies the logic of Sphinx 9.0.4 and is only active for
that version; TestPyXrefIndex compares it with the installed Sphinx and
fails after a Sphinx update until the version is raised. The
documentation test builds with -j (up to four jobs); its pages can
differ from a serial build in the target of ambiguous cross-references.
Read the Docs builds without -j. Sphinx build on GitHub runners:
427-480 s -> 180-233 s.

make test-ci runs the commands of these jobs one after the other.

On GitHub runners the tests are done after about 2 minutes; the
required check ends with docs-test after about 4-5 minutes.

Additional changes
Add pytest-xdist to the development dependencies
List the 25 slowest tests in each test job (--durations=25)
Test version() directly; it was covered only through the Sphinx test
Add a "Keep Tests Fast" tip, the server marker rule, the extension and
test-ci to the development guide and the testing skill

Refs #1553

Co-authored-by: SchaafAlexander <86607129+SchaafAlexander@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: SchaafAlexander <86607129+SchaafAlexander@users.noreply.github.com>
Assisted-by: Claude Code (claude-opus-5-5)
Assisted-by: Claude Code (claude-fable-5-2)
2026-11-20 07:15:33 +01:00
e2726354c2 test: make slow and order-dependent tests fast and independent
Slow tests:
- TestPerformance inserted 10 000 records three times per backend. One
  test per backend now times insert, save and load on the same records,
  with the same assertions.
- test_measurement_realtime_stream slept one second per update, 20 s per
  backend. The updates use synthetic timestamps one second apart in the
  recent past, without a pause, and send the same duplicates,
  out-of-order and burst writes.
- test_readers_never_see_a_partial_document: the readers spun on the
  cache and kept the writer waiting for the GIL (~50 s). They now yield
  with time.sleep(0) after each lookup (~0.5 s); a non-atomic save still
  fails the test 10 of 10 times.
- test_devicessettingsbattery.py compiled the same plain profile before
  each of its 235 tests. A module-scoped fixture compiles it once; a
  compiled profile is frozen and may be shared (20.8 s -> 9.4 s).
- The --finalize case of test_geneticoptimize.py runs 250 instead of
  400 generations. For this input and seed the best fitness is final in
  generation 213, and the solutions after 250 and 400 generations are
  identical field by field. The test checks the keys and the consistency
  of the result, not the schedule, so it detects the same as before
  (127 s -> 80 s on GitHub runners). test_genetic0optimize.py keeps 400.

Tests that depended on another test of the same process, found by
running them in another order and under pytest-xdist:
- TestPredictionContainer::test_len relied on a class flag that a
  TestPredictionProvider fixture set and never reset. Both fixtures now
  set the flags with monkeypatch.
- The EnergyCharts status code test got a cached response from an
  earlier test; it now calls _request_forecast(force_update=True) and
  asserts that the request was made.
- test_ingress_safe_links did not wait for EOSdash, which EOS starts
  after its own startup.
- test_forward_stream_truncates_very_long_line found the log queue left
  behind by test_server_start_eosdash (no worker, closed event loop). It
  installs its own queue now, and test_server_start_eosdash no longer
  leaves its queue behind. Dropping lines from a full queue was only
  covered through that left-over queue and gets a test of its own.

Refs #1553

Co-authored-by: SchaafAlexander <86607129+SchaafAlexander@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: SchaafAlexander <86607129+SchaafAlexander@users.noreply.github.com>
Assisted-by: Claude Code (claude-opus-5-5)
Assisted-by: Claude Code (claude-fable-5-2)
2026-11-20 07:15:33 +01:00
2245976de4 docs(ai): move agent rules to ai/skills and add an AI development sandbox (#1498)
The sandbox provides an isolated Docker environment for AI-assisted development
(OpenCode + Claude Code + Qwen Code) against the local AkkudoktorEOS repository.

The sandbox does not protect the repository from harmful changes by the agent.
It limits what a misled agent can reach on the machine, but the agent can still
write any change into the repository.

Primary security defence is to check every change before it is run on the host.
Same holds for opening a pull request or updating one.

Additional changes

- Reduce AGENTS.md to the project summary, baseline rules, completion checklist,
  and an index of the skills.
- Add skills for the Python environment and REST API error responses.
- Add the development guide page docs/develop/ai.md: the AI coding
  workflow, how agents get the project rules from AGENTS.md and ai/skills,
  and how to use the sandbox (start, agent logins, project commands with a
  virtual environment outside the workspace, running EOS and EOSdash,
  GitHub access, persistent data, security model).
- Add a checklist for reviewing agent changes before pushing, starting with
  .git, which stays writable in the sandbox.
- Check out all text files with LF line endings (.gitattributes), also on
  Windows with core.autocrlf, so the sandbox scripts run in the container
  and git in the container agrees with git on the host. Batch files keep CRLF.
- Publish the ports of ai/compose.yaml on request (AI_SANDBOX_PORTS=1).
  docker compose run publishes them only with --service-ports. Off by
  default, so that several sandboxes can run in parallel.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 09:15:12 +01:00