2023-03-26 18:18:18 -07:00
|
|
|
# See tests/README.md for instructions on how to run the tests.
|
|
|
|
|
|
|
|
|
|
# tl;dr:
|
2026-01-11 21:57:52 +01:00
|
|
|
# 1. Clone HA core into ./core: git clone --depth 1 https://github.com/home-assistant/core.git core
|
|
|
|
|
# 2. Setup symlinks: ./scripts/setup-symlinks
|
|
|
|
|
# 3. Run tests (mount entire repo, not individual dirs, or symlinks break):
|
|
|
|
|
# docker run -v $(pwd):/app basnijholt/adaptive-lighting:latest
|
2023-03-26 18:18:18 -07:00
|
|
|
|
|
|
|
|
# Optionally build the image yourself with:
|
|
|
|
|
# docker build -t basnijholt/adaptive-lighting:latest .
|
|
|
|
|
|
2025-06-15 21:31:51 -07:00
|
|
|
FROM ghcr.io/astral-sh/uv:debian
|
2023-03-26 18:18:18 -07:00
|
|
|
|
2025-11-27 09:06:41 -08:00
|
|
|
# Install build dependencies for Python extensions
|
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
|
|
|
python3-dev \
|
|
|
|
|
build-essential \
|
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
2023-03-26 18:18:18 -07:00
|
|
|
# Clone home-assistant/core
|
2024-04-06 11:25:47 +02:00
|
|
|
RUN git clone --depth 1 --branch dev https://github.com/home-assistant/core.git /core
|
2023-03-26 18:18:18 -07:00
|
|
|
|
2023-06-12 00:33:07 +02:00
|
|
|
# Copy the Adaptive Lighting repository
|
|
|
|
|
COPY . /app/
|
2023-03-26 18:18:18 -07:00
|
|
|
|
|
|
|
|
# Setup symlinks in core
|
2024-04-07 14:01:05 +02:00
|
|
|
RUN ln -s /core /app/core && /app/scripts/setup-symlinks
|
2023-03-26 18:18:18 -07:00
|
|
|
|
2024-04-06 11:25:47 +02:00
|
|
|
# Install home-assistant/core dependencies
|
2025-06-15 22:33:35 -07:00
|
|
|
RUN mkdir -p /.venv
|
2026-04-24 11:31:53 -07:00
|
|
|
ENV UV_PROJECT_ENVIRONMENT=/.venv UV_PYTHON=3.14.2 PATH="/.venv/bin:$PATH"
|
2025-06-15 21:31:51 -07:00
|
|
|
RUN uv venv
|
2025-06-15 22:28:12 -07:00
|
|
|
RUN /app/scripts/setup-dependencies
|
2023-03-26 18:18:18 -07:00
|
|
|
|
2025-06-15 21:31:51 -07:00
|
|
|
WORKDIR /app/core
|
2023-03-26 18:18:18 -07:00
|
|
|
|
2023-06-12 00:33:07 +02:00
|
|
|
# Make 'custom_components/adaptive_lighting' imports available to tests
|
2026-01-19 10:03:40 -07:00
|
|
|
ENV PYTHONPATH="/app"
|
2023-06-12 00:33:07 +02:00
|
|
|
|
2023-03-26 22:07:07 -07:00
|
|
|
ENTRYPOINT ["python3", \
|
2023-03-26 18:18:18 -07:00
|
|
|
# Enable Python development mode
|
|
|
|
|
"-X", "dev", \
|
|
|
|
|
# Run pytest
|
|
|
|
|
"-m", "pytest", \
|
|
|
|
|
# Verbose output
|
|
|
|
|
"-vvv", \
|
|
|
|
|
# Set a timeout of 9 seconds per test
|
|
|
|
|
"--timeout=9", \
|
|
|
|
|
# Print the 10 slowest tests
|
|
|
|
|
"--durations=10", \
|
2026-01-19 10:03:20 -07:00
|
|
|
# Measure code coverage for the 'homeassistant.components.adaptive_lighting' component
|
|
|
|
|
"--cov=homeassistant.components.adaptive_lighting", \
|
2023-03-26 18:18:18 -07:00
|
|
|
# Generate an XML report of the code coverage
|
|
|
|
|
"--cov-report=xml", \
|
2023-03-26 21:37:21 -07:00
|
|
|
# Generate an HTML report of the code coverage
|
|
|
|
|
"--cov-report=html", \
|
|
|
|
|
# Print a summary of the code coverage in the console
|
|
|
|
|
"--cov-report=term", \
|
|
|
|
|
# Print logs in color
|
|
|
|
|
"--color=yes", \
|
2023-03-26 18:18:18 -07:00
|
|
|
# Print a count of test results in the console
|
2023-03-26 22:07:07 -07:00
|
|
|
"-o", "console_output_style=count"]
|
|
|
|
|
|
|
|
|
|
# Run tests in the 'tests/components/adaptive_lighting' directory
|
|
|
|
|
CMD ["tests/components/adaptive_lighting"]
|