Skip to content

Commit

Permalink
chore: migrate to uv, python-semantic-release, pre-commit (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Jan 24, 2025
1 parent 6a9cb6e commit 27e4abf
Show file tree
Hide file tree
Showing 27 changed files with 2,621 additions and 1,452 deletions.
117 changes: 117 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: CI

on:
push:
branches:
- main
pull_request:

concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
- uses: pre-commit/[email protected]

# Make sure commit messages follow the conventional commits convention:
# https://www.conventionalcommits.org
commitlint:
name: Lint Commit Messages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: wagoid/[email protected]

test:
strategy:
fail-fast: false
matrix:
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
os:
- ubuntu-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
id: setup-python
with:
python-version: ${{ matrix.python-version }}
- uses: astral-sh/setup-uv@v5
- run: uv sync --no-python-downloads
shell: bash
- run: uv run pytest
shell: bash
- uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}

release:
needs:
- test
- lint
- commitlint

runs-on: ubuntu-latest
environment: release
concurrency: release
permissions:
id-token: write
attestations: write
contents: write

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.sha }}

- name: Checkout commit for release
run: |
git checkout -B ${{ github.ref_name }} ${{ github.sha }}
# Do a dry run of PSR
- name: Test release
uses: python-semantic-release/[email protected]
if: github.ref_name != 'main'
with:
root_options: --noop
github_token: noop

# On main branch: actual PSR + upload to PyPI & GitHub
- name: Release
uses: python-semantic-release/[email protected]
id: release
if: github.ref_name == 'main'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Attest build provenance
uses: actions/attest-build-provenance@v1
if: steps.release.outputs.released == 'true'
with:
subject-path: "dist/*"

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
if: steps.release.outputs.released == 'true'

- name: Publish package distributions to GitHub Releases
uses: python-semantic-release/[email protected]
if: steps.release.outputs.released == 'true'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.release.outputs.tag }}
62 changes: 62 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
exclude: "CHANGELOG.md|.copier-answers.yml|.all-contributorsrc|project"
default_stages: [pre-commit]

ci:
autofix_commit_msg: "chore(pre-commit.ci): auto fixes"
autoupdate_commit_msg: "chore(pre-commit.ci): pre-commit autoupdate"

repos:
- repo: https://github.com/commitizen-tools/commitizen
rev: v4.1.0
hooks:
- id: commitizen
stages: [commit-msg]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: debug-statements
- id: check-builtin-literals
- id: check-case-conflict
- id: check-docstring-first
- id: check-json
- id: check-toml
- id: check-xml
- id: check-yaml
- id: detect-private-key
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/tox-dev/pyproject-fmt
rev: "v2.5.0"
hooks:
- id: pyproject-fmt
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.5.18
hooks:
- id: uv-lock
- repo: https://github.com/asottile/pyupgrade
rev: v3.19.1
hooks:
- id: pyupgrade
args: [--py39-plus]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
hooks:
- id: prettier
args: ["--tab-width", "2"]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.1
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v1.14.1
# hooks:
# - id: mypy
# additional_dependencies: []
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"python.pythonPath": "venv3.7/bin/python"
}
"python.pythonPath": "venv3.7/bin/python"
}
2 changes: 1 addition & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Erik Hendrix
Erik Hendrix
5 changes: 1 addition & 4 deletions PROTOCOL.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,14 @@ with the Harmony HUB device.

The Logitech Harmony HUB connects to your home wireless network and obtains an
IP address. It runs a [Web server](https://en.wikipedia.org/wiki/Web_server) server that listens on port 8088.


## Authentication

### Obtaining Remote ID

Each Harmony HUB has a unique hub ID that has to be provided for every request. This ID can be obtained
Each Harmony HUB has a unique hub ID that has to be provided for every request. This ID can be obtained
through the discovery process for Harmony HUBs or by querying a specific HUB itself for it.



A session token is obtained by logging into the Harmony device with username `[email protected]` and password
`guest`. The login process uses the XMPP SASL PLAIN authentication standard
(XEP-0034).
Expand Down
116 changes: 0 additions & 116 deletions aioharmony/const.py

This file was deleted.

8 changes: 8 additions & 0 deletions commitlint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default {
extends: ["@commitlint/config-conventional"],
rules: {
"header-max-length": [0, "always", Infinity],
"body-max-line-length": [0, "always", Infinity],
"footer-max-line-length": [0, "always", Infinity],
},
};
Loading

0 comments on commit 27e4abf

Please sign in to comment.