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
#	config/bootstrap.sh
#	custom_components/integration_blueprint/const.py
#	custom_components/integration_blueprint/manifest.json
#	hacs.json
#	requirements-dev.txt
#	requirements-test.txt
  • Loading branch information
Limych committed Feb 27, 2024
2 parents 803639f + 06bc9eb commit 2a33624
Show file tree
Hide file tree
Showing 33 changed files with 290 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .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:3.11-bullseye",
"postCreateCommand": "scripts/setup",
"forwardPorts": [
8123
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
8 changes: 4 additions & 4 deletions .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ body:
- 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/ludeeus/integration_blueprint/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
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -56,7 +56,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand All @@ -69,4 +69,4 @@ jobs:
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
2 changes: 1 addition & 1 deletion .github/workflows/issue-lock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
lock:
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v4
- uses: dessant/lock-threads@v5
with:
github-token: ${{ github.token }}
issue-lock-inactive-days: 30
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- name: "Checkout the repository"
uses: "actions/checkout@v4"
uses: "actions/checkout@v4.1.0"

- name: "Set up Python"
uses: actions/setup-python@v4.6.1
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.11"
cache: "pip"

- name: "Install requirements"
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/py-dead-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ jobs:
uses: actions/checkout@v4

- run: |
echo "package=$(ls -F | grep \/$ | grep -v "bin\|examples\|tests" | sed -n "s/\///g;1p")" >> $GITHUB_ENV
echo "package=$(ls -F | grep \/$ | grep -v "scripts\|examples\|tests\|config" | sed -n "s/\///g;1p")" >> $GITHUB_ENV
- name: "Set up Python"
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: '3.11'

- name: "Cache pip"
uses: actions/cache@v3
uses: actions/cache@v4
with:
# This path is specific to Ubuntu
path: ~/.cache/pip
Expand Down
17 changes: 11 additions & 6 deletions .github/workflows/py-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ jobs:
echo "package=$(ls -F | grep \/$ | grep -v "bin\|examples\|tests" | sed -n "s/\///g;1p")" >> $GITHUB_ENV
- name: "Set up Python"
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: "Cache pip"
uses: actions/cache@v3
uses: actions/cache@v4
with:
# This path is specific to Ubuntu
path: ~/.cache/pip
Expand Down Expand Up @@ -60,24 +60,29 @@ jobs:
pylint ${{ env.package }} tests
tests:
name: "Test package"
name: Test package on Python ${{ matrix.python-version }}
needs: lint
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}
strategy:
max-parallel: 3
matrix:
python-version: ['3.9', '3.10', '3.11']
python-version: ['3.11', '3.12']
experimental: [false]
# include:
# - python-version: '3.12'
# experimental: true
steps:
- name: "Checkout code"
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: "Cache pip"
uses: actions/cache@v3
uses: actions/cache@v4
with:
# This path is specific to Ubuntu
path: ~/.cache/pip
Expand Down
Loading

0 comments on commit 2a33624

Please sign in to comment.