Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Major update for version 2.0.0 #55

Merged
merged 12 commits into from
Mar 20, 2024
Merged
43 changes: 43 additions & 0 deletions .devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "mariusz-ostoja-swierczynski/tech-controllers",
"image": "mcr.microsoft.com/devcontainers/python:3.12-bookworm",
"postCreateCommand": "scripts/setup",
"forwardPorts": [
8123
],
"portsAttributes": {
"8123": {
"label": "Home Assistant",
"onAutoForward": "notify"
}
},
"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"charliermarsh.ruff",
"esbenp.prettier-vscode",
"github.vscode-pull-request-github",
"ryanluker.vscode-coverage-gutters",
"ms-python.vscode-pylance",
"ms-python.pylint"
],
"settings": {
"files.eol": "\n",
"editor.tabSize": 4,
"python.pythonPath": "/usr/bin/python3",
"python.analysis.autoSearchPaths": false,
"python.formatting.provider": "black",
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"files.trimTrailingWhitespace": true
}
}
},
"remoteUser": "vscode",
"features": {
"ghcr.io/devcontainers/features/rust:1": {}
}
}
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
* text=auto
# Declare files that will always have LF line endings on checkout.
*.yml text eol=lf
*.yaml text eol=lf
scripts/* text eol=lf
.yamllint text eol=lf
49 changes: 49 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name-template: 'v$RESOLVED_VERSION 🌈'
tag-template: 'v$RESOLVED_VERSION'
change-template: '- #$NUMBER $TITLE @$AUTHOR'
sort-direction: ascending
exclude-contributors:
- 'github-actions[bot]'
- 'github-actions'
- 'renovate[bot]'
- 'renovate'
exclude-labels:
- 'skip-changelog'
- 'dependencies'
categories:
- title: '🚀 Features'
labels:
- 'feature'
- 'enhancement'
- title: '🐛 Bug Fixes'
labels:
- 'fix'
- 'bugfix'
- 'bug'
- title: '🧰 Maintenance'
label: 'chore'
version-resolver:
major:
labels:
- 'major'
minor:
labels:
- 'minor'
patch:
labels:
- 'patch'
default: patch
template: |
## Changes

$CHANGES

$CONTRIBUTORS
autolabeler:
- label: 'bug'
branch:
- '/fix\/.+/'
- label: 'enhancement'
branch:
- '/feature\/.+/'
- '/feat\/.+/'
28 changes: 28 additions & 0 deletions .github/scripts/update_hacs_manifest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""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/tech/manifest.json",
) as manifestfile:
manifest = json.load(manifestfile)

manifest["version"] = version

with open(
f"{os.getcwd()}/custom_components/tech/manifest.json",
"w",
) as manifestfile:
manifestfile.write(json.dumps(manifest, indent=4, sort_keys=True))


update_manifest()
27 changes: 27 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Release Drafter

on:
push:
branches:
- main
pull_request:
types: [opened, reopened, synchronize]

jobs:
update_release_draft:
name: Update release draft
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create Release
uses: release-drafter/release-drafter@v6
with:
disable-releaser: github.ref != 'refs/heads/main'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28 changes: 28 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Release

on:
release:
types: [published]

jobs:
release_zip_file:
name: Prepare release asset
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: "Set manifest version number"
run: |
python3 ${{ github.workspace }}/.github/scripts/update_hacs_manifest.py --version ${{ github.ref_name }}
- name: Create zip
run: |
cd custom_components/tech
zip tech.zip -r ./
- name: Upload zip to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./custom_components/tech/tech.zip
asset_name: tech.zip
tag: ${{ github.ref }}
overwrite: true
23 changes: 23 additions & 0 deletions .github/workflows/validate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Validate

on:
push:
pull_request:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:

jobs:
validate-hassfest:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v4"
- uses: home-assistant/actions/hassfest@master
validate-hacs:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v4"
- name: HACS validation
uses: "hacs/action@main"
with:
category: "integration"
20 changes: 19 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
__pycache__/
# artifacts
__pycache__
.pytest*
*.egg-info
*/build/*
*/dist/*
.ruff_cache


# misc
.coverage
coverage.xml


# Home Assistant configuration
config/*
!config/configuration.yaml

homeassistant/*
3 changes: 3 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"MD013": false
}
1 change: 1 addition & 0 deletions .markdownlintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.github
19 changes: 19 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.2.2
hooks:
# Run the linter.
- id: ruff
args: [--fix]
pass_filenames: false
# Run the formatter.
- id: ruff-format
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.35.1
hooks:
- id: yamllint
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.39.0
hooks:
- id: markdownlint
7 changes: 7 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"recommendations": [
"charliermarsh.ruff",
"esbenp.prettier-vscode",
"ms-python.python"
]
}
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"files.associations": {
"config/*.yaml": "home-assistant"
}
}
17 changes: 17 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Run Home Assistant on port 8123",
"type": "shell",
"command": "scripts/develop",
"problemMatcher": []
},
{
"label": "Run pre-commit checks",
"type": "shell",
"command": "pre-commit run --all-files",
"group": "test"
},
]
}
66 changes: 66 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
ignore: |
azure-*.yml
tests/fixtures/core/config/yaml_errors/
rules:
braces:
level: error
min-spaces-inside: 0
max-spaces-inside: 1
min-spaces-inside-empty: -1
max-spaces-inside-empty: -1
brackets:
level: error
min-spaces-inside: 0
max-spaces-inside: 0
min-spaces-inside-empty: -1
max-spaces-inside-empty: -1
colons:
level: error
max-spaces-before: 0
max-spaces-after: 1
commas:
level: error
max-spaces-before: 0
min-spaces-after: 1
max-spaces-after: 1
comments:
level: error
require-starting-space: true
min-spaces-from-content: 1
comments-indentation:
level: error
document-end:
level: error
present: false
document-start:
level: error
present: false
empty-lines:
level: error
max: 1
max-start: 0
max-end: 1
hyphens:
level: error
max-spaces-after: 1
indentation:
level: error
spaces: 2
indent-sequences: true
check-multi-line-strings: false
key-duplicates:
level: error
line-length: disable
new-line-at-end-of-file:
level: error
new-lines:
level: error
type: unix
trailing-spaces:
level: error
truthy:
level: error
allowed-values: ['true', 'false']
check-keys: true
ignore: |
.github/workflows
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# MIT License

Copyright (c) 2024 Mariusz Ostoja-Swierczynski

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading
Loading