Skip to content

Commit 5202f65

Browse files
committed
transition to uv
1 parent 743f80d commit 5202f65

19 files changed

Lines changed: 3764 additions & 1058 deletions

.github/dependabot.yml

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
version: 2
22
updates:
3-
# Enable version updates for pip
4-
- package-ecosystem: pip
5-
directory: "/"
6-
schedule:
7-
interval: daily
8-
open-pull-requests-limit: 10
3+
# Enable version updates for pip
4+
- package-ecosystem: pip
5+
directory: "/"
6+
schedule:
7+
interval: daily
8+
open-pull-requests-limit: 10
99

10-
# Maintain dependencies for GitHub Actions
11-
- package-ecosystem: "github-actions"
12-
directory: "/"
13-
schedule:
14-
interval: "weekly"
10+
- package-ecosystem: "uv"
11+
directory: "/"
12+
schedule:
13+
interval: daily
14+
open-pull-requests-limit: 10
1515

16-
# Enable version updates for Docker
17-
- package-ecosystem: "docker"
18-
# Look for a `Dockerfile` in the `root` directory
19-
directory: "/"
20-
# Check for updates once a week
21-
schedule:
22-
interval: "weekly"
16+
# Maintain dependencies for GitHub Actions
17+
- package-ecosystem: "github-actions"
18+
directory: "/"
19+
schedule:
20+
interval: "weekly"
21+
22+
# Enable version updates for Docker
23+
- package-ecosystem: "docker"
24+
# Look for a `Dockerfile` in the `root` directory
25+
directory: "/"
26+
# Check for updates once a week
27+
schedule:
28+
interval: "weekly"

.github/workflows/build-deploy.yml

Lines changed: 60 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@ name: Build and deploy
66

77
on:
88
push:
9-
branches: ["dev"]
109
tags: ["*"]
11-
pull_request:
10+
workflow_run:
11+
workflows: ["Python lint and tests"]
1212
branches: ["dev"]
13+
types:
14+
- completed
15+
- requested
1316

1417
# Cancel a currently running workflow from the same PR, branch or tag when a new workflow is triggered:
1518
# Taken from https://stackoverflow.com/a/72408109
@@ -25,24 +28,31 @@ jobs:
2528
build_docs:
2629
name: Documentation
2730
runs-on: ubuntu-latest
31+
# Only run if tests passed or if triggered by push/PR (not workflow_run)
32+
if: |
33+
github.event_name != 'workflow_run' ||
34+
github.event.workflow_run.conclusion == 'success'
2835
permissions:
2936
packages: write
37+
env:
38+
UV_LOCKED: true
39+
UV_COMPILE_BYTECODE: true
40+
UV_NO_EDITABLE: true
41+
UV_NO_PROGRESS: true
3042
steps:
3143
- name: Checkout repository
3244
uses: actions/checkout@v6
3345
# https://github.com/actions/setup-python
34-
- name: Set up Python
35-
uses: actions/setup-python@v6
46+
- name: Install uv and set the python version
47+
id: setup-uv
48+
uses: astral-sh/setup-uv@v7
3649
with:
37-
python-version: "3.12"
38-
cache: 'pip' # caching pip dependencies
39-
# Manually set 'doc-requirements.txt' as the file to use for dependencies, since `requirements.txt` contains runtime dependencies.
40-
cache-dependency-path: 'doc-requirements.txt'
41-
- name: Install dependencies
42-
run: |
43-
python -m pip install --upgrade pip
44-
pip install -r doc-requirements.txt
45-
# Invoke sphinx to build the documentation
50+
# https://docs.astral.sh/uv/guides/integration/github/#using-uv-in-github-actions
51+
# It is considered best practice to pin to a specific uv version
52+
version: "0.9.26"
53+
# https://github.com/astral-sh/setup-uv?tab=readme-ov-file#enable-caching
54+
enable-cache: true
55+
cache-dependency-glob: uv.lock
4656
- name: Build documentation
4757
# Options:
4858
# -T Display the full traceback when an unhandled exception occurs
@@ -52,7 +62,16 @@ jobs:
5262
# -D Override a configuration value set in the conf.py file
5363
# -W Turn warnings into errors. This means that the build stops at the first warning and sphinx-build exits with exit status 1
5464
# --keep-going With -W option, keep going processing when getting warnings to the end of build, and sphinx-build exits with exit status 1.
55-
run: python -m sphinx -T -E -b html -d _build/doctrees -D language=en -W --keep-going . _build/html
65+
run: >
66+
uv run
67+
--group doc
68+
python -m sphinx
69+
-T -E
70+
-b html
71+
-d _build/doctrees
72+
-D language=en
73+
-W --keep-going
74+
. _build/html
5675
working-directory: docs
5776
# Save the generated documentation as an artifact in Github
5877
- name: Upload documentation
@@ -65,27 +84,36 @@ jobs:
6584
build_package:
6685
name: Python package
6786
runs-on: ubuntu-latest
87+
# Only run if tests passed or if triggered by push/PR (not workflow_run)
88+
if: |
89+
github.event_name != 'workflow_run' ||
90+
github.event.workflow_run.conclusion == 'success'
6891
permissions:
6992
contents: read
7093
packages: write
71-
94+
env:
95+
UV_LOCKED: true
96+
UV_COMPILE_BYTECODE: true
97+
UV_NO_EDITABLE: true
98+
UV_NO_PROGRESS: true
99+
UV_NO_SYNC: true
72100
steps:
73101
- name: Checkout repository
74102
uses: actions/checkout@v6
75-
# https://github.com/actions/setup-python
76-
- name: Set up Python
77-
uses: actions/setup-python@v6
103+
- name: Install uv and set the python version
104+
id: setup-uv
105+
uses: astral-sh/setup-uv@v7
78106
with:
79-
python-version: "3.12"
80-
cache: 'pip' # caching pip dependencies
81-
# Manually set 'dev-requirements.txt' as the file to use for dependencies, since `requirements.txt` contains runtime dependencies.
82-
cache-dependency-path: 'dev-requirements.txt'
83-
- name: Install dependencies
84-
run: |
85-
python -m pip install --upgrade pip
86-
pip install -r dev-requirements.txt
107+
# https://docs.astral.sh/uv/guides/integration/github/#using-uv-in-github-actions
108+
# It is considered best practice to pin to a specific uv version
109+
version: "0.9.26"
110+
# https://github.com/astral-sh/setup-uv?tab=readme-ov-file#enable-caching
111+
enable-cache: true
112+
cache-dependency-glob: uv.lock
113+
- name: Install the project
114+
run: uv sync --dev
87115
- name: Build Python package
88-
run: python -m build
116+
run: uv build --wheel --refresh
89117
- name: Upload Python package
90118
uses: actions/upload-artifact@v6
91119
with:
@@ -103,6 +131,10 @@ jobs:
103131
name: Docker image
104132
runs-on: ubuntu-latest
105133
needs: ['build_package']
134+
# Only run if tests passed or if triggered by push/PR (not workflow_run)
135+
if: |
136+
github.event_name != 'workflow_run' ||
137+
github.event.workflow_run.conclusion == 'success'
106138
permissions:
107139
contents: read
108140
packages: write
@@ -154,6 +186,7 @@ jobs:
154186
uses: docker/build-push-action@v6.18.0
155187
with:
156188
context: .
189+
file: Dockerfile
157190
push: ${{github.event_name == 'push' && (startsWith(github.ref, 'refs/tags') || github.ref_name == 'dev') && github.repository == 'AppDaemon/appdaemon'}}
158191
tags: ${{ steps.meta.outputs.tags }}
159192
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/python-tests.yml

Lines changed: 60 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -6,69 +6,80 @@ name: Python lint and tests
66
on:
77
push:
88
pull_request:
9-
branches: ["dev"]
9+
branches: ["*"]
1010

1111
jobs:
1212
lint:
1313
runs-on: ubuntu-latest
14+
env:
15+
UV_LOCKED: true
16+
UV_COMPILE_BYTECODE: true
17+
UV_NO_EDITABLE: true
18+
UV_NO_PROGRESS: true
1419
steps:
15-
- uses: actions/checkout@v6
16-
- name: Install uv and set the python version
17-
id: setup-uv
18-
uses: astral-sh/setup-uv@v7
19-
with:
20-
version: "0.8.15" # It is considered best practice to pin to a specific uv version
21-
# https://github.com/astral-sh/setup-uv?tab=readme-ov-file#enable-caching
22-
enable-cache: true
23-
cache-dependency-glob: |
24-
**/*requirements*.txt
25-
**/pyproject.toml
26-
**/uv.lock
27-
28-
- name: Do something if the cache was restored
29-
if: steps.setup-uv.outputs.cache-hit == 'true'
30-
run: echo "Cache was restored"
31-
32-
- name: Install the project
33-
run: uv sync --all-extras --dev
34-
35-
- name: Run pre-commit hooks
36-
run: >
37-
uv run pre-commit
38-
run --all-files
39-
--show-diff-on-failure --color=always
20+
- name: Checkout repository
21+
uses: actions/checkout@v6
22+
- name: Install uv and set the python version
23+
id: setup-uv
24+
uses: astral-sh/setup-uv@v7
25+
with:
26+
# https://docs.astral.sh/uv/guides/integration/github/#using-uv-in-github-actions
27+
# It is considered best practice to pin to a specific uv version
28+
version: "0.9.26"
29+
# https://github.com/astral-sh/setup-uv?tab=readme-ov-file#enable-caching
30+
enable-cache: true
31+
cache-dependency-glob: uv.lock
32+
- name: Do something if the cache was restored
33+
if: steps.setup-uv.outputs.cache-hit == 'true'
34+
run: echo "uv cache was restored"
35+
- uses: actions/cache@v4
36+
id: pre-commit-cache
37+
with:
38+
path: ~/.cache/pre-commit
39+
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}-${{ hashFiles('uv.lock') }}
40+
- name: Do something if the cache was restored
41+
if: steps.pre-commit-cache.outputs.cache-hit == 'true'
42+
run: echo "pre-commit cache was restored"
43+
- name: Run pre-commit hooks
44+
run: >
45+
uv run
46+
--verbose
47+
pre-commit run
48+
--all-files
49+
--show-diff-on-failure --color=always
4050
4151
test:
4252
needs: lint
4353
runs-on: ubuntu-latest
54+
env:
55+
UV_LOCKED: true
56+
UV_COMPILE_BYTECODE: true
57+
UV_NO_EDITABLE: true
58+
UV_NO_PROGRESS: true
4459
strategy:
4560
fail-fast: false
4661
matrix:
4762
python-version: ["3.10", "3.11", "3.12", "3.13"]
4863

4964
steps:
50-
- uses: actions/checkout@v6
51-
- name: Install uv and set the python version
52-
id: setup-uv
53-
uses: astral-sh/setup-uv@v7
54-
with:
55-
# https://docs.astral.sh/uv/guides/integration/github/#multiple-python-versions
56-
python-version: ${{ matrix.python-version }}
57-
version: "0.8.15" # It is considered best practice to pin to a specific uv version
58-
# https://github.com/astral-sh/setup-uv?tab=readme-ov-file#enable-caching
59-
enable-cache: true
60-
cache-dependency-glob: |
61-
**/*requirements*.txt
62-
**/pyproject.toml
63-
**/uv.lock
64-
65-
- name: Do something if the cache was restored
66-
if: steps.setup-uv.outputs.cache-hit == 'true'
67-
run: echo "Cache was restored"
65+
- name: Checkout repository
66+
uses: actions/checkout@v6
67+
- name: Install uv and set the python version
68+
id: setup-uv
69+
uses: astral-sh/setup-uv@v7
70+
with:
71+
python-version: ${{ matrix.python-version }}
72+
# https://docs.astral.sh/uv/guides/integration/github/#using-uv-in-github-actions
73+
# It is considered best practice to pin to a specific uv version
74+
version: "0.9.26"
75+
# https://github.com/astral-sh/setup-uv?tab=readme-ov-file#enable-caching
76+
enable-cache: true
77+
cache-dependency-glob: uv.lock
6878

69-
- name: Install the project
70-
run: uv sync --all-extras --dev
79+
- name: Do something if the cache was restored
80+
if: steps.setup-uv.outputs.cache-hit == 'true'
81+
run: echo "Cache was restored"
7182

72-
- name: Run tests
73-
# For example, using `pytest`
74-
run: uv run pytest -m ci
83+
- name: Run tests
84+
# For example, using `pytest`
85+
run: uv run --verbose pytest -m ci

.github/workflows/stale-issues.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
stale-issue-message: 'This issue is stale because it has been open for 45 days with no activity. Remove stale label or comment or this will be closed in 15 days.'
2929
close-issue-message: 'Please feel free re-open this issue if you have new information available'
3030
days-before-stale: 45
31-
days-before-close: 15
31+
# days-before-close: 15
3232
any-of-labels: "question,docs_needed"
3333
stale-issue-label: "stale"
3434
debug-only: "${{ env.DRY_RUN }}"
@@ -43,7 +43,7 @@ jobs:
4343
stale-issue-message: 'This issue is stale because it has been open for 6 months with no activity. Remove stale label or comment or this will be closed in 15 days.'
4444
close-issue-message: 'Please feel free re-open this issue if you have new information available'
4545
days-before-stale: 180
46-
days-before-close: 15
46+
# days-before-close: 15
4747
exempt-issue-labels: "bug,enhancement,documentation,question,docs_needed,work_in_progress"
4848
stale-issue-label: "stale"
4949
debug-only: "${{ env.DRY_RUN }}"

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ target/
6666
# Python
6767
venv
6868
.venv
69-
uv.lock
7069
*.ipynb
7170

7271
# Mac stuff

.pre-commit-config.yaml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v5.0.0
3+
rev: v6.0.0
44
hooks:
55
- id: end-of-file-fixer
66
- id: trailing-whitespace
7-
- repo: https://github.com/charliermarsh/ruff-pre-commit
8-
rev: 'v0.6.4'
7+
- repo: https://github.com/astral-sh/ruff-pre-commit
8+
rev: v0.14.13
99
hooks:
10-
- id: ruff
11-
args: [--fix, --exit-non-zero-on-fix]
10+
- id: ruff-check
11+
types_or: [ python, pyi ]
12+
args: [--fix-only, --exit-non-zero-on-fix]
13+
# - id: ruff-format
14+
# types_or: [ python, pyi ]
1215
- repo: https://github.com/codespell-project/codespell
1316
# Configuration for codespell is in pyproject.toml
1417
rev: v2.4.1
1518
hooks:
1619
- id: codespell
1720
additional_dependencies:
1821
- tomli
22+
- repo: https://github.com/astral-sh/uv-pre-commit
23+
# uv version.
24+
rev: 0.9.26
25+
hooks:
26+
# Update the uv lockfile
27+
- id: uv-lock

0 commit comments

Comments
 (0)