mirror of
https://github.com/esphome/esphome.git
synced 2026-05-23 03:06:05 +08:00
[rp2040] Add CI check for boards.py freshness (#14754)
CI / Create common environment (push) Has been cancelled
CI / Check pylint (push) Has been cancelled
CI / Run script/ci-custom (push) Has been cancelled
CI / Run pytest (macOS-latest, 3.11) (push) Has been cancelled
CI / Run pytest (macOS-latest, 3.14) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.11) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.13) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.14) (push) Has been cancelled
CI / Run pytest (windows-latest, 3.11) (push) Has been cancelled
CI / Run pytest (windows-latest, 3.14) (push) Has been cancelled
CI / Determine which jobs to run (push) Has been cancelled
CI / Run integration tests (push) Has been cancelled
CI / Run C++ unit tests (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 IDF (push) Has been cancelled
CI / Run script/clang-tidy for ESP8266 (push) Has been cancelled
CI / Run script/clang-tidy for ZEPHYR (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Has been cancelled
CI / Test components batch (${{ matrix.components }}) (push) Has been cancelled
CI / pre-commit.ci lite (push) Has been cancelled
CI / Build target branch for memory impact (push) Has been cancelled
CI / Build PR branch for memory impact (push) Has been cancelled
CI / Comment memory impact (push) Has been cancelled
CI / CI Status (push) Has been cancelled
CI for docker images / Build docker containers (docker, ubuntu-24.04) (push) Has been cancelled
CI for docker images / Build docker containers (docker, ubuntu-24.04-arm) (push) Has been cancelled
CI for docker images / Build docker containers (ha-addon, ubuntu-24.04) (push) Has been cancelled
CI for docker images / Build docker containers (ha-addon, ubuntu-24.04-arm) (push) Has been cancelled
Synchronise Device Classes from Home Assistant / Sync Device Classes (push) Has been cancelled
CI / Create common environment (push) Has been cancelled
CI / Check pylint (push) Has been cancelled
CI / Run script/ci-custom (push) Has been cancelled
CI / Run pytest (macOS-latest, 3.11) (push) Has been cancelled
CI / Run pytest (macOS-latest, 3.14) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.11) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.13) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.14) (push) Has been cancelled
CI / Run pytest (windows-latest, 3.11) (push) Has been cancelled
CI / Run pytest (windows-latest, 3.14) (push) Has been cancelled
CI / Determine which jobs to run (push) Has been cancelled
CI / Run integration tests (push) Has been cancelled
CI / Run C++ unit tests (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 IDF (push) Has been cancelled
CI / Run script/clang-tidy for ESP8266 (push) Has been cancelled
CI / Run script/clang-tidy for ZEPHYR (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Has been cancelled
CI / Test components batch (${{ matrix.components }}) (push) Has been cancelled
CI / pre-commit.ci lite (push) Has been cancelled
CI / Build target branch for memory impact (push) Has been cancelled
CI / Build PR branch for memory impact (push) Has been cancelled
CI / Comment memory impact (push) Has been cancelled
CI / CI Status (push) Has been cancelled
CI for docker images / Build docker containers (docker, ubuntu-24.04) (push) Has been cancelled
CI for docker images / Build docker containers (docker, ubuntu-24.04-arm) (push) Has been cancelled
CI for docker images / Build docker containers (ha-addon, ubuntu-24.04) (push) Has been cancelled
CI for docker images / Build docker containers (ha-addon, ubuntu-24.04-arm) (push) Has been cancelled
Synchronise Device Classes from Home Assistant / Sync Device Classes (push) Has been cancelled
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -106,6 +106,7 @@ jobs:
|
||||
script/build_codeowners.py --check
|
||||
script/build_language_schema.py --check
|
||||
script/generate-esp32-boards.py --check
|
||||
script/generate-rp2040-boards.py --check
|
||||
|
||||
pytest:
|
||||
name: Run pytest
|
||||
|
||||
@@ -6,6 +6,7 @@ Usage: python esphome/components/rp2040/generate_boards.py <arduino-pico-path>
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
@@ -157,7 +158,7 @@ def generate(arduino_pico_path: Path) -> str:
|
||||
board_pins, boards = load_boards(arduino_pico_path)
|
||||
|
||||
template = _jinja_env.get_template("boards.jinja2")
|
||||
return template.render(
|
||||
content = template.render(
|
||||
cyw43_gpio_offset=CYW43_GPIO_OFFSET,
|
||||
cyw43_max_gpio=CYW43_GPIO_OFFSET + CYW43_GPIO_COUNT - 1,
|
||||
default_max_pin=DEFAULT_MAX_PIN,
|
||||
@@ -165,6 +166,15 @@ def generate(arduino_pico_path: Path) -> str:
|
||||
boards=sorted(boards.items()),
|
||||
)
|
||||
|
||||
# Format output to match pre-commit ruff formatting
|
||||
result = subprocess.run(
|
||||
[sys.executable, "-m", "ruff", "format", "--stdin-filename", "boards.py"],
|
||||
input=content.encode(),
|
||||
capture_output=True,
|
||||
check=True,
|
||||
)
|
||||
return result.stdout.decode()
|
||||
|
||||
|
||||
def main():
|
||||
if len(sys.argv) < 2:
|
||||
|
||||
Executable
+61
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
from esphome.components.rp2040 import RECOMMENDED_ARDUINO_FRAMEWORK_VERSION
|
||||
from esphome.components.rp2040.generate_boards import generate
|
||||
from esphome.helpers import write_file_if_changed
|
||||
|
||||
ver = RECOMMENDED_ARDUINO_FRAMEWORK_VERSION
|
||||
version_tag: str = f"{ver.major}.{ver.minor}.{ver.patch}"
|
||||
root: Path = Path(__file__).parent.parent
|
||||
boards_file_path: Path = root / "esphome" / "components" / "rp2040" / "boards.py"
|
||||
|
||||
|
||||
def main(check: bool) -> None:
|
||||
with tempfile.TemporaryDirectory() as tempdir:
|
||||
subprocess.run(
|
||||
[
|
||||
"git",
|
||||
"clone",
|
||||
"-q",
|
||||
"-c",
|
||||
"advice.detachedHead=false",
|
||||
"--depth",
|
||||
"1",
|
||||
"--branch",
|
||||
version_tag,
|
||||
"https://github.com/earlephilhower/arduino-pico",
|
||||
tempdir,
|
||||
],
|
||||
check=True,
|
||||
)
|
||||
|
||||
content: str = generate(Path(tempdir))
|
||||
|
||||
if check:
|
||||
existing_content: str = boards_file_path.read_text(encoding="utf-8")
|
||||
if existing_content != content:
|
||||
print("esphome/components/rp2040/boards.py is not up to date.")
|
||||
print("Please run `script/generate-rp2040-boards.py`")
|
||||
sys.exit(1)
|
||||
print("esphome/components/rp2040/boards.py is up to date")
|
||||
elif write_file_if_changed(boards_file_path, content):
|
||||
print("RP2040 boards updated successfully.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser: argparse.ArgumentParser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
"--check",
|
||||
help="Check if the boards.py file is up to date.",
|
||||
action="store_true",
|
||||
)
|
||||
args: argparse.Namespace = parser.parse_args()
|
||||
main(args.check)
|
||||
Reference in New Issue
Block a user