VS Code Dev Container (dev & test environment) (#605)

* build: dev container

Add a VS Code Dev Container from the blueprint at bceaae212f

* build: dev container test setup

Add support for unit testing in the dev container environment with debugging and code coverage.

* ci: adjust to dev container test restructuring

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* ci: fix coverage collection

* build: add dummy light to HA config

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* build: update dev container to Python 3.11 (for HA 2023.6)

* Add VS Code tasks

* Use pre-commit hooks for linting

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Unpin HA version

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Bas Nijholt <basnijholt@gmail.com>
This commit is contained in:
Mario Guggenberger 2023-06-12 00:33:07 +02:00 • committed by GitHub
commit 6283158ff7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 329 additions and 111 deletions

View file

@ -23,12 +23,11 @@ RUN pip3 install -r /core/requirements.txt --use-pep517 && \
pip3 install -r /core/requirements_test.txt --use-pep517 && \
pip3 install -e /core/ --use-pep517
# Clone the Adaptive Lighting repository
RUN git clone https://github.com/basnijholt/adaptive-lighting.git /app
# Copy the Adaptive Lighting repository
COPY . /app/
# Setup symlinks in core
RUN ln -s /app/custom_components/adaptive_lighting /core/homeassistant/components/adaptive_lighting && \
ln -s /app/tests /core/tests/components/adaptive_lighting && \
RUN ln -s /app/tests /core/tests/components/adaptive_lighting && \
# For test_dependencies.py
ln -s /core /app/core
@ -37,6 +36,11 @@ RUN pip3 install $(python3 /app/test_dependencies.py) --use-pep517
WORKDIR /core
# Make 'custom_components/adaptive_lighting' imports available to tests
ENV PYTHONPATH="${PYTHONPATH}:/app"
# Enable testing against HA clone (instead of pytest_homeassistant_custom_component)
ENV HA_CLONE=true
ENTRYPOINT ["python3", \
# Enable Python development mode
"-X", "dev", \
@ -49,7 +53,7 @@ ENTRYPOINT ["python3", \
# Print the 10 slowest tests
"--durations=10", \
# Measure code coverage for the 'homeassistant' package
"--cov='homeassistant'", \
"--cov=custom_components.adaptive_lighting", \
# Generate an XML report of the code coverage
"--cov-report=xml", \
# Generate an HTML report of the code coverage