mirror of
https://github.com/hacs/integration.git
synced 2025-07-22 00:35:16 +00:00
Update development environment (#3060)
* Update development environment * lint
This commit is contained in:
@ -15,4 +15,4 @@ ratings:
|
||||
exclude_paths:
|
||||
- tests/
|
||||
- action/
|
||||
- manage/
|
||||
- scripts/
|
@ -1,19 +1,18 @@
|
||||
{
|
||||
"name": "HACS Integration Development",
|
||||
"name": "hacs/integration",
|
||||
"image": "mcr.microsoft.com/vscode/devcontainers/python:0-3.10-bullseye",
|
||||
"postCreateCommand": "make init",
|
||||
"context": "..",
|
||||
"appPort": [
|
||||
"9123:8123"
|
||||
],
|
||||
"extensions": [
|
||||
"ms-python.python",
|
||||
"github.vscode-pull-request-github",
|
||||
"ryanluker.vscode-coverage-gutters",
|
||||
"ms-python.vscode-pylance",
|
||||
"GitHub.copilot"
|
||||
"postCreateCommand": "scripts/setup",
|
||||
"forwardPorts": [
|
||||
8123
|
||||
],
|
||||
"customizations": {
|
||||
"extensions": [
|
||||
"ms-python.python",
|
||||
"github.vscode-pull-request-github",
|
||||
"ryanluker.vscode-coverage-gutters",
|
||||
"ms-python.vscode-pylance",
|
||||
"GitHub.copilot"
|
||||
],
|
||||
"vscode": {
|
||||
"settings": {
|
||||
"python.defaultInterpreterPath": "/usr/local/bin/python",
|
||||
|
10
.github/workflows/generate-hacs-data.yml
vendored
10
.github/workflows/generate-hacs-data.yml
vendored
@ -47,14 +47,8 @@ jobs:
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
bash manage/install_frontend
|
||||
pip3 install \
|
||||
--disable-pip-version-check install \
|
||||
--ignore-installed \
|
||||
--constraint constraints.txt \
|
||||
--requirement requirements_generate_data.txt \
|
||||
--use-deprecated=legacy-resolver
|
||||
|
||||
scripts/install/frontend
|
||||
scripts/install/pip_packages --requirement requirements_generate_data.txt
|
||||
|
||||
- name: Generate ${{ matrix.category }} data
|
||||
run: python3 -m scripts.data.generate_category_data ${{ matrix.category }}
|
||||
|
4
.github/workflows/lint.yaml
vendored
4
.github/workflows/lint.yaml
vendored
@ -39,7 +39,7 @@ jobs:
|
||||
|
||||
- name: 📦 Install pre-commit
|
||||
run: |
|
||||
python3 -m pip install pre-commit
|
||||
scripts/install/pip_packages pre-commit
|
||||
pre-commit install-hooks --config .github/pre-commit-config.yaml
|
||||
|
||||
- name: 🏃 Run the check (${{ matrix.check }})
|
||||
@ -63,7 +63,7 @@ jobs:
|
||||
requirements_lint.txt
|
||||
|
||||
- name: 📦 Install requirements
|
||||
run: python3 -m pip install -r requirements_lint.txt
|
||||
run: scripts/install/pip_packages --requirement requirements_lint.txt
|
||||
|
||||
- name: ✅ Add problem matcher
|
||||
run: echo "::add-matcher::.github/matchers/bellybutton.json"
|
||||
|
4
.github/workflows/publish.yml
vendored
4
.github/workflows/publish.yml
vendored
@ -36,10 +36,10 @@ jobs:
|
||||
if: ${{ github.event_name == 'release' }}
|
||||
run: |
|
||||
sed -i "/MINIMUM_HA_VERSION = /c\MINIMUM_HA_VERSION = \"$(jq .homeassistant -r ${{ github.workspace }}/hacs.json)\"" ${{ github.workspace }}/custom_components/hacs/const.py
|
||||
python3 ${{ github.workspace }}/manage/update_manifest.py --version ${{ steps.version.outputs.version }}
|
||||
python3 ${{ github.workspace }}/scripts/update/manifest.py --version ${{ steps.version.outputs.version }}
|
||||
|
||||
- name: ⏬ Download HACS frontend
|
||||
run: ${{ github.workspace }}/manage/install_frontend
|
||||
run: ${{ github.workspace }}/scripts/install/frontend
|
||||
|
||||
- name: 📤 Upload zip to action
|
||||
uses: actions/upload-artifact@v3.1.2
|
||||
|
12
.github/workflows/pytest.yml
vendored
12
.github/workflows/pytest.yml
vendored
@ -35,8 +35,8 @@ jobs:
|
||||
|
||||
- name: 📦 Install requirements
|
||||
run: |
|
||||
python3 -m pip install -r requirements_test.txt
|
||||
bash manage/install_frontend
|
||||
scripts/install/frontend
|
||||
scripts/install/pip_packages --requirement requirements_test.txt
|
||||
|
||||
- name: 🏃 Run tests
|
||||
env:
|
||||
@ -47,7 +47,7 @@ jobs:
|
||||
- name: 📤 Upload coverage to Codecov
|
||||
if: ${{ matrix.python-version == '3.9' }}
|
||||
run: |
|
||||
make coverage
|
||||
scripts/coverage
|
||||
curl -sfSL https://codecov.io/bash | bash -
|
||||
|
||||
legacy:
|
||||
@ -68,9 +68,9 @@ jobs:
|
||||
|
||||
- name: 📦 Install dependencies
|
||||
run: |
|
||||
python3 -m pip install -r requirements_test.txt
|
||||
make homeassistant-install-old
|
||||
bash manage/install_frontend
|
||||
scripts/install/pip_packages --requirement requirements_test.txt
|
||||
scripts/install/core
|
||||
scripts/install/frontend
|
||||
|
||||
- name: 🏃 Run tests
|
||||
env:
|
||||
|
2
.github/workflows/validate.yml
vendored
2
.github/workflows/validate.yml
vendored
@ -63,7 +63,7 @@ jobs:
|
||||
- name: 📋 Copy sample configuration for Home Assistant
|
||||
run: |
|
||||
mkdir ./test_configuration
|
||||
bash manage/install_frontend
|
||||
bash scripts/install/frontend
|
||||
cp -r ./custom_components ./test_configuration
|
||||
echo "default_config:" >> ./test_configuration/configuration.yaml
|
||||
echo "hacs:" >> ./test_configuration/configuration.yaml
|
||||
|
46
.gitignore
vendored
46
.gitignore
vendored
@ -1,24 +1,36 @@
|
||||
site
|
||||
.pytest*
|
||||
# artifacts
|
||||
__pycache__
|
||||
action/Test
|
||||
settings.json
|
||||
.devcontainer/configuration.yaml
|
||||
node_modules
|
||||
custom_components/custom_components
|
||||
custom_components/hacs/hacs_frontend
|
||||
custom_components/hacs/hacs_frontend_experimental
|
||||
manage/secrets.json
|
||||
.pytest*
|
||||
*.egg-info
|
||||
*/dist/*
|
||||
*/build/*
|
||||
.vscode
|
||||
*/dist/*
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
|
||||
# misc
|
||||
.coverage
|
||||
.vscode
|
||||
coverage.xml
|
||||
htmlcov
|
||||
venv
|
||||
config
|
||||
outputdata
|
||||
outputdata
|
||||
settings.json
|
||||
|
||||
|
||||
# Frontend are downloaded on release
|
||||
custom_components/hacs/hacs_frontend
|
||||
custom_components/hacs/hacs_frontend_experimental
|
||||
|
||||
|
||||
# Home Assistant configuration
|
||||
.cloud
|
||||
.HA_VERSION
|
||||
.storage
|
||||
automations.yaml
|
||||
blueprints
|
||||
configuration.yaml
|
||||
deps
|
||||
home-assistant_v2*
|
||||
home-assistant.log*
|
||||
tts
|
||||
scenes.yaml
|
||||
scripts.yaml
|
||||
secrets.yaml
|
||||
|
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 - 2021 Joakim Sørensen (@ludeeus)
|
||||
Copyright (c) 2019 - 2023 Joakim Sørensen (@ludeeus)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
58
Makefile
58
Makefile
@ -1,58 +0,0 @@
|
||||
.DEFAULT_GOAL := help
|
||||
SHELL := /bin/bash
|
||||
|
||||
help: ## Shows help message.
|
||||
@printf "\033[1m%s\033[36m %s\033[32m %s\033[0m \n\n" "Development environment for" "HACS" "Integration";
|
||||
@awk 'BEGIN {FS = ":.*##";} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m make %-25s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST);
|
||||
@echo
|
||||
|
||||
init: requirements homeassistant-install-old## Install requirements
|
||||
pre-commit install-hooks --config .github/pre-commit-config.yaml;
|
||||
|
||||
requirements:
|
||||
python3 -m pip --disable-pip-version-check install -U "pip>=8.0.3,<20.3"
|
||||
python3 -m pip --disable-pip-version-check install -U setuptools wheel
|
||||
python3 -m pip --disable-pip-version-check install --ignore-installed -r requirements_lint.txt -r requirements_test.txt -c constraints.txt
|
||||
@bash manage/install_frontend
|
||||
|
||||
start: ## Start the HA with the integration
|
||||
@bash manage/integration_start;
|
||||
|
||||
test: ## Run pytest
|
||||
@python3 -m pytest tests -rxf -x -v -l --cov=./ --cov-report=xml
|
||||
|
||||
lint: ## Run linters
|
||||
set -e
|
||||
jq -r -e -c . tests/fixtures/*.json
|
||||
pre-commit install-hooks --config .github/pre-commit-config.yaml;
|
||||
pre-commit run --hook-stage manual --all-files --config .github/pre-commit-config.yaml;
|
||||
bellybutton lint
|
||||
vulture . --min-confidence 75 --ignore-names policy
|
||||
|
||||
coverage: ## Display coverage report
|
||||
@python3 -m pytest tests -rxf -x -v -l --cov=./ --cov-report=xml > /dev/null
|
||||
@coverage report --skip-covered
|
||||
|
||||
update: ## Pull main from hacs/integration
|
||||
git pull upstream main;
|
||||
|
||||
update-base-repositories: ## Update stored base repositories
|
||||
@python3 manage/update_default_repositories.py;
|
||||
|
||||
clear-storage:
|
||||
rm -rf config/.storage/hacs
|
||||
rm config/.storage/hacs*
|
||||
|
||||
homeassistant-install: ## Install the latest dev version of Home Assistant
|
||||
python3 -m pip --disable-pip-version-check install -U "pip>=8.0.3,<20.3";
|
||||
python3 -m pip --disable-pip-version-check install -U setuptools wheel;
|
||||
python3 -m pip --disable-pip-version-check \
|
||||
install --upgrade git+https://github.com/home-assistant/home-assistant.git@dev -c constraints.txt;
|
||||
|
||||
homeassistant-install-old: ## Install the oldest version of Home Assistant
|
||||
python3 -m pip --disable-pip-version-check install -U "pip>=8.0.3,<20.3";
|
||||
python3 -m pip --disable-pip-version-check install -U setuptools wheel;
|
||||
python3 -m pip --disable-pip-version-check \
|
||||
install --upgrade homeassistant==2022.11.0 -c constraints.txt;
|
||||
|
||||
homeassistant-update: homeassistant-install ## Alias for 'homeassistant-install'
|
@ -12,11 +12,11 @@ RUN \
|
||||
\
|
||||
&& git clone --quiet --depth 1 https://github.com/hacs/integration.git /hacs \
|
||||
\
|
||||
&& python3 -m pip --disable-pip-version-check install setuptools wheel \
|
||||
&& bash /hacs/scripts/install/pip_packages setuptools wheel \
|
||||
\
|
||||
&& python3 -m pip --disable-pip-version-check install homeassistant aiogithubapi \
|
||||
&& bash /hacs/scripts/install/pip_packages homeassistant aiogithubapi \
|
||||
\
|
||||
&& bash /hacs/manage/install_frontend \
|
||||
&& bash /hacs/scripts/install/frontend \
|
||||
\
|
||||
&& apk del --no-cache .build-deps > /dev/null 2>&1 \
|
||||
\
|
||||
|
@ -1,4 +1,6 @@
|
||||
{
|
||||
"domain": "hacs",
|
||||
"name": "HACS",
|
||||
"codeowners": [
|
||||
"@ludeeus"
|
||||
],
|
||||
@ -12,10 +14,8 @@
|
||||
"repairs"
|
||||
],
|
||||
"documentation": "https://hacs.xyz/docs/configuration/start",
|
||||
"domain": "hacs",
|
||||
"iot_class": "cloud_polling",
|
||||
"issue_tracker": "https://github.com/hacs/integration/issues",
|
||||
"name": "HACS",
|
||||
"requirements": [
|
||||
"aiogithubapi>=22.10.1"
|
||||
],
|
||||
|
@ -1,33 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [ ! -d "${PWD}/config" ]; then
|
||||
echo "Creating default configuration."
|
||||
mkdir -p "${PWD}/config";
|
||||
hass --script ensure_config -c "${PWD}/config"
|
||||
echo "
|
||||
logger:
|
||||
default: info
|
||||
logs:
|
||||
custom_components.hacs: debug
|
||||
aiogithubapi: debug
|
||||
awesomeversion: debug
|
||||
frontend:
|
||||
themes: !include_dir_merge_named themes
|
||||
|
||||
#hacs: #https://hacs.xyz/docs/configuration/legacy
|
||||
# token: CHANGE_ME
|
||||
# frontend_repo_url: http://192.168.100.50:5000
|
||||
# appdaemon: true
|
||||
# experimental: true
|
||||
" >> "${PWD}/config/configuration.yaml"
|
||||
fi
|
||||
|
||||
# Symlink the custom_components dir
|
||||
rm -rf "${PWD}/config/custom_components"
|
||||
ln -sf "${PWD}/custom_components" "${PWD}/config/custom_components"
|
||||
|
||||
echo "Installing HACS frontend"
|
||||
bash "${PWD}/manage/install_frontend"
|
||||
|
||||
# Start Home Assistant
|
||||
hass -c "${PWD}/config" --debug
|
@ -1,23 +0,0 @@
|
||||
"""Update the manifest file."""
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def update_manifest():
|
||||
"""Update the manifest file."""
|
||||
version = "0.0.0"
|
||||
for index, value in enumerate(sys.argv):
|
||||
if value in ["--version", "-V"]:
|
||||
version = sys.argv[index + 1]
|
||||
|
||||
with open(f"{os.getcwd()}/custom_components/hacs/manifest.json") as manifestfile:
|
||||
manifest = json.load(manifestfile)
|
||||
|
||||
manifest["version"] = version
|
||||
|
||||
with open(f"{os.getcwd()}/custom_components/hacs/manifest.json", "w") as manifestfile:
|
||||
manifestfile.write(json.dumps(manifest, indent=4, sort_keys=True))
|
||||
|
||||
|
||||
update_manifest()
|
9
scripts/clear_storage
Executable file
9
scripts/clear_storage
Executable file
@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
rm -rf .storage/hacs
|
||||
rm -f .storage/hacs*
|
||||
|
11
scripts/coverage
Executable file
11
scripts/coverage
Executable file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
bash scripts/test > /dev/null
|
||||
python3 -m \
|
||||
coverage \
|
||||
report \
|
||||
--skip-covered
|
26
scripts/develop
Executable file
26
scripts/develop
Executable file
@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
if [ ! -f "configuration.yaml" ]; then
|
||||
echo "Creating default configuration."
|
||||
echo "
|
||||
default_config:
|
||||
frontend:
|
||||
themes: !include_dir_merge_named themes
|
||||
logger:
|
||||
default: info
|
||||
logs:
|
||||
custom_components.hacs: debug
|
||||
# aiogithubapi: debug
|
||||
# awesomeversion: debug
|
||||
" >> "configuration.yaml"
|
||||
fi
|
||||
|
||||
echo "Installing HACS frontend"
|
||||
bash "scripts/install/frontend"
|
||||
|
||||
# Start Home Assistant
|
||||
hass -c . --debug
|
7
scripts/install/core
Executable file
7
scripts/install/core
Executable file
@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
cd "$(dirname "$0")/../.."
|
||||
|
||||
bash scripts/install/pip_packages "homeassistant==${1:-$(jq -r .homeassistant hacs.json)}"
|
@ -2,15 +2,16 @@
|
||||
|
||||
set -e
|
||||
|
||||
cd "$(dirname "$0")/../.."
|
||||
|
||||
FRONTEND_VERSION="20220906112053"
|
||||
EXPERIMENTAL_FRONTEND_VERSION="20230127100107"
|
||||
|
||||
rm -rf ./custom_components/hacs/hacs_frontend
|
||||
rm -rf ./custom_components/hacs/hacs_frontend_experimental
|
||||
|
||||
python3 -m pip --disable-pip-version-check install -U --target=./custom_components/hacs "hacs_frontend==$EXPERIMENTAL_FRONTEND_VERSION"
|
||||
scripts/install/pip_packages --target=./custom_components/hacs "hacs_frontend==${EXPERIMENTAL_FRONTEND_VERSION}"
|
||||
rm -rf ./custom_components/hacs/*.dist-info
|
||||
mv ./custom_components/hacs/hacs_frontend ./custom_components/hacs/hacs_frontend_experimental
|
||||
|
||||
python3 -m pip --disable-pip-version-check install -U --target=./custom_components/hacs "hacs_frontend==$FRONTEND_VERSION"
|
||||
rm -rf ./custom_components/hacs/*.dist-info
|
||||
rm -rf ./custom_components/hacs/hacs_frontend
|
||||
scripts/install/pip_packages --target=./custom_components/hacs "hacs_frontend==${FRONTEND_VERSION}"
|
||||
rm -rf ./custom_components/hacs/*.dist-info
|
12
scripts/install/pip_packages
Executable file
12
scripts/install/pip_packages
Executable file
@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
python3 -m pip \
|
||||
install \
|
||||
--upgrade \
|
||||
--disable-pip-version-check \
|
||||
--use-deprecated=legacy-resolver \
|
||||
--constraint constraints.txt \
|
||||
"${@}"
|
||||
|
12
scripts/lint
Executable file
12
scripts/lint
Executable file
@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
pre-commit install-hooks --config .github/pre-commit-config.yaml;
|
||||
pre-commit run --hook-stage manual --all-files --config .github/pre-commit-config.yaml;
|
||||
|
||||
bellybutton lint
|
||||
|
||||
vulture . --min-confidence 75 --ignore-names policy
|
11
scripts/setup
Executable file
11
scripts/setup
Executable file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
scripts/install/pip_packages "pip>=21.0,<23.1"
|
||||
scripts/install/pip_packages setuptools wheel
|
||||
scripts/install/pip_packages --requirement requirements_lint.txt --requirement requirements_test.txt
|
||||
scripts/install/frontend
|
||||
scripts/install/core
|
13
scripts/test
Executable file
13
scripts/test
Executable file
@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
python3 -m \
|
||||
pytest \
|
||||
tests \
|
||||
-rxf -x -v -l \
|
||||
--cov=./ \
|
||||
--cov-report=xml
|
||||
|
1
scripts/update/__init__.py
Normal file
1
scripts/update/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
"""HACS update script."""
|
@ -9,7 +9,7 @@ def update():
|
||||
storage, to_store, old = None, {}, {}
|
||||
updated = 0
|
||||
|
||||
with open(f"{os.getcwd()}/config/.storage/hacs.repositories", encoding="utf-8") as storage_file:
|
||||
with open(f"{os.getcwd()}/.storage/hacs.repositories", encoding="utf-8") as storage_file:
|
||||
storage = json.load(storage_file)
|
||||
|
||||
with open(
|
35
scripts/update/manifest.py
Normal file
35
scripts/update/manifest.py
Normal file
@ -0,0 +1,35 @@
|
||||
"""Update the manifest file."""
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
|
||||
MANIFEST_FILE = Path(f"{os.getcwd()}/custom_components/hacs/manifest.json")
|
||||
|
||||
|
||||
def update_manifest():
|
||||
"""Update the manifest file."""
|
||||
version = "0.0.0"
|
||||
for index, value in enumerate(sys.argv):
|
||||
if value in ["--version", "-V"]:
|
||||
version = sys.argv[index + 1]
|
||||
|
||||
with open(MANIFEST_FILE, encoding="utf-8") as manifestfile:
|
||||
base: dict = json.load(manifestfile)
|
||||
base["version"] = version
|
||||
|
||||
with open(MANIFEST_FILE, "w", encoding="utf-8") as manifestfile:
|
||||
manifestfile.write(
|
||||
json.dumps(
|
||||
{
|
||||
"domain": base["domain"],
|
||||
"name": base["name"],
|
||||
**{k: v for k, v in sorted(base.items()) if k not in ("domain", "name")},
|
||||
},
|
||||
indent=4,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
update_manifest()
|
Reference in New Issue
Block a user