-
Notifications
You must be signed in to change notification settings - Fork 12
87 lines (82 loc) · 2.72 KB
/
python-checks.yml
File metadata and controls
87 lines (82 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
---
name: Python Checks
# GHA requires bare `on:` which yamllint sees as boolean
# yamllint disable-line rule:truthy
on:
workflow_call:
env:
# Target Python version for coverage and static analysis
TARGET_PYTHON: "3.13"
# Additional Python versions to test (JSON array, can be empty: '[]')
OTHER_PYTHON_VERSIONS: '["3.14"]'
jobs:
setup:
name: Setup
runs-on: ubuntu-latest
outputs:
target-python: ${{ env.TARGET_PYTHON }}
python-versions: ${{ steps.versions.outputs.matrix }}
steps:
- name: Build version matrix
id: versions
run: |
# Combine target with other versions into a JSON array
MATRIX=$(echo '${{ env.OTHER_PYTHON_VERSIONS }}' | jq -c '. + ["${{ env.TARGET_PYTHON }}"] | unique | sort')
echo "matrix=$MATRIX" >> "$GITHUB_OUTPUT"
ruff:
name: Ruff
needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ needs.setup.outputs.target-python }}
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Install dependencies
run: uv pip install --system ruff
- name: Check formatting
run: ruff format --check .
- name: Check linting
run: ruff check .
pytest:
name: Pytest (${{ matrix.python-version }})
needs: setup
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ${{ fromJSON(needs.setup.outputs.python-versions) }}
steps:
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install libudev-dev
- name: Install dependencies
run: uv pip install --system -r requirements_dev.txt
- name: Run tests and generate coverage report
# CI-only deps installed separately to keep requirements_dev.txt lightweight
run: |
uv pip install --system pytest-cov pytest-github-actions-annotate-failures
pytest ./tests/ --cov=custom_components/lock_code_manager/ --cov-report=xml
- name: Upload coverage to Codecov
if: matrix.python-version == needs.setup.outputs.target-python
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: python
files: coverage.xml