Skip to content

Commit d9dbdd6

Browse files
committed
Merge branch 'dev' of https://github.com/esphome/esphome into dev
2 parents 47f387c + 16bb818 commit d9dbdd6

File tree

782 files changed

+31087
-11329
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

782 files changed

+31087
-11329
lines changed

.clang-tidy.hash

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
a3cdfc378d28b53b416a1d5bf0ab9077ee18867f0d39436ea8013cf5a4ead87a

.github/actions/restore-python/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ runs:
4141
shell: bash
4242
run: |
4343
python -m venv venv
44-
./venv/Scripts/activate
44+
source ./venv/Scripts/activate
4545
python --version
4646
pip install -r requirements.txt -r requirements_test.txt
4747
pip install -e .
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Clang-tidy Hash CI
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- ".clang-tidy"
7+
- "platformio.ini"
8+
- "requirements_dev.txt"
9+
- ".clang-tidy.hash"
10+
- "script/clang_tidy_hash.py"
11+
- ".github/workflows/ci-clang-tidy-hash.yml"
12+
13+
permissions:
14+
contents: read
15+
pull-requests: write
16+
17+
jobs:
18+
verify-hash:
19+
name: Verify clang-tidy hash
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4.2.2
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v5.6.0
27+
with:
28+
python-version: "3.11"
29+
30+
- name: Verify hash
31+
run: |
32+
python script/clang_tidy_hash.py --verify
33+
34+
- if: failure()
35+
name: Show hash details
36+
run: |
37+
python script/clang_tidy_hash.py
38+
echo "## Job Failed" | tee -a $GITHUB_STEP_SUMMARY
39+
echo "You have modified clang-tidy configuration but have not updated the hash." | tee -a $GITHUB_STEP_SUMMARY
40+
echo "Please run 'script/clang_tidy_hash.py --update' and commit the changes." | tee -a $GITHUB_STEP_SUMMARY
41+
42+
- if: failure()
43+
name: Request changes
44+
uses: actions/github-script@v7.0.1
45+
with:
46+
script: |
47+
await github.rest.pulls.createReview({
48+
pull_number: context.issue.number,
49+
owner: context.repo.owner,
50+
repo: context.repo.repo,
51+
event: 'REQUEST_CHANGES',
52+
body: 'You have modified clang-tidy configuration but have not updated the hash.\nPlease run `script/clang_tidy_hash.py --update` and commit the changes.'
53+
})
54+
55+
- if: success()
56+
name: Dismiss review
57+
uses: actions/github-script@v7.0.1
58+
with:
59+
script: |
60+
let reviews = await github.rest.pulls.listReviews({
61+
pull_number: context.issue.number,
62+
owner: context.repo.owner,
63+
repo: context.repo.repo
64+
});
65+
for (let review of reviews.data) {
66+
if (review.user.login === 'github-actions[bot]' && review.state === 'CHANGES_REQUESTED') {
67+
await github.rest.pulls.dismissReview({
68+
pull_number: context.issue.number,
69+
owner: context.repo.owner,
70+
repo: context.repo.repo,
71+
review_id: review.id,
72+
message: 'Clang-tidy hash now matches configuration.'
73+
});
74+
}
75+
}
76+

.github/workflows/ci.yml

Lines changed: 75 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ jobs:
204204
- name: Check out code from GitHub
205205
uses: actions/checkout@v4.2.2
206206
- name: Restore Python
207+
id: restore-python
207208
uses: ./.github/actions/restore-python
208209
with:
209210
python-version: ${{ matrix.python-version }}
@@ -213,17 +214,57 @@ jobs:
213214
- name: Run pytest
214215
if: matrix.os == 'windows-latest'
215216
run: |
216-
./venv/Scripts/activate
217-
pytest -vv --cov-report=xml --tb=native -n auto tests
217+
. ./venv/Scripts/activate.ps1
218+
pytest -vv --cov-report=xml --tb=native -n auto tests --ignore=tests/integration/
218219
- name: Run pytest
219220
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macOS-latest'
220221
run: |
221222
. venv/bin/activate
222-
pytest -vv --cov-report=xml --tb=native -n auto tests
223+
pytest -vv --cov-report=xml --tb=native -n auto tests --ignore=tests/integration/
223224
- name: Upload coverage to Codecov
224225
uses: codecov/codecov-action@v5.4.3
225226
with:
226227
token: ${{ secrets.CODECOV_TOKEN }}
228+
- name: Save Python virtual environment cache
229+
if: github.ref == 'refs/heads/dev'
230+
uses: actions/cache/save@v4.2.3
231+
with:
232+
path: venv
233+
key: ${{ runner.os }}-${{ steps.restore-python.outputs.python-version }}-venv-${{ needs.common.outputs.cache-key }}
234+
235+
integration-tests:
236+
name: Run integration tests
237+
runs-on: ubuntu-latest
238+
needs:
239+
- common
240+
steps:
241+
- name: Check out code from GitHub
242+
uses: actions/checkout@v4.2.2
243+
- name: Set up Python 3.13
244+
id: python
245+
uses: actions/setup-python@v5.6.0
246+
with:
247+
python-version: "3.13"
248+
- name: Restore Python virtual environment
249+
id: cache-venv
250+
uses: actions/cache@v4.2.3
251+
with:
252+
path: venv
253+
key: ${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv-${{ needs.common.outputs.cache-key }}
254+
- name: Create Python virtual environment
255+
if: steps.cache-venv.outputs.cache-hit != 'true'
256+
run: |
257+
python -m venv venv
258+
. venv/bin/activate
259+
python --version
260+
pip install -r requirements.txt -r requirements_test.txt
261+
pip install -e .
262+
- name: Register matcher
263+
run: echo "::add-matcher::.github/workflows/matchers/pytest.json"
264+
- name: Run integration tests
265+
run: |
266+
. venv/bin/activate
267+
pytest -vv --no-cov --tb=native -n auto tests/integration/
227268
228269
clang-format:
229270
name: Check clang-format
@@ -263,6 +304,8 @@ jobs:
263304
- pylint
264305
- pytest
265306
- pyupgrade
307+
env:
308+
GH_TOKEN: ${{ github.token }}
266309
strategy:
267310
fail-fast: false
268311
max-parallel: 2
@@ -301,6 +344,10 @@ jobs:
301344
steps:
302345
- name: Check out code from GitHub
303346
uses: actions/checkout@v4.2.2
347+
with:
348+
# Need history for HEAD~1 to work for checking changed files
349+
fetch-depth: 2
350+
304351
- name: Restore Python
305352
uses: ./.github/actions/restore-python
306353
with:
@@ -312,14 +359,14 @@ jobs:
312359
uses: actions/cache@v4.2.3
313360
with:
314361
path: ~/.platformio
315-
key: platformio-${{ matrix.pio_cache_key }}
362+
key: platformio-${{ matrix.pio_cache_key }}-${{ hashFiles('platformio.ini') }}
316363

317364
- name: Cache platformio
318365
if: github.ref != 'refs/heads/dev'
319366
uses: actions/cache/restore@v4.2.3
320367
with:
321368
path: ~/.platformio
322-
key: platformio-${{ matrix.pio_cache_key }}
369+
key: platformio-${{ matrix.pio_cache_key }}-${{ hashFiles('platformio.ini') }}
323370

324371
- name: Register problem matchers
325372
run: |
@@ -333,10 +380,28 @@ jobs:
333380
mkdir -p .temp
334381
pio run --list-targets -e esp32-idf-tidy
335382
383+
- name: Check if full clang-tidy scan needed
384+
id: check_full_scan
385+
run: |
386+
. venv/bin/activate
387+
if python script/clang_tidy_hash.py --check; then
388+
echo "full_scan=true" >> $GITHUB_OUTPUT
389+
echo "reason=hash_changed" >> $GITHUB_OUTPUT
390+
else
391+
echo "full_scan=false" >> $GITHUB_OUTPUT
392+
echo "reason=normal" >> $GITHUB_OUTPUT
393+
fi
394+
336395
- name: Run clang-tidy
337396
run: |
338397
. venv/bin/activate
339-
script/clang-tidy --all-headers --fix ${{ matrix.options }} ${{ matrix.ignore_errors && '|| true' || '' }}
398+
if [ "${{ steps.check_full_scan.outputs.full_scan }}" = "true" ]; then
399+
echo "Running FULL clang-tidy scan (hash changed)"
400+
script/clang-tidy --all-headers --fix ${{ matrix.options }} ${{ matrix.ignore_errors && '|| true' || '' }}
401+
else
402+
echo "Running clang-tidy on changed files only"
403+
script/clang-tidy --all-headers --fix --changed ${{ matrix.options }} ${{ matrix.ignore_errors && '|| true' || '' }}
404+
fi
340405
env:
341406
# Also cache libdeps, store them in a ~/.platformio subfolder
342407
PLATFORMIO_LIBDEPS_DIR: ~/.platformio/libdeps
@@ -351,23 +416,14 @@ jobs:
351416
needs:
352417
- common
353418
if: github.event_name == 'pull_request'
419+
env:
420+
GH_TOKEN: ${{ github.token }}
354421
outputs:
355422
components: ${{ steps.list-components.outputs.components }}
356423
count: ${{ steps.list-components.outputs.count }}
357424
steps:
358425
- name: Check out code from GitHub
359426
uses: actions/checkout@v4.2.2
360-
with:
361-
# Fetch enough history so `git merge-base refs/remotes/origin/dev HEAD` works.
362-
fetch-depth: 500
363-
- name: Get target branch
364-
id: target-branch
365-
run: |
366-
echo "branch=${{ github.event.pull_request.base.ref }}" >> $GITHUB_OUTPUT
367-
- name: Fetch ${{ steps.target-branch.outputs.branch }} branch
368-
run: |
369-
git -c protocol.version=2 fetch --no-tags --prune --no-recurse-submodules --depth=1 origin +refs/heads/${{ steps.target-branch.outputs.branch }}:refs/remotes/origin/${{ steps.target-branch.outputs.branch }}
370-
git merge-base refs/remotes/origin/${{ steps.target-branch.outputs.branch }} HEAD
371427
- name: Restore Python
372428
uses: ./.github/actions/restore-python
373429
with:
@@ -377,7 +433,7 @@ jobs:
377433
id: list-components
378434
run: |
379435
. venv/bin/activate
380-
components=$(script/list-components.py --changed --branch ${{ steps.target-branch.outputs.branch }})
436+
components=$(script/list-components.py --changed)
381437
output_components=$(echo "$components" | jq -R -s -c 'split("\n")[:-1] | map(select(length > 0))')
382438
count=$(echo "$output_components" | jq length)
383439
@@ -494,6 +550,7 @@ jobs:
494550
- flake8
495551
- pylint
496552
- pytest
553+
- integration-tests
497554
- pyupgrade
498555
- clang-tidy
499556
- list-components

.github/workflows/lock.yml

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,11 @@
11
---
2-
name: Lock
2+
name: Lock closed issues and PRs
33

44
on:
55
schedule:
6-
- cron: "30 0 * * *"
6+
- cron: "30 0 * * *" # Run daily at 00:30 UTC
77
workflow_dispatch:
88

9-
permissions:
10-
issues: write
11-
pull-requests: write
12-
13-
concurrency:
14-
group: lock
15-
169
jobs:
1710
lock:
18-
runs-on: ubuntu-latest
19-
steps:
20-
- uses: dessant/lock-threads@v5.0.1
21-
with:
22-
pr-inactive-days: "1"
23-
pr-lock-reason: ""
24-
exclude-any-pr-labels: keep-open
25-
26-
issue-inactive-days: "7"
27-
issue-lock-reason: ""
28-
exclude-any-issue-labels: keep-open
11+
uses: esphome/workflows/.github/workflows/lock.yml@main

.pre-commit-config.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
repos:
55
- repo: https://github.com/astral-sh/ruff-pre-commit
66
# Ruff version.
7-
rev: v0.12.0
7+
rev: v0.12.2
88
hooks:
99
# Run the linter.
1010
- id: ruff
1111
args: [--fix]
1212
# Run the formatter.
1313
- id: ruff-format
1414
- repo: https://github.com/PyCQA/flake8
15-
rev: 7.2.0
15+
rev: 7.3.0
1616
hooks:
1717
- id: flake8
1818
additional_dependencies:
@@ -48,3 +48,10 @@ repos:
4848
entry: python3 script/run-in-env.py pylint
4949
language: system
5050
types: [python]
51+
- id: clang-tidy-hash
52+
name: Update clang-tidy hash
53+
entry: python script/clang_tidy_hash.py --update-if-changed
54+
language: python
55+
files: ^(\.clang-tidy|platformio\.ini|requirements_dev\.txt)$
56+
pass_filenames: false
57+
additional_dependencies: []

0 commit comments

Comments
 (0)