fix(lint): provision mmdc's browser only when it is missing

install-lint provisioned chrome-headless-shell on every run, and `make lint`
runs install-lint once per lint target in parallel whenever its stamp is not
fresh. On CI the stamp never is (eslint lives in node_modules, not on PATH),
so one lint job provisioned 16 times (run 38455552981). As root, puppeteer's
--install-deps runs `apt-get satisfy` even for an installed browser, and two
of those at once fail on the dpkg lock; a failed provisioning then deleted the
shared browser cache while lint-mermaid could be rendering with it.

The browser is now provisioned only when it is not installed, and --force
drops its cache so `make install-lint-force` still reinstalls it with its
libraries.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kevinveenbirkenbachandClaude Opus 5.5 committed 2026-10-14 08:56:59 +02:00
1 parent fd9286b24f
commit 078d0a0682
4 files changed
+35 -2

No files matched your search

@@ -99,9 +99,10 @@ class TestStampLogic(unittest.TestCase):
self.assertTrue((root / cli._STAMP).exists())
def test_force_drops_stamp(self) -> None:
with TemporaryDirectory() as tmp:
with TemporaryDirectory() as tmp, TemporaryDirectory() as cache:
root = _make_repo_root(tmp, stamp_age_offset=60.0)
with (
mock.patch.dict(os.environ, {"PUPPETEER_CACHE_DIR": cache}),
mock.patch.object(cli, "PROJECT_ROOT", root),
mock.patch.object(cli, "_install_all") as inst,
):
@@ -109,6 +110,19 @@ class TestStampLogic(unittest.TestCase):
self.assertEqual(rc, 0)
inst.assert_called_once()
def test_force_drops_the_mermaid_browser(self) -> None:
with TemporaryDirectory() as tmp, TemporaryDirectory() as cache:
root = _make_repo_root(tmp, stamp_age_offset=60.0)
browser = Path(cache) / "chrome-headless-shell" / "linux-1"
browser.mkdir(parents=True)
with (
mock.patch.dict(os.environ, {"PUPPETEER_CACHE_DIR": cache}),
mock.patch.object(cli, "PROJECT_ROOT", root),
mock.patch.object(cli, "_install_all"),
):
cli.main(["--force"])
self.assertFalse(browser.exists())
class TestGroupDispatch(unittest.TestCase):
def test_group_only_bypasses_stamp(self) -> None:
@@ -84,8 +84,23 @@ class TestBrowserProvisioning(unittest.TestCase):
self.assertEqual(len(warnings), 1)
self.assertIn("out\nerr\n", warnings[0])
def test_an_installed_browser_is_not_provisioned_again(self) -> None:
with TemporaryDirectory() as cache:
build = Path(cache) / "chrome-headless-shell" / "linux-1" / "linux64"
build.mkdir(parents=True)
(build / "chrome-headless-shell").write_text("", encoding="utf-8")
with (
mock.patch.dict(os.environ, {"PUPPETEER_CACHE_DIR": cache}),
mock.patch.object(mermaid_cli, "which", return_value=True),
mock.patch.object(mermaid_cli.subprocess, "run") as run,
):
mermaid_cli.ensure()
run.assert_not_called()
def test_a_timeout_warns_instead_of_raising(self) -> None:
with (
TemporaryDirectory() as cache,
mock.patch.dict(os.environ, {"PUPPETEER_CACHE_DIR": cache}),
mock.patch.object(mermaid_cli, "which", return_value=True),
mock.patch.object(
mermaid_cli.subprocess,