Repository navigation
123 lines (102 loc) · 4.39 KB
/
Copy pathpull_request.yml
File metadata and controls
123 lines (102 loc) · 4.39 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
name: CI/CQ
on:
# push is limited to master: a push to a PR branch already fires
# pull_request, and an unrestricted push would run the suite twice.
push:
branches: ["master"]
pull_request:
types: ["opened", "synchronize", "reopened"]
workflow_dispatch:
env:
# The oldest core this job is willing to call a valid run, and the minimum
# hacs.json declares: an older core is one the suite has never run against,
# so it is not one to promise. Raise both together. It is also a tripwire -
# see the "Report and check the resolved core" step.
MINIMUM_CORE: "2026.9.3"
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
codechecks:
name: Code Quality
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
matrix:
# Home Assistant dropped Python 3.12 after 2025.1.4; 2025.2.0+ need
# >=3.13 and 2026.3.0+ need >=3.14.2. On 3.11 pip could still satisfy
# .[dev] - by backtracking all the way to core 2024.3.3 - so the suite
# was green against a core hacs.json (then 2026.1.0) did not even allow.
python-version: ["3.14"]
steps:
- name: Install xmllint
run: sudo apt-get update && sudo apt-get -y install libxml2-utils
- name: Checkout Repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set Up Python-${{ matrix.python-version }}
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: ${{ matrix.python-version }}
- name: Pre Commit Checks
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
- name: Install Dependencies
run: pip install .[dev]
- name: Report and check the resolved core
run: |
# pyproject.toml pins no homeassistant, and homeassistant-stubs (in
# .[dev]) pins an *exact* one. So the core under test is chosen by the
# resolver, not by this repo, and it can move without a commit. Print
# it so every run says which core it tested, and fail if the resolver
# has quietly walked backwards to an older one instead of erroring out.
python - <<'PY'
import os
import sys
from importlib.metadata import requires, version
from packaging.requirements import Requirement
from packaging.version import Version
core = version("homeassistant")
stubs = version("homeassistant-stubs")
floor = os.environ["MINIMUM_CORE"]
print(f"python = {sys.version.split()[0]}")
print(f"homeassistant = {core}")
print(f"homeassistant-stubs = {stubs}")
print(f"minimum core = {floor}")
failures = []
if Version(core) < Version(floor):
failures.append(
f"homeassistant {core} is older than the required {floor}. The "
"resolver backtracked instead of failing - usually because the "
"interpreter is too old for the current core, which makes an "
"unsatisfiable pin look like a satisfiable older one."
)
# The exact pin is the mechanism behind that backtracking, so name it
# rather than leaving a mismatch to be puzzled out from two versions.
pinned = [
Requirement(r)
for r in (requires("homeassistant-stubs") or [])
if Requirement(r).name == "homeassistant"
]
for requirement in pinned:
if not requirement.specifier.contains(core, prereleases=True):
failures.append(
f"homeassistant-stubs {stubs} pins "
f"homeassistant{requirement.specifier}, but {core} is installed."
)
if failures:
print()
for failure in failures:
print(f"error: {failure}")
raise SystemExit(1)
print("\nok: testing against the current core.")
PY
- name: Collect Tests
run: pytest --collect-only tests
- name: Run Tests
run: pytest -sv tests/
- name: Analysis (git diff)
if: failure()
run: git diff