Validation and release automation
Adaptive Lighting uses local scripts and GitHub Actions to validate the Home Assistant integration across supported Core versions, keep generated text in sync with source definitions, build the simulator documentation site, and publish release artifacts. The system joins code checks with release steps so that a change is checked in the same environments in which users receive it.
Validation system
The validation system checks four different risks: Python quality, Home Assistant integration rules, behavior across Home Assistant Core versions, and package metadata. Pull requests and pushes to the project branches run the checks that protect those contracts.
Python quality checks
Python quality checks run through the repository's pre-commit configuration. The scripts/lint command gives developers one entry point that applies the same basic file checks and Python format and lint rules used by the pre-commit workflow (scripts/lint#L1-L7, .pre-commit-config.yaml• L1-18).
The shared checks cover:
- Basic file hygiene such as trailing spaces, end-of-file form, line endings, and large files.
- Ruff linting with automatic fixes.
- Black formatting.
The workflow runs these checks on pull requests and on pushes to master. It does not define a separate project-specific check set (.github/…/pre-commit.yaml• L1-14).
References: scripts/lint• L1-7 .pre-commit-config.yaml• L1-18 .github/…/pre-commit.yaml• L1-14
Home Assistant checks
Home Assistant checks confirm that the integration follows the host project's metadata and structure rules. HACS validation treats the project as an integration, while Hassfest checks it against Home Assistant's integration validation rules (.github/…/validate.yml• L1-18, .github/…/hassfest.yaml• L1-15).
Both checks run for pull requests and pushes to master. They also run on a daily schedule, which catches changes in the external validation services even when the repository has not changed.
References: .github/…/validate.yml• L1-18 .github/…/hassfest.yaml• L1-15 hacs.json• L1-5 custom_components/…/manifest.json• L1-12
Integration test suite
The test suite runs inside a checkout of Home Assistant Core rather than as a separate package. The repository links its integration and tests into the matching Core paths, then runs the integration tests through Core's pytest setup (scripts/setup-symlinks#L1-L13, .github/…/action.yml• L16-41).
The tests cover the main product contracts:
- Integration setup, config entries, import, options, and unload behavior.
- Sun event and time-zone calculations.
- Brightness and color adaptation, including service-call splitting, redundant-attribute filtering, and transition preservation.
- Switch behavior, sleep mode, manual control, service calls, transitions, and supported light groups.
- Interception of
light.turn_oncalls.
The color and brightness tests also protect unusual solar conditions and brightness ranges. They cover inverted brightness limits, polar night, midnight sun, southern-hemisphere behavior, and the order of derived sun events (tests/test_color_and_brightness.py• L285-549).
The switch tests protect the boundary between adaptive changes and user changes. They check that manual-control state and events stay current during direct service calls, profile sharing, reloads, expiry, sleep-mode changes, and non-Home-Assistant state changes. They also check that queued adaptations and transition timers do not overwrite preserved user state (tests/test_switch.py• L912-1121, tests/test_switch.py• L1278-1618, tests/test_switch.py• L1690-1926).
The suite is run with development-mode Python, a per-test timeout, slow-test reporting, and coverage for the Home Assistant integration component (tests/test_init.py• L15-55, tests/test_config_flow.py• L20-249, tests/test_color_and_brightness.py• L39-209, tests/test_switch.py• L396-527, .github/…/pytest.yaml• L55-75). The adaptation utility tests also protect the rules that split brightness and color commands, remove values that already match light state, classify light-control attributes, and preserve transition timing (tests/test_adaptation_utils.py• L304-603).
The test harness uses template lights and mocks one unrelated Home Assistant deprecation issue. This keeps the fixture environment focused on Adaptive Lighting behavior (tests/conftest.py• L8-26, tests/test_switch.py• L205-287).
References: tests/conftest.py• L8-26 tests/test_init.py• L15-55 tests/test_config_flow.py• L20-249 tests/test_color_and_brightness.py• L39-209 tests/test_color_and_brightness.py• L285-549 tests/test_switch.py• L912-1121 tests/test_switch.py• L1278-1618 tests/test_switch.py• L1690-1926 tests/test_adaptation_utils.py• L304-603 .github/…/pytest.yaml• L8-78 .github/…/action.yml• L16-41 scripts/setup-symlinks• L1-13
Home Assistant version matrix
The pytest workflow tests the newest patch release for each supported Home Assistant Core month from 2025.9 through 2026.9. It also tests the Core development branch. The matrix uses Python 3.13 through Core 2026.2 and Python 3.14.2 from Core 2026.3 onward, so it checks both the integration contract and the runtime used by each Core line (.github/…/pytest.yaml• L13-44).
The scripts/update-test-matrix.py script fetches Core tags from GitHub, keeps stable releases from the explicit 2025.9 floor, selects the newest patch per monthly release, maps each release to its Python version, and adds the development entry. The scheduled Update Test Matrix workflow runs this script weekly or on demand. When the matrix changes, it opens an automated pull request instead of changing the branch without review (scripts/update-test-matrix.py• L18-102, .github/…/update-test-matrix.yaml• L1-59).
The dependency setup follows the Core version selected by the matrix. It checks out that Core version, creates the requested Python environment, installs the required packages, and links the integration into Core before pytest runs (.github/…/action.yml• L16-41, scripts/setup-dependencies#L5-L49, test_dependencies.py• L1-48).
References: .github/…/pytest.yaml• L13-78 scripts/update-test-matrix.py• L18-148 .github/…/update-test-matrix.yaml• L1-59 .github/…/action.yml• L16-41 scripts/setup-dependencies• L5-49 test_dependencies.py• L1-48
Developer workflow
Developer scripts provide the local paths that match CI. A developer can start Home Assistant against the local integration, run the pre-commit checks, refresh generated content, or use the Docker test image without learning the CI command details (scripts/develop#L1-L20, scripts/lint#L1-L7, tests/README.md• L1-52).
Local Home Assistant environment
The scripts/develop command creates a local Home Assistant configuration when needed, exposes the repository's custom component path, and starts Home Assistant in debug mode. This gives developers a running host for manual checks while keeping the integration in its repository layout (scripts/develop#L7-L20).
For tests, the repository can use either a local Core checkout with symlinks or the published Docker image. The Docker image contains a Core development checkout and prepares the same links and dependencies before its entry point runs pytest (tests/README.md• L6-42, Dockerfile#L1-L65).
References: scripts/develop• L1-20 tests/README.md• L6-52 Dockerfile• L1-65
Generated-content pipeline
Generated content keeps user-facing documentation and Home Assistant metadata aligned with the integration's source definitions. The update command installs the documentation dependencies, installs the project in editable form, runs Markdown code blocks, and then regenerates service and translation data (scripts/update-generated-content#L1-L11).
The pipeline has three linked outputs:
- Markdown tables and examples are rendered from code or shared README sections.
- services.yaml receives field descriptions from the integration's documentation constants.
- strings.json and English translations receive option and service text from the same definitions.
The Markdown runner scans docs/ and the root README for CODE:START markers. It runs each marked file and reports failure if any generated block cannot be updated (docs/run_markdown_code_runner.py• L15-67).
The markdown-code-runner workflow checks the pull request's source revision before it runs the update command. A pull request fails when the update command changes tracked files, so contributors must regenerate and commit the result. On pushes to main, the workflow commits and pushes detected updates (.github/…/markdown-code-runner.yml• L13-48).
This pipeline matters because the generated service and translation files are also part of Home Assistant validation. A source change can therefore pass local code checks but still fail validation if its generated metadata is stale (.github/update-services.py• L12-27, .github/update-strings.py• L14-70, scripts/setup-dependencies#L27-L37).
References: scripts/update-generated-content• L1-11 docs/run_markdown_code_runner.py• L15-67 .github/update-services.py• L1-27 .github/update-strings.py• L1-70 .github/…/markdown-code-runner.yml• L1-48 custom_components/…/services.yaml• L1
Documentation and simulator publishing
The documentation workflow builds the Zensical site and exports the simulator web app as a static site. It uses a fixed Python environment with uv-managed documentation dependencies, places the simulator under the documentation site's /simulator/ path, and publishes the combined site to GitHub Pages (.github/…/docs.yml• L18-64).
The workflow builds on pushes to main, pull requests, and manual dispatch. Only a non-pull-request run on main deploys the built artifact. This lets pull requests prove that the docs and simulator build without publishing preview output (.github/…/docs.yml• L3-7, .github/…/docs.yml• L49-64).
The wider branch and delivery model is described in Adaptive Lighting development and delivery. The simulator itself is described in Color and brightness preview app.
The table of contents workflow updates README contents after pushes to main. A separate main-to-master workflow mirrors main to master, which keeps the branch used by validation workflows aligned with the branch used for documentation and release activity (.github/…/toc.yaml• L1-12, .github/…/main-to-master-sync.yml• L1-22).
References: .github/…/docs.yml• L1-64 .github/…/toc.yaml• L1-12 .github/…/main-to-master-sync.yml• L1-22 docs/index.md• L1-85
Release configuration
Release automation collects merged pull request changes into a draft release on main. Pull request events use dry-run mode, while pushes can update the draft. The draft format contains a change list and a comparison link to the prior tag (.github/…/release-drafter.yml• L1-24, .github/release-drafter.yml• L1-6).
The integration publishes its package identity through pyproject.toml and Home Assistant metadata through manifest.json. The Python project declares version 1.30.1, while the integration manifest declares version 1.32.0; these are separate release-facing values and should not be treated as one shared version source (pyproject.toml• L5-11, custom_components/…/manifest.json• L1-12). HACS identifies the project as an integration and requires Home Assistant 2024.12.0 or newer (hacs.json• L1-5).
The Docker workflow builds a multi-platform image for pull requests, pushes to main, version tags, and manual runs. Pull requests build without pushing. Non-pull-request runs can publish to GitHub Container Registry with branch, semantic-version, and default-branch latest tags (.github/…/docker-build.yml• L3-8, .github/…/docker-build.yml• L32-50).
References: .github/…/release-drafter.yml• L1-24 .github/release-drafter.yml• L1-6 pyproject.toml• L5-34 custom_components/…/manifest.json• L1-12 hacs.json• L1-5 .github/…/docker-build.yml• L1-50
Change checklist
When these files or sections are changed, remember to consider these:
- When changing option or service descriptions in the integration source, run
./scripts/update-generated-contentand review services.yaml, strings.json, translations/en.json, and generated Markdown together. - When changing the minimum Home Assistant version, update the HACS requirement and the test-matrix lower bound. Check the Python mapping for affected Core releases.
- When changing test setup or Home Assistant compatibility workarounds, review both the local Docker path and .github/…/action.yml because CI uses the composite action rather than the Docker image.
- When changing docs or simulator inputs, verify both the Zensical build and the
shinylive exportstep. The simulator is copied into the final Pages artifact rather than deployed as a separate site. - When changing release identity or package metadata, compare pyproject.toml, manifest.json, HACS metadata, and Docker semantic-version tags. They serve different consumers.
- When changing branch triggers, check the
maindocumentation and release workflows against themastervalidation workflows and the synchronization workflow.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A source description changes without running the generated-content command | Markdown, service metadata, or translations remain stale. Pull requests fail the generated-content check or Home Assistant validation sees old text. | Run ./scripts/update-generated-content and inspect the generated files before push (.github/…/markdown-code-runner.yml• L28-45). |
| A new Home Assistant Core release changes its requirement layout | Dependency setup can miss packages or use the wrong compatibility path. The matrix job can fail before pytest starts. | Keep the Core-version fallback logic in scripts/setup-dependencies and test_dependencies.py aligned with Core's requirement files (scripts/setup-dependencies#L5-L25, test_dependencies.py• L9-45). |
| A supported Core minor is added without the correct Python mapping | The integration is tested with a runtime that does not match that Core release. | Run scripts/update-test-matrix.py; review its stable-release floor and Python mapping (scripts/update-test-matrix.py• L18-89). |
| A pull request passes tests but the docs or simulator build fails | The code may merge without a publishable documentation artifact. | The documentation workflow builds both Zensical output and the exported simulator on pull requests (.github/…/docs.yml• L18-47). |
| A pull request changes generated files indirectly | The generated-content workflow reports a dirty work tree and blocks the pull request. | Commit the output produced by ./scripts/update-generated-content; do not hand-edit generated blocks (.github/…/markdown-code-runner.yml• L31-45). |
| A release uses an inconsistent version source | HACS, Home Assistant, Python packaging, and Docker tags can show different release identities. | Treat manifest.json, pyproject.toml, hacs.json, and Docker metadata as separate release contracts (custom_components/…/manifest.json• L1-12, pyproject.toml• L5-11, hacs.json• L1-5, .github/…/docker-build.yml• L32-47). |
Key files
| File | Why to read it |
|---|---|
| .github/…/pytest.yaml | Defines the Home Assistant Core and Python test matrix and the CI pytest command. |
| .github/…/action.yml | Shows how CI prepares the integration beside a selected Core checkout. |
scripts/setup-dependencies | Explains dependency installation and compatibility steps for different Core layouts. |
| scripts/update-test-matrix.py | Defines how supported Core releases become test-matrix entries. |
| tests/test_adaptation_utils.py | Shows the service-call and attribute rules that the adaptation utility tests protect. |
| tests/test_color_and_brightness.py | Covers time-aware brightness and color behavior across normal and extreme solar conditions. |
| tests/test_switch.py | Gives the broadest view of adaptation, switches, services, manual-control state, shared profiles, reloads, expiry, transitions, and light groups under test. |
| .github/…/markdown-code-runner.yml | Enforces and, on main, updates generated documentation and metadata. |
scripts/update-generated-content | Provides the local command for refreshing all generated outputs. |
| docs/run_markdown_code_runner.py | Defines which Markdown files are discovered and how generated blocks are refreshed. |
| .github/update-services.py | Connects service metadata to the integration's shared documentation text. |
| .github/update-strings.py | Connects config and service translations to the same source definitions. |
| .github/…/docs.yml | Builds and publishes the documentation site with the simulator. |
| .github/…/release-drafter.yml | Maintains the draft release from changes on main. |
| .github/release-drafter.yml | Defines the draft release body and change comparison link. |
| .github/…/docker-build.yml | Builds and publishes the multi-platform test image and tagged release image. |
| custom_components/…/manifest.json | Defines Home Assistant and HACS-facing integration metadata. |
| pyproject.toml | Defines Python package metadata and the local test, docs, lint, and format tool settings. |