소스 검색

Set a timeout on spawn CI subprocesses. (default is 5 min)

default_compile_flags
vector-of-bool 3 년 전
부모
커밋
318853fef1
3개의 변경된 파일30개의 추가작업 그리고 19개의 파일을 삭제
  1. +17
    -13
      tools/dds_ci/dds.py
  2. +6
    -2
      tools/dds_ci/main.py
  3. +7
    -4
      tools/dds_ci/proc.py

+ 17
- 13
tools/dds_ci/dds.py 파일 보기

@@ -60,11 +60,11 @@ class DDSWrapper:
if pkg_db and self.pkg_db_path.exists():
self.pkg_db_path.unlink()

def run(self, args: proc.CommandLine, *, cwd: Optional[Pathish] = None) -> None:
def run(self, args: proc.CommandLine, *, cwd: Optional[Pathish] = None, timeout: Optional[int] = None) -> None:
"""Execute the 'dds' executable with the given arguments"""
env = os.environ.copy()
env['DDS_NO_ADD_INITIAL_REPO'] = '1'
proc.check_run([self.path, args], cwd=cwd or self.default_cwd, env=env)
proc.check_run([self.path, args], cwd=cwd or self.default_cwd, env=env, timeout=timeout)

def catalog_json_import(self, path: Path) -> None:
"""Run 'catalog import' to import the given JSON. Only applicable to older 'dds'"""
@@ -94,7 +94,8 @@ class DDSWrapper:
toolchain: Optional[Path] = None,
build_root: Optional[Path] = None,
jobs: Optional[int] = None,
more_args: Optional[proc.CommandLine] = None) -> None:
more_args: Optional[proc.CommandLine] = None,
timeout: Optional[int] = None) -> None:
"""
Run 'dds build' with the given arguments.

@@ -105,16 +106,19 @@ class DDSWrapper:
"""
toolchain = toolchain or tc_mod.get_default_audit_toolchain()
jobs = jobs or multiprocessing.cpu_count() + 2
self.run([
'build',
f'--toolchain={toolchain}',
self.repo_dir_arg,
self.catalog_path_arg,
f'--jobs={jobs}',
f'{self.project_dir_flag}={root}',
f'--out={build_root}',
more_args or (),
])
self.run(
[
'build',
f'--toolchain={toolchain}',
self.repo_dir_arg,
self.catalog_path_arg,
f'--jobs={jobs}',
f'{self.project_dir_flag}={root}',
f'--out={build_root}',
more_args or (),
],
timeout=timeout,
)

def compile_file(self,
paths: Iterable[Pathish],

+ 6
- 2
tools/dds_ci/main.py 파일 보기

@@ -81,7 +81,7 @@ def test_build(dds: DDSWrapper, args: CommandArguments) -> DDSWrapper:
test_tc = args.test_toolchain or toolchain.get_default_audit_toolchain()
build_dir = paths.BUILD_DIR
with toolchain.fixup_toolchain(test_tc) as new_tc:
dds.build(toolchain=new_tc, root=paths.PROJECT_ROOT, build_root=build_dir, jobs=args.jobs)
dds.build(toolchain=new_tc, root=paths.PROJECT_ROOT, build_root=build_dir, jobs=args.jobs, timeout=60 * 15)
return DDSWrapper(build_dir / ('dds' + paths.EXE_SUFFIX))


@@ -113,7 +113,11 @@ def main_build(dds: DDSWrapper, args: CommandArguments) -> int:
toolchain.get_default_toolchain() if not args.rapid else toolchain.get_default_audit_toolchain())
with toolchain.fixup_toolchain(main_tc) as new_tc:
try:
dds.build(toolchain=new_tc, root=paths.PROJECT_ROOT, build_root=paths.BUILD_DIR, jobs=args.jobs)
dds.build(toolchain=new_tc,
root=paths.PROJECT_ROOT,
build_root=paths.BUILD_DIR,
jobs=args.jobs,
timeout=60 * 15)
except subprocess.CalledProcessError as e:
if args.rapid:
return e.returncode

+ 7
- 4
tools/dds_ci/proc.py 파일 보기

@@ -43,9 +43,11 @@ def flatten_cmd(cmd: CommandLine) -> Iterable[str]:
def run(*cmd: CommandLine,
cwd: Optional[Pathish] = None,
check: bool = False,
env: Optional[Mapping[str, str]] = None) -> ProcessResult:
env: Optional[Mapping[str, str]] = None,
timeout: Optional[int] = None) -> ProcessResult:
timeout = timeout or 60 * 5
command = list(flatten_cmd(cmd))
res = subprocess.run(command, cwd=cwd, check=False, env=env)
res = subprocess.run(command, cwd=cwd, check=False, env=env, timeout=timeout)
if res.returncode and check:
raise_error(res)
return res
@@ -57,5 +59,6 @@ def raise_error(proc: ProcessResult) -> NoReturn:

def check_run(*cmd: CommandLine,
cwd: Optional[Pathish] = None,
env: Optional[Mapping[str, str]] = None) -> ProcessResult:
return run(cmd, cwd=cwd, check=True, env=env)
env: Optional[Mapping[str, str]] = None,
timeout: Optional[int] = None) -> ProcessResult:
return run(cmd, cwd=cwd, check=True, env=env, timeout=timeout)

Loading…
취소
저장