Skip to content

Commit

Permalink
Linting, housekeeping
Browse files Browse the repository at this point in the history
- flake8 and black linting
- add CONFIG_SCHEMA per hassfest checks
- have vscode generate valid text files
- remove (currently unused) pandas requirement
- remove invalid `iot_class` entry from hacs.json
- bump release action, harden version-change
  regex, switch to supported gh-release action.
  • Loading branch information
agittins committed Aug 24, 2023
1 parent d58624d commit bfef766
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 40 deletions.
3 changes: 2 additions & 1 deletion .devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"files.trimTrailingWhitespace": true
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true
}
}
},
Expand Down
43 changes: 10 additions & 33 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,55 +7,32 @@ on:
release:
types: [published]

permissions: {}

jobs:
release_zip_file:
name: Prepare and upload release asset
runs-on: ubuntu-latest
permissions:
contents: write
env:
BERMUDA_ROOT_DIR: "${{ github.workspace }}/custom_components/bermuda"
steps:
- name: Check out repository
uses: actions/checkout@v1

# - name: Download Lokalise CLI
# run: |
# curl -sfL https://raw.githubusercontent.com/lokalise/lokalise-cli-2-go/master/install.sh | sh
#
# - name: Download latest translations with Lokalise
# run: |
# ./bin/lokalise2 \
# --token "${{ secrets.lokalise_token }}"\
# --project-id "260939135f7593a05f2b79.75475372" \
# file download \
# --format json \
# --unzip-to /tmp/lokalise \
# --export-empty-as skip \
# --export-sort a_z \
# --original-filenames=false \
# --bundle-structure %LANG_ISO%.%FORMAT%
#
# - name: Move downloaded translations
# run: |
# mkdir -p "${{ env.BERMUDA_ROOT_DIR }}/translations/
# cp /tmp/lokalise/* "${{ env.BERMUDA_ROOT_DIR }}/translations/"
uses: actions/checkout@v3

- name: Set release version number in files
run: |
sed -i '/VERSION = /c\VERSION = "${{ github.ref_name }}"' "${{ env.BERMUDA_ROOT_DIR }}/const.py"
sed -i '/VERSION.=./c\VERSION = "${{ github.ref_name }}"' "${{ env.BERMUDA_ROOT_DIR }}/const.py"
(jq '.version = "${{ github.ref_name }}"' "${{ env.BERMUDA_ROOT_DIR }}/manifest.json") > "${{ env.BERMUDA_ROOT_DIR }}/manifest.json.tmp"
mv "${{ env.BERMUDA_ROOT_DIR }}/manifest.json.tmp" "${{ env.BERMUDA_ROOT_DIR }}/manifest.json"
- name: Add Bermuda folder to zip archive
- name: Zip the integration directory
run: |
cd "${{ env.BERMUDA_ROOT_DIR }}"
zip bermuda.zip -r ./
- name: Upload release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: "Upload the ZIP file to the release"
uses: softprops/[email protected]
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: "${{ env.BERMUDA_ROOT_DIR }}/bermuda.zip"
asset_name: bermuda.zip
asset_content_type: application/zip
files: ${{ env.BERMUDA_ROOT_DIR }}/bermuda.zip
3 changes: 3 additions & 0 deletions custom_components/bermuda/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from homeassistant.core import SupportsResponse
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers import area_registry
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.device_registry import format_mac
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
from homeassistant.util import slugify
Expand All @@ -37,6 +38,8 @@

MONOTONIC_TIME: Final = monotonic_time_coarse

CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)

_LOGGER: logging.Logger = logging.getLogger(__package__)


Expand Down
3 changes: 2 additions & 1 deletion custom_components/bermuda/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"dependencies": ["bluetooth_adapters", "device_tracker"],
"documentation": "https://github.com/agittins/bermuda",
"iot_class": "calculated",
"integration_type": "helper",
"issue_tracker": "https://github.com/agittins/bermuda/issues",
"requirements": ["pandas"],
"requirements": [],
"version": "0.0.1"
}
1 change: 0 additions & 1 deletion hacs.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "Bermuda BLE Triangulation",
"hacs": "1.6.0",
"iot_class": "local_polling",
"homeassistant": "2022.10",
"render_readme": true
}
8 changes: 4 additions & 4 deletions tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ async def test_setup_unload_and_reload_entry(hass, bypass_get_data):
# call, no code from custom_components/bermuda/api.py actually runs.
assert await async_setup_entry(hass, config_entry)
assert DOMAIN in hass.data and config_entry.entry_id in hass.data[DOMAIN]
assert (
type(hass.data[DOMAIN][config_entry.entry_id]) == BermudaDataUpdateCoordinator
assert type(hass.data[DOMAIN][config_entry.entry_id]).isinstance(
BermudaDataUpdateCoordinator
)

# Reload the entry and assert that the data from above is still there
assert await async_reload_entry(hass, config_entry) is None
assert DOMAIN in hass.data and config_entry.entry_id in hass.data[DOMAIN]
assert (
type(hass.data[DOMAIN][config_entry.entry_id]) == BermudaDataUpdateCoordinator
assert type(hass.data[DOMAIN][config_entry.entry_id]).isinstance(
BermudaDataUpdateCoordinator
)

# Unload the entry and verify that the data has been removed
Expand Down

0 comments on commit bfef766

Please sign in to comment.