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:
#	custom_components/integration_blueprint/__init__.py
#	custom_components/integration_blueprint/binary_sensor.py
#	custom_components/integration_blueprint/config_flow.py
#	custom_components/integration_blueprint/const.py
#	custom_components/integration_blueprint/sensor.py
#	custom_components/integration_blueprint/switch.py
#	hacs.json
#	requirements.txt
#	tests/const.py
#	tests/test_config_flow.py
#	tests/test_switch.py
  • Loading branch information
Limych committed Jul 18, 2022
2 parents 540c907 + 631d289 commit 0ace8c8
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/py-dead-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ 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@v3
uses: actions/setup-python@v4
with:
python-version: '3.9'

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/py-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ 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@v3
uses: actions/setup-python@v4
with:
python-version: '3.9'

Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:
uses: actions/checkout@v3

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

Expand Down
24 changes: 11 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ on:
- "[v0-9]+.[0-9]+*"

jobs:
release_zip_file:
name: "Prepare release asset"
release:
name: "Publish new release"
runs-on: ubuntu-latest
steps:
- name: "Check out repository"
Expand All @@ -17,7 +17,7 @@ jobs:
- working-directory: ./custom_components
run: |
echo "package=$(ls -F | grep \/$ | sed -n "s/\///g;1p")" >> $GITHUB_ENV
echo "release_version=$(git describe --abbrev=0 | sed s/v//)" >> $GITHUB_ENV
echo "release_version=$(git describe --tags | sed s/v//)" >> $GITHUB_ENV
- working-directory: ./custom_components
run: |
echo "basedir=$(pwd)/${{ env.package }}" >> $GITHUB_ENV
Expand All @@ -34,26 +34,23 @@ jobs:
run: |
zip ${{ env.package }}.zip -r ./
- name: "Upload zip to release"
- name: "Release"
if: env.release_version != '' && success()
uses: svenstaro/upload-release-action@v2
uses: softprops/action-gh-release@v1
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ env.basedir }}/${{ env.package }}.zip
asset_name: ${{ env.package }}.zip
tag: ${{ env.release_version }}
overwrite: true
files: ${{ env.basedir }}/${{ env.package }}.zip

releasenotes:
name: "Prepare releasenotes"
release-notes:
name: "Compose release notes"
needs: release
runs-on: ubuntu-latest
steps:
- name: "Check out repository"
uses: actions/checkout@v3

- working-directory: ./custom_components
run: |
echo "release_version=$(git describe --abbrev=0 | sed s/v//)" >> $GITHUB_ENV
echo "release_version=$(git describe --tags | sed s/v//)" >> $GITHUB_ENV
- name: "Set up Python"
if: env.release_version != '' && success()
Expand All @@ -62,6 +59,7 @@ jobs:
python-version: 3.9

- name: "Cache pip"
if: env.release_version != '' && success()
uses: actions/cache@v3
with:
# This path is specific to Ubuntu
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repos:
name: Update manifest.json
entry: bin/update_manifest
language: script
files: ^custom_components/.+/const\.py$
files: ^(custom_components/.+/const\.py|requirements\.txt)$
- repo: https://github.com/asottile/pyupgrade
rev: v2.7.4
hooks:
Expand Down
5 changes: 5 additions & 0 deletions bin/update_manifest
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ fi

component=$(ls -q "${ROOT}/custom_components/" | grep -v __ | head -n 1)
const_path="custom_components/${component}/const.py"
reqs_path="requirements.txt"

name=$(grep "^NAME: Final =" ${const_path} | sed -E "s/^[^\"]+\"([^\"]*).*$/\\1/")
domain=$(grep "^DOMAIN: Final =" ${const_path} | sed -E "s/^[^\"]+\"([^\"]*).*$/\\1/")
version=$(grep "^VERSION: Final =" ${const_path} | sed -E "s/^[^\"]+\"([^\"]*).*$/\\1/")
issue_url=$(grep "^ISSUE_URL: Final =" ${const_path} | sed -E "s/^[^\"]+\"([^\"]*).*$/\\1/")
ha_version=$(grep "^homeassistant>=" ${reqs_path} | sed -E "s/^[^=]+=(\S*).*$/\\1/")

log.info "Update manifest.json data..."
manifest_path="custom_components/${component}/manifest.json"
Expand All @@ -29,6 +31,9 @@ sed -i -E "s!(\"domain\": \")[^\"]*!\\1${domain}!" ${manifest_path}
sed -i -E "s!(\"version\": \")[^\"]*!\\1${version}!" ${manifest_path}
sed -i -E "s!(\"issue_tracker\": \")[^\"]*!\\1${issue_url}!" ${manifest_path}

bin/update_requirements

log.info "Update hacs.json data..."
hacs_path="${ROOT}/hacs.json"
sed -i -E "s!(\"name\": \")[^\"]*!\\1${name}!" ${hacs_path}
sed -i -E "s!(\"homeassistant\": \")[^\"]*!\\1${ha_version}!" ${hacs_path}
26 changes: 7 additions & 19 deletions bin/update_requirements
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def get_package(requre: str) -> str:
return requre.split(">")[0].split("<")[0].split("!")[0].split("=")[0].split("~")[0]


harequire = []
harequire = ["homeassistant"]
request = requests.get(
"https://raw.githubusercontent.com/home-assistant/core/dev/requirements.txt"
)
Expand All @@ -34,29 +34,17 @@ for req in request:
if "=" in req:
harequire.append(get_package(req))

print(harequire)

with open(f"{PKG_PATH}/manifest.json", encoding="utf8") as manifest:
manifest = json.load(manifest)
requirements = []
for req in manifest["requirements"]:
requirements.append(get_package(req))
manifest["requirements"] = requirements

with open(f"{ROOT}/requirements.txt", encoding="utf8") as requirements:
tmp = requirements.readlines()
requirements = []
for req in tmp:
requirements.append(req.replace("\n", ""))
for req in requirements:
pkg = get_package(req)
if pkg in manifest["requirements"]:
manifest["requirements"].remove(pkg)
manifest["requirements"].append(req)

for req in manifest["requirements"]:
pkg = get_package(req)
if pkg in harequire:
print(f"{pkg} in HA requirements, no need here.")
print(json.dumps(manifest["requirements"], indent=4))
pkg = get_package(req)
if pkg not in harequire:
requirements.append(req.replace("\n", ""))
manifest["requirements"] = requirements

with open(f"{PKG_PATH}/manifest.json", "w", encoding="utf8") as manifestfile:
manifestfile.write(json.dumps(manifest, indent=4))
4 changes: 1 addition & 3 deletions hacs.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"name": "JQ-300/200/100 Indoor Air Quality Meter",
"domains": ["sensor"],
"hacs": "1.6.0",
"iot_class": "Cloud Push",
"homeassistant": "0.118.0"
"homeassistant": "2022.6.0"
}
2 changes: 0 additions & 2 deletions pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ good-names=id,i,j,k,ex,Run,_,fp,T
# locally-disabled - it spams too much
# duplicate-code - unavoidable
# cyclic-import - doesn't test if both import on load
# abstract-class-little-used - prevents from setting right foundation
# unused-argument - generic callbacks and setup methods create a lot of warnings
# too-many-* - are not enforced for the sake of readability
# too-few-* - same as too-many-*
Expand All @@ -26,7 +25,6 @@ good-names=id,i,j,k,ex,Run,_,fp,T
# wrong-import-order - isort guards this
disable=
format,
abstract-class-little-used,
abstract-method,
cyclic-import,
duplicate-code,
Expand Down
8 changes: 4 additions & 4 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-r requirements-test.txt
black==22.3.0
black==22.6.0
packaging==21.3
pre-commit~=2.19
pre-commit~=2.20
PyGithub~=1.55
pyupgrade~=2.32
yamllint~=1.26
pyupgrade~=2.37
yamllint~=1.27
4 changes: 2 additions & 2 deletions requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
asynctest~=0.13
flake8~=4.0
flake8-docstrings~=1.6
mypy==0.960
mypy==0.961
pylint~=2.14
pylint-strict-informational==0.1
pytest~=7.1
pytest-cov~=2.12
pytest-cov~=3.0
pytest-homeassistant-custom-component>=0.8
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
homeassistant>=2022.4
homeassistant>=2022.6.0
paho-mqtt==1.6.1

0 comments on commit 0ace8c8

Please sign in to comment.