Skip to content

Commit 27e4abf

Browse files
authored
chore: migrate to uv, python-semantic-release, pre-commit (#42)
1 parent 6a9cb6e commit 27e4abf

27 files changed

+2621
-1452
lines changed

.github/workflows/ci.yml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
concurrency:
10+
group: ${{ github.head_ref || github.run_id }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
lint:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-python@v5
19+
with:
20+
python-version: 3.x
21+
- uses: pre-commit/[email protected]
22+
23+
# Make sure commit messages follow the conventional commits convention:
24+
# https://www.conventionalcommits.org
25+
commitlint:
26+
name: Lint Commit Messages
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
32+
- uses: wagoid/[email protected]
33+
34+
test:
35+
strategy:
36+
fail-fast: false
37+
matrix:
38+
python-version:
39+
- "3.9"
40+
- "3.10"
41+
- "3.11"
42+
- "3.12"
43+
- "3.13"
44+
os:
45+
- ubuntu-latest
46+
runs-on: ${{ matrix.os }}
47+
steps:
48+
- uses: actions/checkout@v4
49+
- uses: actions/setup-python@v5
50+
id: setup-python
51+
with:
52+
python-version: ${{ matrix.python-version }}
53+
- uses: astral-sh/setup-uv@v5
54+
- run: uv sync --no-python-downloads
55+
shell: bash
56+
- run: uv run pytest
57+
shell: bash
58+
- uses: codecov/codecov-action@v5
59+
with:
60+
token: ${{ secrets.CODECOV_TOKEN }}
61+
62+
release:
63+
needs:
64+
- test
65+
- lint
66+
- commitlint
67+
68+
runs-on: ubuntu-latest
69+
environment: release
70+
concurrency: release
71+
permissions:
72+
id-token: write
73+
attestations: write
74+
contents: write
75+
76+
steps:
77+
- uses: actions/checkout@v4
78+
with:
79+
fetch-depth: 0
80+
ref: ${{ github.sha }}
81+
82+
- name: Checkout commit for release
83+
run: |
84+
git checkout -B ${{ github.ref_name }} ${{ github.sha }}
85+
86+
# Do a dry run of PSR
87+
- name: Test release
88+
uses: python-semantic-release/[email protected]
89+
if: github.ref_name != 'main'
90+
with:
91+
root_options: --noop
92+
github_token: noop
93+
94+
# On main branch: actual PSR + upload to PyPI & GitHub
95+
- name: Release
96+
uses: python-semantic-release/[email protected]
97+
id: release
98+
if: github.ref_name == 'main'
99+
with:
100+
github_token: ${{ secrets.GITHUB_TOKEN }}
101+
102+
- name: Attest build provenance
103+
uses: actions/attest-build-provenance@v1
104+
if: steps.release.outputs.released == 'true'
105+
with:
106+
subject-path: "dist/*"
107+
108+
- name: Publish package distributions to PyPI
109+
uses: pypa/gh-action-pypi-publish@release/v1
110+
if: steps.release.outputs.released == 'true'
111+
112+
- name: Publish package distributions to GitHub Releases
113+
uses: python-semantic-release/[email protected]
114+
if: steps.release.outputs.released == 'true'
115+
with:
116+
github_token: ${{ secrets.GITHUB_TOKEN }}
117+
tag: ${{ steps.release.outputs.tag }}

.pre-commit-config.yaml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
exclude: "CHANGELOG.md|.copier-answers.yml|.all-contributorsrc|project"
4+
default_stages: [pre-commit]
5+
6+
ci:
7+
autofix_commit_msg: "chore(pre-commit.ci): auto fixes"
8+
autoupdate_commit_msg: "chore(pre-commit.ci): pre-commit autoupdate"
9+
10+
repos:
11+
- repo: https://github.com/commitizen-tools/commitizen
12+
rev: v4.1.0
13+
hooks:
14+
- id: commitizen
15+
stages: [commit-msg]
16+
- repo: https://github.com/pre-commit/pre-commit-hooks
17+
rev: v5.0.0
18+
hooks:
19+
- id: debug-statements
20+
- id: check-builtin-literals
21+
- id: check-case-conflict
22+
- id: check-docstring-first
23+
- id: check-json
24+
- id: check-toml
25+
- id: check-xml
26+
- id: check-yaml
27+
- id: detect-private-key
28+
- id: end-of-file-fixer
29+
- id: trailing-whitespace
30+
- repo: https://github.com/tox-dev/pyproject-fmt
31+
rev: "v2.5.0"
32+
hooks:
33+
- id: pyproject-fmt
34+
- repo: https://github.com/astral-sh/uv-pre-commit
35+
rev: 0.5.18
36+
hooks:
37+
- id: uv-lock
38+
- repo: https://github.com/asottile/pyupgrade
39+
rev: v3.19.1
40+
hooks:
41+
- id: pyupgrade
42+
args: [--py39-plus]
43+
- repo: https://github.com/pre-commit/mirrors-prettier
44+
rev: v3.1.0
45+
hooks:
46+
- id: prettier
47+
args: ["--tab-width", "2"]
48+
- repo: https://github.com/astral-sh/ruff-pre-commit
49+
rev: v0.9.1
50+
hooks:
51+
- id: ruff
52+
args: [--fix, --exit-non-zero-on-fix]
53+
- id: ruff-format
54+
- repo: https://github.com/codespell-project/codespell
55+
rev: v2.3.0
56+
hooks:
57+
- id: codespell
58+
# - repo: https://github.com/pre-commit/mirrors-mypy
59+
# rev: v1.14.1
60+
# hooks:
61+
# - id: mypy
62+
# additional_dependencies: []

.vscode/settings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"python.pythonPath": "venv3.7/bin/python"
3-
}
2+
"python.pythonPath": "venv3.7/bin/python"
3+
}

AUTHORS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Erik Hendrix
1+
Erik Hendrix

PROTOCOL.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,14 @@ with the Harmony HUB device.
77

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

1211
## Authentication
1312

1413
### Obtaining Remote ID
1514

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

19-
20-
2118
A session token is obtained by logging into the Harmony device with username `[email protected]` and password
2219
`guest`. The login process uses the XMPP SASL PLAIN authentication standard
2320
(XEP-0034).

aioharmony/const.py

Lines changed: 0 additions & 116 deletions
This file was deleted.

commitlint.config.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default {
2+
extends: ["@commitlint/config-conventional"],
3+
rules: {
4+
"header-max-length": [0, "always", Infinity],
5+
"body-max-line-length": [0, "always", Infinity],
6+
"footer-max-line-length": [0, "always", Infinity],
7+
},
8+
};

0 commit comments

Comments
 (0)