@@ -191,29 +191,31 @@ def test_default_project(cookies):
191191 pytest .fail ("Something went wrong with the project's post-generation hook" )
192192
193193 try :
194- # Build all supported architectures to ensure it succeeds; we cannot test it because multi-platform builds can't be loaded into the docker daemon, but
195- # we will load and test the same-platform image later
196194 env = os .environ .copy ()
197195 env .pop ("VIRTUAL_ENV" , None ) # Clean VIRTUAL_ENV to avoid conflicts
198- env ["PLATFORM" ] = "all"
196+
197+ # Bootstrap the project and run the simplest checks first to optimize for a fast feedback loop
199198 subprocess .run (
200199 [
201200 "task" ,
202201 "-v" ,
203202 "init" ,
204203 "lint" ,
205204 "validate" ,
206- "build" ,
207- "sbom" ,
208- "vulnscan" ,
209205 ],
210206 capture_output = True ,
211207 check = True ,
212208 cwd = project ,
213209 env = env ,
214210 )
215211
216- # Build and test each supported architecture individually (should be mostly cached)
212+ # Ensure the project.yml is generated, and is valid YAML
213+ config_path = project / ".github" / "project.yml"
214+ with config_path .open (encoding = "utf-8" ) as yaml_data :
215+ project_context = yaml .safe_load (yaml_data )
216+ assert project_context ["origin" ]["generated" ]
217+
218+ # Build and test each supported architecture individually
217219 for platform in ("linux/arm64" , "linux/amd64" ):
218220 env ["PLATFORM" ] = platform
219221 subprocess .run (
@@ -264,11 +266,24 @@ def test_default_project(cookies):
264266 f"Unexpected exit code when running { command } ; expected { expected_exit } , received { process .returncode } "
265267 )
266268
267- # Ensure the project.yml is generated, and is valid YAML
268- config_path = project / ".github" / "project.yml"
269- with config_path .open (encoding = "utf-8" ) as yaml_data :
270- project_context = yaml .safe_load (yaml_data )
271- assert project_context ["origin" ]["generated" ]
269+ # Clean the repo, perform a multi-platform build, and then run the sbom and vulnscan task to ensure it all works
270+ # We cannot functionally test a multi-platform image without pushing it to a registry and then pulling it back down because they can't directly be
271+ # loaded into the docker daemon
272+ env ["PLATFORM" ] = "all"
273+ subprocess .run (
274+ [
275+ "task" ,
276+ "-v" ,
277+ "clean" ,
278+ "build" ,
279+ "sbom" ,
280+ "vulnscan" ,
281+ ],
282+ capture_output = True ,
283+ check = True ,
284+ cwd = project ,
285+ env = env ,
286+ )
272287 except subprocess .CalledProcessError as error :
273288 print (f"\n === STDOUT ===\n { error .stdout .decode ('utf-8' )} " )
274289 print (f"\n === STDERR ===\n { error .stderr .decode ('utf-8' )} " )
0 commit comments