mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-28 22:06:31 +00:00
perf(image): bake the lint toolchain into locally built images
A new lint-docker stage runs utils.install.lint for every all-mode group that installs outside the source tree; the full stage builds on lint-${INFINITO_LINT_RUNNER}. default.env selects docker for developer machines, and the new lint_runner env handler pins host on GitHub Actions and act, so CI images stay without the toolchain. The Dockerfile keeps host as its ARG default because the CI image build runs push.sh from github.sha against the checked-out context, so published images stay unchanged as well. make install-lint inside the container drops from 173.97 s to 0.533 s. tests/utils/image_slice.py moves the Dockerfile slicing out of test_collections so the new bake test reads the same instructions.
🎯 Fix: 88 %
💥 Break: 8 %
💸 Cost: –
⏱️ Time: –
🛡️ Security: ~100 %
🏆 Score: 81
🚦 Gate: ⛔ fix 88 % < 90, break 8 % > 5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3fdfce419e
commit
452abb5c02
12 files changed
+257
-43
No files matched your search
@@ -0,0 +1,45 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
from utils.env.builder import BuildContext, EnvBuilder
|
||||
from utils.env.handlers.infinito import lint_runner as handler
|
||||
|
||||
|
||||
def _ctx(*, on_gha: bool, on_act: bool) -> BuildContext:
|
||||
return BuildContext(
|
||||
static={},
|
||||
static_comments={},
|
||||
repo_root=Path("/repo"),
|
||||
on_gha=on_gha,
|
||||
on_act=on_act,
|
||||
)
|
||||
|
||||
|
||||
def _apply(ctx: BuildContext) -> str | None:
|
||||
eb = EnvBuilder()
|
||||
handler.apply(eb, ctx)
|
||||
return eb.values.get(handler.KEY)
|
||||
|
||||
|
||||
@patch.dict(os.environ, {handler.KEY: ""})
|
||||
class TestLintRunner(unittest.TestCase):
|
||||
def test_a_github_runner_lints_on_the_host(self) -> None:
|
||||
self.assertEqual(_apply(_ctx(on_gha=True, on_act=False)), "host")
|
||||
|
||||
def test_act_lints_on_the_host(self) -> None:
|
||||
self.assertEqual(_apply(_ctx(on_gha=False, on_act=True)), "host")
|
||||
|
||||
def test_a_developer_machine_keeps_the_static_value(self) -> None:
|
||||
self.assertIsNone(_apply(_ctx(on_gha=False, on_act=False)))
|
||||
|
||||
def test_a_github_job_that_sets_the_runner_keeps_it(self) -> None:
|
||||
with patch.dict(os.environ, {handler.KEY: "docker"}):
|
||||
self.assertEqual(_apply(_ctx(on_gha=True, on_act=False)), "docker")
|
||||
|
||||
|
||||
if __name__ == "__main__": # pragma: no cover
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user