Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

Commit

Permalink
Code quality improvements (#195)
Browse files Browse the repository at this point in the history
* add pre-commit

* fix pre-commit found issues

* fix pylint issues

* use one workflow to run checks

* fix found issue

* add dependabot and codeql

* fix ci

* update lib to 3.0.0b1
  • Loading branch information
edenhaus authored Oct 2, 2021
1 parent 073a7d7 commit bdad4e6
Show file tree
Hide file tree
Showing 51 changed files with 1,244 additions and 748 deletions.
18 changes: 9 additions & 9 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ In the container you will have a dedicated Home Assistant core instance running

- [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
- Docker
- For Linux, macOS, or Windows 10 Pro/Enterprise/Education use the [current release version of Docker](https://docs.docker.com/install/)
- Windows 10 Home requires [WSL 2](https://docs.microsoft.com/windows/wsl/wsl2-install) and the current Edge version of Docker Desktop (see instructions [here](https://docs.docker.com/docker-for-windows/wsl-tech-preview/)). This can also be used for Windows Pro/Enterprise/Education.
- For Linux, macOS, or Windows 10 Pro/Enterprise/Education use the [current release version of Docker](https://docs.docker.com/install/)
- Windows 10 Home requires [WSL 2](https://docs.microsoft.com/windows/wsl/wsl2-install) and the current Edge version of Docker Desktop (see instructions [here](https://docs.docker.com/docker-for-windows/wsl-tech-preview/)). This can also be used for Windows Pro/Enterprise/Education.
- [Visual Studio code](https://code.visualstudio.com/)
- [Remote - Containers (VSC Extension)][extension-link]

Expand All @@ -35,12 +35,12 @@ When a task is currently running (like `Run Home Assistant on port 9123` for the

The available tasks are:

Task | Description
-- | --
Run Home Assistant on port 9123 | Launch Home Assistant with your custom component code and the configuration defined in `.devcontainer/configuration.yaml`.
Run Home Assistant configuration against /config | Check the configuration.
Upgrade Home Assistant to latest dev | Upgrade the Home Assistant core version in the container to the latest version of the `dev` branch.
Install a specific version of Home Assistant | Install a specific version of Home Assistant core in the container.
| Task | Description |
| ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------- |
| Run Home Assistant on port 9123 | Launch Home Assistant with your custom component code and the configuration defined in `.devcontainer/configuration.yaml`. |
| Run Home Assistant configuration against /config | Check the configuration. |
| Upgrade Home Assistant to latest dev | Upgrade the Home Assistant core version in the container to the latest version of the `dev` branch. |
| Install a specific version of Home Assistant | Install a specific version of Home Assistant core in the container. |

### Step by Step debugging

Expand All @@ -54,7 +54,7 @@ by uncommenting the line:
# debugpy:
```

Then launch the task `Run Home Assistant on port 9123`, and launch the debbuger
Then launch the task `Run Home Assistant on port 9123`, and launch the debugger
with the existing debugging configuration `Python: Attach Local`.

For more information, look at [the Remote Python Debugger integration documentation](https://www.home-assistant.io/integrations/debugpy/).
22 changes: 11 additions & 11 deletions .devcontainer/configuration.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
default_config:

logger:
default: info
logs:
custom_components.deebot: debug
deebotozmo: debug
components.vacuum.deebotozmo: debug

# If you need to debug uncommment the line below (doc: https://www.home-assistant.io/integrations/debugpy/)
debugpy:
default_config:

logger:
default: info
logs:
custom_components.deebot: debug
deebotozmo: debug
components.vacuum.deebotozmo: debug

# If you need to debug uncomment the line below (doc: https://www.home-assistant.io/integrations/debugpy/)
debugpy:
58 changes: 28 additions & 30 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
// See https://aka.ms/vscode-remote/devcontainer.json for format details.
{
"image": "ludeeus/container:integration-debian",
"name": "Blueprint integration development",
"context": "..",
"appPort": [
"9123:8123"
],
"postCreateCommand": "container install",
"extensions": [
"ms-python.python",
"github.vscode-pull-request-github",
"ryanluker.vscode-coverage-gutters",
"ms-python.vscode-pylance"
],
"settings": {
"files.eol": "\n",
"editor.tabSize": 4,
"terminal.integrated.shell.linux": "/bin/bash",
"python.pythonPath": "/usr/bin/python3",
"python.analysis.autoSearchPaths": false,
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"python.formatting.provider": "black",
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"files.trimTrailingWhitespace": true
}
}
// See https://aka.ms/vscode-remote/devcontainer.json for format details.
{
"image": "ludeeus/container:integration-debian",
"name": "Blueprint integration development",
"context": "..",
"appPort": ["9123:8123"],
"postCreateCommand": "container install",
"extensions": [
"ms-python.python",
"github.vscode-pull-request-github",
"ryanluker.vscode-coverage-gutters",
"ms-python.vscode-pylance"
],
"settings": {
"files.eol": "\n",
"editor.tabSize": 4,
"terminal.integrated.shell.linux": "/bin/bash",
"python.pythonPath": "/usr/bin/python3",
"python.analysis.autoSearchPaths": false,
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"python.formatting.provider": "black",
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"files.trimTrailingWhitespace": true
}
}
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ body:
label: Is there an existing issue for this?
description: Please search to see if an issue already exists for the bug you encountered.
options:
- label: I have searched the existing issues and no issue is describing my issue
required: true
- label: I have searched the existing issues and no issue is describing my issue
required: true

- type: textarea
validations:
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
blank_issues_enabled: false
blank_issues_enabled: false
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ body:
label: Is there an existing issue for this?
description: Please search to see if an issue already exists for your feature request or idea
options:
- label: I have searched the existing issues and no issue is describing my feature request or idea
required: true
- label: I have searched the existing issues and no issue is describing my feature request or idea
required: true

- type: textarea
attributes:
Expand Down
17 changes: 17 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
labels:
- "pr: dependency-update"
schedule:
interval: "daily"

# Maintain dependencies for pip
- package-ecosystem: "pip"
directory: "/"
labels:
- "pr: dependency-update"
schedule:
interval: "daily"
51 changes: 51 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name-template: "$RESOLVED_VERSION"
tag-template: "$RESOLVED_VERSION"
change-template: "- #$NUMBER $TITLE @$AUTHOR"
sort-direction: ascending
prerelease: true
categories:
- title: ":boom: Breaking changes"
label: "Breaking Change"

- title: ":sparkles: New features"
label: "pr: new-feature"

- title: ":zap: Enhancements"
label: "pr: enhancement"

- title: ":recycle: Refactor"
label: "pr: refactor"

- title: ":bug: Bug Fixes"
label: "pr: bugfix"

- title: ":arrow_up: Dependency Updates"
labels:
- "pr: dependency-update"
- "dependencies"

include-labels:
- "Breaking Change"
- "pr: enhancement"
- "pr: dependency-update"
- "pr: new-feature"
- "pr: bugfix"
- "pr: refactor"

version-resolver:
major:
labels:
- "Breaking Change"
minor:
labels:
- "pr: enhancement"
- "pr: dependency-update"
- "pr: new-feature"
patch:
labels:
- "pr: bugfix"
default: minor

template: |
[![Downloads for this release](https://img.shields.io/github/downloads/And3rsL/Deebotozmo/$RESOLVED_VERSION/total.svg)](https://github.com/And3rsL/Deebotozmo/releases/$RESOLVED_VERSION)
$CHANGES
49 changes: 49 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: CI

on:
push:
branches:
- master
pull_request: ~

env:
DEFAULT_PYTHON: 3.9

jobs:
validate:
runs-on: "ubuntu-latest"
name: Validate
steps:
- uses: "actions/checkout@v2"

- name: HACS validation
uses: "hacs/action@main"
with:
category: "integration"
ignore: brands

- name: Hassfest validation
uses: "home-assistant/actions/hassfest@master"

code-quality:
runs-on: "ubuntu-latest"
name: Check code quality
steps:
- uses: "actions/checkout@v2"
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/[email protected]
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Install dependencies
run: |
pip install -r requirements.txt
- name: Run pre-commit checks
run: |
pre-commit run --hook-stage manual --all-files --show-diff-on-failure
- name: Pylint review
run: |
pylint custom_components
73 changes: 73 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches:
- master
pull_request:
# The branches below must be a subset of the branches above
branches:
- master
schedule:
- cron: "20 10 * * 0"

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: ["python"]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# 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@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

# - run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
18 changes: 9 additions & 9 deletions .github/workflows/cron.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ name: Cron actions

on:
schedule:
- cron: '0 0 * * *'
- cron: "0 0 * * *"

jobs:
validate:
runs-on: "ubuntu-latest"
name: Validate
steps:
- uses: "actions/checkout@v2"
- uses: "actions/checkout@v2"

- name: HACS validation
uses: "hacs/action@main"
with:
category: "integration"
ignore: brands
- name: HACS validation
uses: "hacs/action@main"
with:
category: "integration"
ignore: brands

- name: Hassfest validation
uses: "home-assistant/actions/hassfest@master"
- name: Hassfest validation
uses: "home-assistant/actions/hassfest@master"
Loading

0 comments on commit bdad4e6

Please sign in to comment.