@@ -74,19 +74,25 @@ def test_playwright_headless_shell_is_copied_to_runtime_cache(self, dockerfile):
7474 assert "chromium_headless_shell-*" in cache_copy .group ("artifacts" )
7575
7676 def test_build_artifacts_removed_before_layer_commit (self , dockerfile ):
77- for command , cleanup in (
78- ("playwright install --with-deps" , "rm -rf /root/.cache/ms-playwright" ),
79- ("crawl4ai-doctor" , "-name '*.core' -delete" ),
77+ layer = re .search (
78+ r"^RUN crawl4ai-setup(?P<body>(?:(?!^[A-Z]+\s).)*)" ,
79+ dockerfile ,
80+ re .MULTILINE | re .DOTALL ,
81+ )
82+ assert layer , "Dockerfile must run crawl4ai-setup"
83+ positions = []
84+ for command in (
85+ "playwright install --with-deps chromium" ,
86+ "crawl4ai-doctor" ,
87+ "cp -r /root/.cache/ms-playwright/chromium-*" ,
88+ "rm -rf /root/.cache/ms-playwright" ,
89+ "-name '*.core' -delete" ,
8090 ):
81- layer = re .search (
82- rf"^RUN { re .escape (command )} (?P<body>(?:(?!^[A-Z]+\s).)*)" ,
83- dockerfile ,
84- re .MULTILINE | re .DOTALL ,
85- )
86- assert layer , f"Dockerfile must run { command } "
87- assert cleanup in layer .group (
91+ assert command in layer .group (
8892 "body"
89- ), f"{ cleanup } must run in the { command } layer"
93+ ), f"{ command } must run in the crawl4ai-setup layer"
94+ positions .append (layer .group ("body" ).index (command ))
95+ assert positions == sorted (positions ), "Docker build steps must remain ordered"
9096
9197 def test_runs_as_non_root (self , dockerfile ):
9298 assert re .search (r"^USER\s+appuser" , dockerfile , re .MULTILINE )
0 commit comments