1a6308aba7
A test and code-analysis round of 0.2.72 to 0.2.76 (suites at every tag, sanitizers, ESP32 and GitHub builds, host harnesses on both boards, the editor in a browser, best practice checked against ESPHome, LVGL, Home Assistant and Vue) found these, fixed here with Max's choices for the product questions: - Firmware 0.2.65: the second hand of a single analog clock moves again; on a page that is one full on/off tile the waking push also switches it; on the Guition a flick is never a tap and a finger that slides off a tile doesn't tap it; Previous/Next react to a firm press; the same Go to page tile may sit on several pages; a layout the screen has no memory for is refused instead of crashing; 64-bit redraw mask for 48 tiles; Montserrat 14 no longer built. - App: Save refuses a layout too long for one message or too big for eight pages; an offline screen keeps its firmware version from the device registry; HA refusals reach the editor; 128 KB requests; changelog out of the live stream; cached hashed assets; tini as init and a clean stop; changelog parsing without asterisks or crashes. - Editor: clicking the open screen keeps unsaved edits, edits during a save stay unsaved, a Page row and phone dragging to other pages, repeated page tiles, limits from the server, HA's error messages, a type-checked build. - tools/check.sh + GitHub Actions + a CYD flash budget; docs match 48 tiles and the new editor. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
72 lines
3.5 KiB
Python
72 lines
3.5 KiB
Python
"""Release lint (app 0.2.78): the version numbers of a release agree, and the packages fetch only fonts that exist.
|
|
|
|
Every push to main is a release (docs/RELEASING.md), so these run with the rest of the suite in tools/check.sh and CI.
|
|
Standard library only.
|
|
"""
|
|
from pathlib import Path
|
|
import re
|
|
import sys
|
|
import unittest
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
sys.path.insert(0, str(ROOT / 'screen_manager/app'))
|
|
from core import FIRMWARE_VERSION # noqa: E402
|
|
|
|
CHANGELOG = ROOT / 'screen_manager/CHANGELOG.md'
|
|
# An app release: "## 0.2.76 (firmware 0.2.63)"; the oldest ones name no firmware. The two "## Firmware 0.2.1x"
|
|
# sections are firmware-only releases between app 0.2.11 and 0.2.12 and carry no app version, so they don't count.
|
|
APP_HEADING = re.compile(r'^## (\d+)\.(\d+)\.(\d+)\b(.*)$', re.M)
|
|
FIRMWARE_IN_HEADING = re.compile(r'\(firmware (\d+\.\d+\.\d+)\)')
|
|
# The generator (tools/generate_packages.py) turns fonts/<file> into a raw GitHub URL on main.
|
|
FONT_URL = re.compile(r'https://raw\.githubusercontent\.com/MaxGramser/homeassistant_espscreen/[^/\s"\']+/(fonts/[^"\'\s]+)')
|
|
|
|
|
|
def app_headings():
|
|
"""[(version tuple, text after the version)] of the CHANGELOG, top to bottom."""
|
|
return [((int(a), int(b), int(c)), rest) for a, b, c, rest in APP_HEADING.findall(CHANGELOG.read_text())]
|
|
|
|
|
|
def dotted(version):
|
|
return '.'.join(map(str, version))
|
|
|
|
|
|
class ReleaseVersionTests(unittest.TestCase):
|
|
def test_config_version_is_the_newest_changelog_entry(self):
|
|
match = re.search(r'^version:\s*["\']?([^"\'\s]+)["\']?\s*$', (ROOT / 'screen_manager/config.yaml').read_text(), re.M)
|
|
self.assertIsNotNone(match, 'screen_manager/config.yaml has no version line')
|
|
headings = app_headings()
|
|
self.assertTrue(headings, 'screen_manager/CHANGELOG.md has no "## x.y.z" heading')
|
|
self.assertEqual(match.group(1), dotted(headings[0][0]),
|
|
'Home Assistant offers the update by config.yaml: bump it together with a new CHANGELOG entry')
|
|
|
|
def test_newest_entry_names_the_shipped_firmware(self):
|
|
version, rest = app_headings()[0]
|
|
firmware = FIRMWARE_IN_HEADING.search(rest)
|
|
if firmware:
|
|
self.assertEqual(firmware.group(1), FIRMWARE_VERSION,
|
|
f'CHANGELOG {dotted(version)} names firmware {firmware.group(1)}, core.FIRMWARE_VERSION is {FIRMWARE_VERSION}')
|
|
|
|
def test_changelog_versions_are_unique_and_newest_first(self):
|
|
versions = [version for version, _ in app_headings()]
|
|
duplicates = sorted({dotted(v) for v in versions if versions.count(v) > 1})
|
|
self.assertEqual(duplicates, [], 'a CHANGELOG version appears twice')
|
|
for newer, older in zip(versions, versions[1:]):
|
|
self.assertGreater(newer, older, f'CHANGELOG {dotted(newer)} stands above {dotted(older)}')
|
|
|
|
|
|
class PackageFontTests(unittest.TestCase):
|
|
def test_every_font_a_package_fetches_is_in_the_tree(self):
|
|
packages = sorted((ROOT / 'packages').glob('*.yaml'))
|
|
self.assertTrue(packages, 'no packages/*.yaml')
|
|
seen = 0
|
|
for package in packages:
|
|
for path in FONT_URL.findall(package.read_text()):
|
|
seen += 1
|
|
self.assertTrue((ROOT / path).is_file(), f'{package.name} fetches {path}, which is not in the tree')
|
|
# A changed URL form must not turn this into a test of nothing.
|
|
self.assertGreater(seen, 0, 'no fonts/... URL found in packages/*.yaml')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|