From da4f3c16eb071e250ccd86bc2c69378569f41368 Mon Sep 17 00:00:00 2001 From: Alex Whiteside <1505496+alexw23@users.noreply.github.com> Date: Mon, 16 Jun 2025 11:54:59 +1000 Subject: [PATCH 1/2] Added a HACS button for quicker install path via Google/Github (#1211) --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 71ffa60d..8d01acfc 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,9 @@ [Adaptive Lighting](https://github.com/basnijholt/adaptive-lighting) is a custom component for [Home Assistant](https://www.home-assistant.io/) that intelligently adjusts the brightness and color of your lights 💡 based on the sun's position, while still allowing for manual control. -Download and install directly through [HACS (Home Assistant Community Store)](https://hacs.xyz/) +Download and install directly through [HACS (Home Assistant Community Store)](https://hacs.xyz/): + +[![Open your Home Assistant instance and open the Adaptive Lighting integration inside the Home Assistant Community Store.](https://my.home-assistant.io/badges/hacs_repository.svg)](https://my.home-assistant.io/redirect/hacs_repository/?owner=basnijholt&repository=adaptive-lighting&category=integration) By automatically adapting the settings of your lights throughout the day, Adaptive Lighting helps maintain your natural circadian rhythm 😴, which can lead to improved sleep, mood, and overall well-being. Experience cooler color temperatures at noon, gradually transitioning to warmer colors at sunset and sunrise. From ded439e6f784f05ce4a319f2dc596ae39b85603d Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Sun, 15 Jun 2025 21:31:51 -0700 Subject: [PATCH 2/2] Fix Docker setup and CI installation (#1212) --- .../workflows/install_dependencies/action.yml | 3 + .github/workflows/pytest.yaml | 56 ++++++------------- .github/workflows/update-readme.yml | 2 +- Dockerfile | 13 ++--- scripts/develop | 2 +- scripts/setup-dependencies | 19 ++----- scripts/setup-devcontainer | 1 + tests/README.md | 2 +- 8 files changed, 32 insertions(+), 66 deletions(-) diff --git a/.github/workflows/install_dependencies/action.yml b/.github/workflows/install_dependencies/action.yml index c1f2ddd8..8f1732d6 100644 --- a/.github/workflows/install_dependencies/action.yml +++ b/.github/workflows/install_dependencies/action.yml @@ -31,8 +31,11 @@ runs: uses: actions/setup-python@v5.3.0 with: python-version: ${{ inputs.python-version }} + - name: Set up UV + uses: astral-sh/setup-uv@v6 - name: Install dependencies shell: bash run: | + uv venv --python ${{ inputs.python-version }} ./scripts/setup-dependencies ./scripts/setup-symlinks diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index 098a33af..fb25eff0 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -14,46 +14,22 @@ jobs: fail-fast: false matrix: include: - - python-version: "3.11" - core-version: "2023.7.3" - - python-version: "3.11" - core-version: "2023.8.4" - - python-version: "3.11" - core-version: "2023.9.3" - - python-version: "3.11" - core-version: "2023.10.5" - - python-version: "3.11" - core-version: "2023.11.3" - - python-version: "3.11" - core-version: "2023.12.4" - - python-version: "3.11" - core-version: "2024.1.6" - - python-version: "3.11" - core-version: "2024.2.5" - - python-version: "3.12" - core-version: "2024.3.3" - - python-version: "3.12" - core-version: "2024.4.4" - - python-version: "3.12" - core-version: "2024.5.5" - - python-version: "3.12" - core-version: "2024.6.4" - - python-version: "3.12" - core-version: "2024.7.4" - - python-version: "3.12" - core-version: "2024.8.3" - - python-version: "3.12" - core-version: "2024.9.3" - - python-version: "3.12" - core-version: "2024.10.4" - - python-version: "3.12" - core-version: "2024.11.3" - - python-version: "3.12" - core-version: "2024.12.5" - - python-version: "3.12" - core-version: "2025.1.0b5" - - python-version: "3.13" - core-version: "dev" + - core-version: "2024.12.5" + python-version: "3.12" + - core-version: "2025.1.4" + python-version: "3.12" + - core-version: "2025.2.5" + python-version: "3.13" + - core-version: "2025.3.4" + python-version: "3.13" + - core-version: "2025.4.4" + python-version: "3.13" + - core-version: "2025.5.3" + python-version: "3.13" + - core-version: "2025.6.1" + python-version: "3.13" + - core-version: "dev" + python-version: "3.13" steps: - name: Check out code from GitHub uses: actions/checkout@v4 diff --git a/.github/workflows/update-readme.yml b/.github/workflows/update-readme.yml index 1df50935..a4422130 100644 --- a/.github/workflows/update-readme.yml +++ b/.github/workflows/update-readme.yml @@ -20,7 +20,7 @@ jobs: - name: Install Home Assistant uses: ./.github/workflows/install_dependencies with: - python-version: "3.12" + python-version: "3.13" - name: Install markdown-code-runner and README code dependencies run: | diff --git a/Dockerfile b/Dockerfile index 6e871795..87f791e5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,13 +7,7 @@ # Optionally build the image yourself with: # docker build -t basnijholt/adaptive-lighting:latest . -FROM python:3.13-bookworm - -RUN apt-get update && \ - DEBIAN_FRONTEND=noninteractive apt-get install -y \ - git \ - build-essential libssl-dev libffi-dev python3-dev \ - && rm -rf /var/lib/apt/lists/* +FROM ghcr.io/astral-sh/uv:debian # Clone home-assistant/core RUN git clone --depth 1 --branch dev https://github.com/home-assistant/core.git /core @@ -25,9 +19,12 @@ COPY . /app/ RUN ln -s /core /app/core && /app/scripts/setup-symlinks # Install home-assistant/core dependencies +RUN mkdir -p /venv +ENV UV_PROJECT_ENVIRONMENT=/venv UV_PYTHON=3.13 PATH="/venv/bin:$PATH" +RUN uv venv RUN /app/scripts/setup-dependencies -WORKDIR /core +WORKDIR /app/core # Make 'custom_components/adaptive_lighting' imports available to tests ENV PYTHONPATH="${PYTHONPATH}:/app" diff --git a/scripts/develop b/scripts/develop index e7ce50cd..5382e0fc 100644 --- a/scripts/develop +++ b/scripts/develop @@ -1,6 +1,6 @@ #!/usr/bin/env bash -set -e +set -ex cd "$(dirname "$0")/.." diff --git a/scripts/setup-dependencies b/scripts/setup-dependencies index 9409ac0c..b9e2de1f 100755 --- a/scripts/setup-dependencies +++ b/scripts/setup-dependencies @@ -2,24 +2,13 @@ set -ex cd "$(dirname "$0")/.." -pip install uv -uv venv -source .venv/bin/activate +if grep -q 'mypy-dev==1.14.0a3' core/requirements_test.txt; then + # mypy-dev==1.14.0a3 seems to not be available anymore, HA 2024.12 is affected + sed -i 's/mypy-dev==1.14.0a3/mypy-dev==1.14.0a7/' core/requirements_test.txt +fi uv pip install -r core/requirements.txt - -if grep -q 'codecov' core/requirements_test.txt; then - # Older HA versions still have `codecov` in `requirements_test.txt` - # however it is removed from PyPI, so we cannot install it - sed -i '/codecov/d' core/requirements_test.txt -fi - -if grep -q 'mypy-dev==1.10.0a3' core/requirements_test.txt; then - # mypy-dev==1.10.0a3 seems to not be available anymore, HA 2024.4 and 2024.5 are affected - sed -i 's/mypy-dev==1.10.0a3/mypy-dev==1.10.0b1/' core/requirements_test.txt -fi uv pip install -r core/requirements_test.txt - uv pip install -e core/ uv pip install ulid-transform # this is in Adaptive-lighting's manifest.json uv pip install $(python test_dependencies.py) diff --git a/scripts/setup-devcontainer b/scripts/setup-devcontainer index bdb82534..f16c2cbd 100755 --- a/scripts/setup-devcontainer +++ b/scripts/setup-devcontainer @@ -12,6 +12,7 @@ pip install \ pip \ ruff +uv venv --python 3.13 ./scripts/setup-dependencies ./scripts/setup-symlinks uv run pre-commit install-hooks diff --git a/tests/README.md b/tests/README.md index dd125d97..a5b60839 100644 --- a/tests/README.md +++ b/tests/README.md @@ -20,7 +20,7 @@ This command will download the Docker image from [the adaptive-lighting Docker H If you prefer to build the image yourself, use the following command: ```bash -docker build -t basnijholt/adaptive-lighting:latest --no-cache . +docker build -t basnijholt/adaptive-lighting:latest --no-cache --progress=plain . ``` This might be necessary if the image on Docker Hub is outdated or if the [`test_dependencies.py`](../test_dependencies.py) file is updated.