2929import shutil
3030
3131from pathlib import Path
32- from utils import Releases , Version , ci_group , is_ci , is_alpinelike , is_debianlike , is_macos , is_windows , is_msys , read_wrap , FormattingError , format_meson
32+ from utils import CIConfig , ProjectCIConfig , Releases , Version , ci_group , is_ci , is_alpinelike , is_debianlike , is_macos , is_windows , is_msys , read_wrap , FormattingError , format_meson
3333
3434PERMITTED_FILES = {'generator.sh' , 'meson.build' , 'meson_options.txt' , 'meson.options' , 'LICENSE.build' }
3535PER_PROJECT_PERMITTED_FILES : dict [str , set [str ]] = {
163163IGNORE_SETUP_WARNINGS = None # or re.compile(r'something')
164164
165165
166- if T .TYPE_CHECKING :
167- class CiConfigProject (T .TypedDict , total = False ):
168- build_options : list [str ]
169- build_on : dict [str , bool ]
170- alpine_packages : list [str ]
171- brew_packages : list [str ]
172- choco_packages : list [str ]
173- debian_packages : list [str ]
174- msys_packages : list [str ]
175- python_packages : list [str ]
176- fatal_warnings : bool
177- has_provides : bool
178- skip_dependency_check : list [str ]
179- skip_program_check : list [str ]
180- test_options : list [str ]
181- skip_tests : bool
182-
183-
184166class TestReleases (unittest .TestCase ):
185- # requires casts for special keys e.g. broken_*
186- ci_config : dict [str , CiConfigProject ]
167+ ci_config : CIConfig
187168 fatal_warnings : bool
188169 annotate_context : bool
189170 skip_build : bool
@@ -211,14 +192,10 @@ def setUpClass(cls):
211192
212193 try :
213194 cls .releases = Releases .load ()
214- fn = 'ci_config.json'
215- with open (fn , 'r' , encoding = 'utf-8' ) as f :
216- cls .ci_config = json .load (f )
195+ cls .ci_config = CIConfig .load ()
217196 except json .decoder .JSONDecodeError as ex :
218197 raise RuntimeError ('metadata is malformed' ) from ex
219198
220- system = platform .system ().lower ()
221- cls .skip = T .cast (T .List [str ], cls .ci_config [f'broken_{ system } ' ])
222199 cls .fatal_warnings = os .environ .get ('TEST_FATAL_WARNINGS' , 'yes' ) == 'yes'
223200 cls .annotate_context = os .environ .get ('TEST_ANNOTATE_CONTEXT' ) == 'yes'
224201 cls .skip_build = os .environ .get ('TEST_SKIP_BUILD' ) == 'yes'
@@ -345,7 +322,7 @@ def test_releases(self) -> None:
345322 if not self .skip_build :
346323 self .check_new_release (name , deps = deps , progs = progs )
347324 with self .subTest (f'If this works now, please remove it from broken_{ platform .system ().lower ()} !' ):
348- self .assertNotIn (name , self .skip )
325+ self .assertNotIn (name , self .ci_config . broken )
349326 self .check_meson_version (name , ver , patch_path )
350327 if patch_path :
351328 self .check_project_args (name , Path ('subprojects' ) / wrap_section ['directory' ])
@@ -367,7 +344,7 @@ def test_build_all(self):
367344 failed = []
368345 errored = []
369346 for name , info in self .releases .items ():
370- if name in self .skip :
347+ if name in self .ci_config . broken :
371348 skipped .append (name )
372349 continue
373350 try :
@@ -550,7 +527,7 @@ def do_setup(builddir, options, meson_env):
550527 raise
551528 subprocess .check_call (['meson' , 'install' , '-C' , builddir , '--destdir' , 'pkg' ])
552529
553- def install_packages (self , ci : CiConfigProject ) -> dict [str , str ]:
530+ def install_packages (self , ci : ProjectCIConfig ) -> dict [str , str ]:
554531 debian_packages = ci .get ('debian_packages' , [])
555532 brew_packages = ci .get ('brew_packages' , [])
556533 choco_packages = ci .get ('choco_packages' , [])
0 commit comments