Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 24 additions & 18 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
version: 2
updates:
# Enable version updates for pip
- package-ecosystem: pip
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
# Enable version updates for pip
- package-ecosystem: pip
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10

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

# Enable version updates for Docker
- package-ecosystem: "docker"
# Look for a `Dockerfile` in the `root` directory
directory: "/"
# Check for updates once a week
schedule:
interval: "weekly"
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"

# Enable version updates for Docker
- package-ecosystem: "docker"
# Look for a `Dockerfile` in the `root` directory
directory: "/"
# Check for updates once a week
schedule:
interval: "weekly"
87 changes: 60 additions & 27 deletions .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ name: Build and deploy

on:
push:
branches: ["dev"]
tags: ["*"]
pull_request:
workflow_run:
workflows: ["Python lint and tests"]
branches: ["dev"]
types:
- completed
- requested

# Cancel a currently running workflow from the same PR, branch or tag when a new workflow is triggered:
# Taken from https://stackoverflow.com/a/72408109
Expand All @@ -25,24 +28,31 @@ jobs:
build_docs:
name: Documentation
runs-on: ubuntu-latest
# Only run if tests passed or if triggered by push/PR (not workflow_run)
if: |
github.event_name != 'workflow_run' ||
github.event.workflow_run.conclusion == 'success'
permissions:
packages: write
env:
UV_LOCKED: true
UV_COMPILE_BYTECODE: true
UV_NO_EDITABLE: true
UV_NO_PROGRESS: true
steps:
- name: Checkout repository
uses: actions/checkout@v5
# https://github.com/actions/setup-python
- name: Set up Python
uses: actions/setup-python@v6
- name: Install uv and set the python version
id: setup-uv
uses: astral-sh/setup-uv@v6
with:
python-version: "3.12"
cache: 'pip' # caching pip dependencies
# Manually set 'doc-requirements.txt' as the file to use for dependencies, since `requirements.txt` contains runtime dependencies.
cache-dependency-path: 'doc-requirements.txt'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r doc-requirements.txt
# Invoke sphinx to build the documentation
# https://docs.astral.sh/uv/guides/integration/github/#using-uv-in-github-actions
# It is considered best practice to pin to a specific uv version
version: "0.9.5"
# https://github.com/astral-sh/setup-uv?tab=readme-ov-file#enable-caching
enable-cache: true
cache-dependency-glob: uv.lock
- name: Build documentation
# Options:
# -T Display the full traceback when an unhandled exception occurs
Expand All @@ -52,7 +62,16 @@ jobs:
# -D Override a configuration value set in the conf.py file
# -W Turn warnings into errors. This means that the build stops at the first warning and sphinx-build exits with exit status 1
# --keep-going With -W option, keep going processing when getting warnings to the end of build, and sphinx-build exits with exit status 1.
run: python -m sphinx -T -E -b html -d _build/doctrees -D language=en -W --keep-going . _build/html
run: >
uv run
--group doc
python -m sphinx
-T -E
-b html
-d _build/doctrees
-D language=en
-W --keep-going
. _build/html
working-directory: docs
# Save the generated documentation as an artifact in Github
- name: Upload documentation
Expand All @@ -65,27 +84,36 @@ jobs:
build_package:
name: Python package
runs-on: ubuntu-latest
# Only run if tests passed or if triggered by push/PR (not workflow_run)
if: |
github.event_name != 'workflow_run' ||
github.event.workflow_run.conclusion == 'success'
permissions:
contents: read
packages: write

env:
UV_LOCKED: true
UV_COMPILE_BYTECODE: true
UV_NO_EDITABLE: true
UV_NO_PROGRESS: true
UV_NO_SYNC: true
steps:
- name: Checkout repository
uses: actions/checkout@v5
# https://github.com/actions/setup-python
- name: Set up Python
uses: actions/setup-python@v6
- name: Install uv and set the python version
id: setup-uv
uses: astral-sh/setup-uv@v6
with:
python-version: "3.12"
cache: 'pip' # caching pip dependencies
# Manually set 'dev-requirements.txt' as the file to use for dependencies, since `requirements.txt` contains runtime dependencies.
cache-dependency-path: 'dev-requirements.txt'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r dev-requirements.txt
# https://docs.astral.sh/uv/guides/integration/github/#using-uv-in-github-actions
# It is considered best practice to pin to a specific uv version
version: "0.9.5"
# https://github.com/astral-sh/setup-uv?tab=readme-ov-file#enable-caching
enable-cache: true
cache-dependency-glob: uv.lock
- name: Install the project
run: uv sync --dev
- name: Build Python package
run: python -m build
run: uv build --wheel --refresh
- name: Upload Python package
uses: actions/upload-artifact@v5
with:
Expand All @@ -103,6 +131,10 @@ jobs:
name: Docker image
runs-on: ubuntu-latest
needs: ['build_package']
# Only run if tests passed or if triggered by push/PR (not workflow_run)
if: |
github.event_name != 'workflow_run' ||
github.event.workflow_run.conclusion == 'success'
permissions:
contents: read
packages: write
Expand Down Expand Up @@ -154,6 +186,7 @@ jobs:
uses: docker/[email protected]
with:
context: .
file: Dockerfile
push: ${{github.event_name == 'push' && (startsWith(github.ref, 'refs/tags') || github.ref_name == 'dev') && github.repository == 'AppDaemon/appdaemon'}}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Expand Down
109 changes: 60 additions & 49 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,69 +6,80 @@ name: Python lint and tests
on:
push:
pull_request:
branches: ["dev"]
branches: ["*"]

jobs:
lint:
runs-on: ubuntu-latest
env:
UV_LOCKED: true
UV_COMPILE_BYTECODE: true
UV_NO_EDITABLE: true
UV_NO_PROGRESS: true
steps:
- uses: actions/checkout@v5
- name: Install uv and set the python version
id: setup-uv
uses: astral-sh/setup-uv@v7
with:
version: "0.8.15" # It is considered best practice to pin to a specific uv version
# https://github.com/astral-sh/setup-uv?tab=readme-ov-file#enable-caching
enable-cache: true
cache-dependency-glob: |
**/*requirements*.txt
**/pyproject.toml
**/uv.lock

- name: Do something if the cache was restored
if: steps.setup-uv.outputs.cache-hit == 'true'
run: echo "Cache was restored"

- name: Install the project
run: uv sync --all-extras --dev

- name: Run pre-commit hooks
run: >
uv run pre-commit
run --all-files
--show-diff-on-failure --color=always
- name: Checkout repository
uses: actions/checkout@v5
- name: Install uv and set the python version
id: setup-uv
uses: astral-sh/setup-uv@v7
with:
# https://docs.astral.sh/uv/guides/integration/github/#using-uv-in-github-actions
# It is considered best practice to pin to a specific uv version
version: "0.9.5"
# https://github.com/astral-sh/setup-uv?tab=readme-ov-file#enable-caching
enable-cache: true
cache-dependency-glob: uv.lock
- name: Do something if the cache was restored
if: steps.setup-uv.outputs.cache-hit == 'true'
run: echo "uv cache was restored"
- uses: actions/cache@v4
id: pre-commit-cache
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}-${{ hashFiles('uv.lock') }}
- name: Do something if the cache was restored
if: steps.pre-commit-cache.outputs.cache-hit == 'true'
run: echo "pre-commit cache was restored"
- name: Run pre-commit hooks
run: >
uv run
--verbose
pre-commit run
--all-files
--show-diff-on-failure --color=always

test:
needs: lint
runs-on: ubuntu-latest
env:
UV_LOCKED: true
UV_COMPILE_BYTECODE: true
UV_NO_EDITABLE: true
UV_NO_PROGRESS: true
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v5
- name: Install uv and set the python version
id: setup-uv
uses: astral-sh/setup-uv@v7
with:
# https://docs.astral.sh/uv/guides/integration/github/#multiple-python-versions
python-version: ${{ matrix.python-version }}
version: "0.8.15" # It is considered best practice to pin to a specific uv version
# https://github.com/astral-sh/setup-uv?tab=readme-ov-file#enable-caching
enable-cache: true
cache-dependency-glob: |
**/*requirements*.txt
**/pyproject.toml
**/uv.lock

- name: Do something if the cache was restored
if: steps.setup-uv.outputs.cache-hit == 'true'
run: echo "Cache was restored"
- name: Checkout repository
uses: actions/checkout@v5
- name: Install uv and set the python version
id: setup-uv
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
# https://docs.astral.sh/uv/guides/integration/github/#using-uv-in-github-actions
# It is considered best practice to pin to a specific uv version
version: "0.9.5"
# https://github.com/astral-sh/setup-uv?tab=readme-ov-file#enable-caching
enable-cache: true
cache-dependency-glob: uv.lock

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

- name: Run tests
# For example, using `pytest`
run: uv run pytest -m ci
- name: Run tests
# For example, using `pytest`
run: uv run --verbose pytest -m ci
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ target/
# Python
venv
.venv
uv.lock
*.ipynb

# Mac stuff
Expand Down
19 changes: 14 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: v6.0.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.6.4'
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.5
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-check
types_or: [ python, pyi ]
args: [--fix-only, --exit-non-zero-on-fix]
# - id: ruff-format
# types_or: [ python, pyi ]
- repo: https://github.com/codespell-project/codespell
# Configuration for codespell is in pyproject.toml
rev: v2.4.1
hooks:
- id: codespell
additional_dependencies:
- tomli
- repo: https://github.com/astral-sh/uv-pre-commit
# uv version.
rev: 0.9.9
hooks:
# Update the uv lockfile
- id: uv-lock
Loading