()
| 227 | |
| 228 | |
| 229 | def main(): |
| 230 | parser = argparse.ArgumentParser() |
| 231 | parser.add_argument('targets', nargs='+', choices=['ALL', 'DNS_PLUGINS', 'certbot', *PLUGINS], |
| 232 | help='the list of snaps to build') |
| 233 | parser.add_argument('--archs', nargs='+', choices=['amd64', 'arm64', 'armhf'], |
| 234 | default=['amd64'], help='the architectures for which snaps are built') |
| 235 | parser.add_argument('--timeout', type=int, default=None, |
| 236 | help='build process will fail after the provided timeout (in seconds)') |
| 237 | args = parser.parse_args() |
| 238 | |
| 239 | archs = set(args.archs) |
| 240 | targets = set(args.targets) |
| 241 | |
| 242 | if 'ALL' in targets: |
| 243 | targets.remove('ALL') |
| 244 | targets.update(['certbot', 'DNS_PLUGINS']) |
| 245 | |
| 246 | if 'DNS_PLUGINS' in targets: |
| 247 | targets.remove('DNS_PLUGINS') |
| 248 | targets.update(PLUGINS) |
| 249 | |
| 250 | # If we're building anything other than just Certbot, we need to |
| 251 | # generate the snapcraft files for the DNS plugins. |
| 252 | if targets != {'certbot'}: |
| 253 | subprocess.run(['tools/snap/generate_dnsplugins_all.sh'], |
| 254 | check=True, cwd=CERTBOT_DIR) |
| 255 | |
| 256 | print('Start remote snap builds...') |
| 257 | print(f' - archs: {", ".join(archs)}') |
| 258 | print(f' - projects: {", ".join(sorted(targets))}') |
| 259 | print() |
| 260 | |
| 261 | manager: SyncManager = Manager() |
| 262 | pool = Pool(processes=len(targets)) |
| 263 | with manager, pool: |
| 264 | status: Dict[str, Dict[str, str]] = manager.dict() |
| 265 | running = manager.dict({target: True for target in targets}) |
| 266 | # While multiple processes are running, this lock should be acquired |
| 267 | # before printing output. |
| 268 | output_lock = manager.Lock() |
| 269 | |
| 270 | async_results = [pool.apply_async(_build_snap, (target, archs, status, running, output_lock)) |
| 271 | for target in targets] |
| 272 | |
| 273 | process = Process(target=_dump_status, args=(archs, status, running, output_lock)) |
| 274 | process.start() |
| 275 | |
| 276 | try: |
| 277 | process.join(args.timeout) |
| 278 | |
| 279 | if process.is_alive(): |
| 280 | for target in targets: |
| 281 | if target == 'certbot': |
| 282 | workspace = CERTBOT_DIR |
| 283 | else: |
| 284 | workspace = join(CERTBOT_DIR, target) |
| 285 | _dump_failed_build_logs(target, archs, status, workspace) |
| 286 | raise ValueError(f"Timeout out reached ({args.timeout} seconds) during the build!") |
no test coverage detected