Skip to content

Commit

Permalink
Merge remote-tracking branch 'blueprint/dev' into dev
Browse files Browse the repository at this point in the history
# Conflicts:
#	README_EXAMPLE.md
#	custom_components/integration_blueprint/const.py
#	custom_components/integration_blueprint/manifest.json
#	hacs.json
  • Loading branch information
Limych committed May 9, 2024
2 parents a8cdf3c + 3ba3282 commit 658cab5
Show file tree
Hide file tree
Showing 40 changed files with 316 additions and 198 deletions.
16 changes: 10 additions & 6 deletions .devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ludeeus/integration_blueprint",
"image": "mcr.microsoft.com/vscode/devcontainers/python:0-3.10-bullseye",
"image": "mcr.microsoft.com/devcontainers/python:1-3.12",
"postCreateCommand": "scripts/setup",
"forwardPorts": [
8123
Expand All @@ -17,17 +17,21 @@
"ms-python.python",
"github.vscode-pull-request-github",
"ryanluker.vscode-coverage-gutters",
"ms-python.vscode-pylance"
"ms-python.vscode-pylance",
"ms-python.black-formatter",
"ms-python.pylint"
],
"settings": {
"files.eol": "\n",
"editor.tabSize": 4,
"python.pythonPath": "/usr/bin/python3",
"python.analysis.autoSearchPaths": false,
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"python.formatting.provider": "black",
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
},
"black-formatter.path": [
"/usr/local/py-utils/bin/black"
],
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,
Expand Down
16 changes: 16 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
ARG BUILD_FROM BUILD_FROM_TAG
FROM python:3.11-slim

ENV DEVCONTAINER=true

COPY ./container /container
COPY ./install /install

ARG OS_VARIANT CONTAINER_TYPE
RUN \
bash /install/init.sh \
&& bash /install/container.sh \
&& bash /install/integration.sh \
&& bash /install/cleanup.sh

CMD ["bash"]
3 changes: 3 additions & 0 deletions .devcontainer/container/container
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

make --file /opt/container/container.mk "${*:-"help"}"
12 changes: 12 additions & 0 deletions .devcontainer/container/container.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
MAKEFLAGS += --no-print-directory
SELF_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
.DEFAULT_GOAL := help

include /opt/container/makefiles/*.mk

help: ## Show help
@printf " \033[1m%s\033[0m\n %s\033[32m\033[0m\n %s\033[32m\033[0m \n\n" "container" "Custom CLI used in this container" "https://github.com/ludeeus/container";
@printf " \033[1m%s\033[0m\n %s\033[32m\033[0m \n\n" "usage:" "container [command]";
@printf " \033[1m%s\033[0m\n" "where [command] is one of:";
@awk 'BEGIN {FS = ":.*##";} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m container %-25s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST);
@echo
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

hass -c /config --script check_config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

read -p 'Set Home Assistant version: ' -r version
python3 -m pip --disable-pip-version-check install --upgrade homeassistant=="$version"

if [[ -n "$POST_SET_VERSION_HOOK" ]]; then
"$POST_SET_VERSION_HOOK" "$version"
fi
40 changes: 40 additions & 0 deletions .devcontainer/container/helpers/common/homeassistant/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash
# shellcheck source=/dev/null

source /opt/container/helpers/common/paths.sh
mkdir -p /config

if test -f "$(workspacePath)config/configuration.yaml"; then
echo "Copy configuration.yaml"
ln -sf "$(workspacePath)config/configuration.yaml" /config/configuration.yaml || echo "config/configuration.yaml are missing"
fi

if test -f "$(workspacePath)config/ui-lovelace.yaml"; then
echo "Copy ui-lovelace.yaml"
ln -sf "$(workspacePath)config/ui-lovelace.yaml" /config/ui-lovelace.yaml || echo ""
fi

if test -f "$(workspacePath)config/secrets.yaml"; then
echo "Copy secrets.yaml"
ln -sf "$(workspacePath)config/secrets.yaml" /config/secrets.yaml || echo ""
fi

if test -d "$(workspacePath)custom_components"; then
echo "Symlink the custom component directory"

if test -d "$(workspacePath)custom_components"; then
rm -R /config/custom_components
fi

ln -sf "$(workspacePath)custom_components/" /config/custom_components || echo "Could not copy the custom_component" exit 1
elif test -f "__init__.py"; then
echo "Having the component in the root is currently not supported"
fi

echo "Start Home Assistant"
if ! [ -x "$(command -v hass)" ]; then
echo "Home Assistant is not installed, running installation."
python3 -m pip --disable-pip-version-check install --upgrade git+https://github.com/home-assistant/home-assistant.git@dev
fi
hass --script ensure_config -c /config
hass -c /config
9 changes: 9 additions & 0 deletions .devcontainer/container/helpers/common/paths.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

function workspacePath {
if [[ -n "$WORKSPACE_DIRECTORY" ]]; then
echo "${WORKSPACE_DIRECTORY}/"
else
echo "$(find /workspaces -mindepth 1 -maxdepth 1 -type d | tail -1)/"
fi
}
21 changes: 21 additions & 0 deletions .devcontainer/container/helpers/integration/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
# shellcheck source=/dev/null

source /opt/container/helpers/common/paths.sh


if test -d "$(workspacePath).git"; then
echo ".git exsist in $(workspacePath), existing initializing"
exit 1
fi

echo "Initializing dev env for integration"
rm -R /tmp/init > /dev/null 2>&1

git clone https://github.com/custom-components/integration-blueprint.git /tmp/init

rm -R /tmp/init/.git
rm -R /tmp/init/.devcontainer
cp -a /tmp/init/. "$(workspacePath)"
cd "$(workspacePath)" || exit 1
git init
20 changes: 20 additions & 0 deletions .devcontainer/container/makefiles/integration.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
start: ## Start Home Assistant with the integration loaded
@bash /opt/container/helpers/common/homeassistant/start.sh

set-version: ## Set Home Assistant version
@bash /opt/container/helpers/common/homeassistant/set-version.sh

install: ## Install Home Assistant dev in the container
@python3 -m pip --disable-pip-version-check install --upgrade git+https://github.com/home-assistant/home-assistant.git@dev

upgrade: ## Upgrade Home Assistant to latest dev in the container
install

run:
start

check-config: ## Check Home Assistant config
@hass -c /config --script check_config

init: ## Initialize the dev env
@bash /opt/container/helpers/integration/init.sh
10 changes: 10 additions & 0 deletions .devcontainer/install/cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

echo -e "\\033[0;34mRunning cleanup script 'cleanup.sh'\\033[0m"

apt-get clean -y
rm -fr /var/lib/apt/lists/*
rm -fr /tmp/* /var/{cache,log}/*

rm -fr /container
rm -fr /install
24 changes: 24 additions & 0 deletions .devcontainer/install/container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
set -e
echo -e "\\033[0;34mRunning install script 'container.sh'\\033[0m"

export DEBIAN_FRONTEND=noninteractive

apt-get update
apt-get install -y --no-install-recommends \
make

mkdir -p /opt/container/makefiles
mkdir -p /opt/container/helpers
touch /opt/container/makefiles/dummy.mk

cp /container/container.mk /opt/container/container.mk
cp -r /container/helpers/common /opt/container/helpers/common

cp /container/container /usr/bin/container
chmod +x /usr/bin/container

cp /container/makefiles/integration.mk /opt/container/makefiles/integration.mk
cp -r /container/helpers/integration /opt/container/helpers/integration

container help
4 changes: 4 additions & 0 deletions .devcontainer/install/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh

uname -m
printenv
47 changes: 47 additions & 0 deletions .devcontainer/install/integration.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash
set -e
echo -e "\\033[0;34mRunning install script 'integration.sh'\\033[0m"

export DEBIAN_FRONTEND=noninteractive

apt-get update
apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
curl \
ffmpeg \
gcc \
git \
jq \
libavcodec-dev \
libavdevice-dev \
libavfilter-dev \
libavformat-dev \
libavutil-dev \
libbz2-dev \
libcap-dev \
libffi-dev \
libjpeg-dev \
liblzma-dev \
libncurses5-dev \
libncursesw5-dev \
libpcap-dev \
libreadline-dev \
libsqlite3-dev \
libssl-dev \
libswresample-dev \
libswscale-dev \
llvm \
shellcheck \
tar \
tk-dev \
wget \
xz-utils \
zlib1g-dev

python3 -m pip --disable-pip-version-check install --upgrade \
git+https://github.com/home-assistant/home-assistant.git@dev
python3 -m pip --disable-pip-version-check install --upgrade wheel setuptools

# Fix issue https://github.com/home-assistant/core/issues/95192
python3 -m pip --disable-pip-version-check install --upgrade git+https://github.com/boto/botocore urllib3~=1.26
10 changes: 5 additions & 5 deletions .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---
name: "Bug report"
description: "Report a bug with the integration"
labels: "Bug"
labels: "bug"
body:
- type: markdown
attributes:
value: Before you open a new issue, search through the existing issues to see if others have had the same problem.
- type: textarea
attributes:
label: "System Health details"
description: "Paste the data from the System Health card in Home Assistant (https://www.home-assistant.io//more-info/system-health#github-issues)"
description: "Paste the data from the System Health card in Home Assistant (https://www.home-assistant.io/more-info/system-health#github-issues)"
validations:
required: true
- type: checkboxes
Expand All @@ -22,7 +22,7 @@ body:
required: true
- label: This issue only contains 1 issue (if you have multiple issues, open one issue for each issue).
required: true
- label: This issue is not a duplicate issue of currently [previous issues](https://github.com/ludeeus/integration_blueprint/issues?q=is%3Aissue+label%3A%22Bug%22+)..
- label: This issue is not a duplicate issue of any [previous issues](https://github.com/Limych/ha-carwash/issues?q=is%3Aissue+label%3A%22bug%22+)..
required: true
- type: textarea
attributes:
Expand All @@ -33,7 +33,7 @@ body:
- type: textarea
attributes:
label: Reproduction steps
description: "Without steps to reproduce, it will be hard to fix, it is very important that you fill out this part, issues without it will be closed"
description: "Without steps to reproduce, it will be hard to fix. It is very important that you fill out this part. Issues without it will be closed."
value: |
1.
2.
Expand All @@ -44,7 +44,7 @@ body:
- type: textarea
attributes:
label: "Debug logs"
description: "To enable debug logs check this https://www.home-assistant.io/integrations/logger/, this **needs** to include _everything_ from startup of Home Assistant to the point where you encounter the issue."
description: "To enable debug logs check this https://www.home-assistant.io/integrations/logger/, this **needs** to install _everything_ from startup of Home Assistant to the point where you encounter the issue."
render: text
validations:
required: true
Expand Down
70 changes: 0 additions & 70 deletions .github/ISSUE_TEMPLATE/bug_report.md

This file was deleted.

Loading

0 comments on commit 658cab5

Please sign in to comment.