Probe failures follow the compile branch's transient rules, strict on the native esp8266 job

This commit is contained in:
J. Nick Koston
2026-08-26 23:02:18 -05:00
parent 0266b7f0fb
commit 34daa6138a
4 changed files with 51 additions and 8 deletions
+4 -2
View File
@@ -1202,8 +1202,10 @@ jobs:
echo ""
# ESP8266 Arduino built directly (no PlatformIO); compile validates
# config first, so a separate config pass is redundant.
python3 script/test_build_components.py -e compile -t esp8266-ard -c "$TEST_COMPONENTS" -f --toolchain arduino --fail-on-no-tests
# config first, so a separate config pass is redundant. Strict pch:
# the docker smoke test covers the PlatformIO default, this job is
# the only CI exercise of the native ninja pch (and its probe edge).
ESPHOME_PCH_STRICT=1 python3 script/test_build_components.py -e compile -t esp8266-ard -c "$TEST_COMPONENTS" -f --toolchain arduino --fail-on-no-tests
device-builder:
name: Test downstream esphome/device-builder
+14 -3
View File
@@ -442,8 +442,9 @@ def prepare_pch(
# Load probe: some toolchains build a .gch they then refuse to load
# (per-process ASLR); dep flags are already stripped from cmd, so no
# -MF is needed
# cmd ends with the fixed "-x c++-header -c <header> -o <gch>" tail
probe_cmd = [
*cmd[: cmd.index("-x")],
*cmd[:-6],
"-Winvalid-pch",
"-include",
str(header),
@@ -467,12 +468,22 @@ def prepare_pch(
discard_pch(build_dir)
pch_degraded(f"probe did not run: {err}")
return
if probe.returncode < 0:
# Killed by a signal (OOM, ^C): environmental, do not latch
_LOGGER.warning(
"Precompiled header probe was killed (signal %d); retrying next build",
-probe.returncode,
)
discard_pch(build_dir)
pch_degraded(f"probe killed by signal {-probe.returncode}")
return
if probe.returncode != 0 or ".gch" in probe.stderr:
error = f"toolchain cannot load the pch: {probe.stderr.strip()[:400]}"
_LOGGER.warning("Precompiled header failed; compiling without it: %s", error)
discard_pch(build_dir)
failed_marker.write_text(checksum + "\n", encoding="utf-8")
os.utime(header)
if not any(m in error for m in _TRANSIENT_ERRORS):
failed_marker.write_text(checksum + "\n", encoding="utf-8")
os.utime(header)
pch_degraded(error)
return
failed_marker.unlink(missing_ok=True)
@@ -1878,6 +1878,10 @@ def test_write_project_pch_strict_emits_probe_edge(
)
content = _write_ninja(paths, ccache="/usr/bin/ccache")
assert "pchprobe esphome_pch.h.gch\n flags = " in content
for line in content.splitlines():
if line.startswith("build obj/src/main.cpp.o:"):
assert line.endswith("| esphome_pch.h.gch esphome_pch.probe")
edges = [
line
for line in content.splitlines()
if line.startswith("build obj/src/") and ".cpp.o:" in line
]
assert edges
assert all(line.endswith("| esphome_pch.h.gch esphome_pch.probe") for line in edges)
+26
View File
@@ -903,6 +903,32 @@ def test_prepare_pch_probe_spawn_failure_degrades(
prepare_pch()
def test_prepare_pch_probe_environmental_failures_do_not_latch(
tmp_path: Path,
) -> None:
"""A signal-killed or ENOSPC probe retries next build, no marker."""
from esphome.build_gen.espidf import prepare_pch
for stderr, code in (("", -9), ("fatal: No space left on device", 1)):
dev = _make_pch_device(tmp_path, f"dev_pe{code}")
CORE.build_path = dev
gch = dev / "build" / "esphome_pch.h.gch"
def env_probe(cmd, _gch=gch, _stderr=stderr, _code=code, **kwargs):
if "-fsyntax-only" in cmd:
return subprocess.CompletedProcess(cmd, _code, "", _stderr)
_gch.write_bytes(b"gch")
return subprocess.CompletedProcess(cmd, 0, "", "")
with (
patch.object(CORE, "name", "test"),
patch("esphome.build_helpers.pch.subprocess.run", side_effect=env_probe),
):
prepare_pch()
assert not gch.exists()
assert not (dev / "build" / "esphome_pch.h.gch.failed").exists()
def test_prepare_pch_signal_kill_strict_raises(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None: