Main entry point — orchestrates build, deploy, pin setup, and test phases.
(args: Args | None = None)
| 77 | |
| 78 | |
| 79 | async def run(args: Args | None = None) -> int: |
| 80 | """Main entry point — orchestrates build, deploy, pin setup, and test phases.""" |
| 81 | install_signal_handler() |
| 82 | |
| 83 | args = args or Args.parse_args() |
| 84 | assert args is not None |
| 85 | |
| 86 | if args.quiet: |
| 87 | args.skip_lint = True |
| 88 | args.skip_schema = True |
| 89 | |
| 90 | # Phase A: Parse args, validate modes, build RPC commands (pure computation) |
| 91 | result = _parse_args_and_build_commands(args) |
| 92 | if isinstance(result, int): |
| 93 | return result |
| 94 | ctx = result |
| 95 | |
| 96 | # Early return: --decode mode |
| 97 | if ctx.decode_mode: |
| 98 | assert args.decode is not None |
| 99 | final_environment = ctx.final_environment |
| 100 | if final_environment: |
| 101 | upload_port = args.upload_port |
| 102 | if not upload_port: |
| 103 | port_result = auto_detect_upload_port(final_environment) |
| 104 | if not port_result.ok: |
| 105 | print( |
| 106 | f"{Fore.RED}\u274c Error: No serial port detected for device decode{Style.RESET_ALL}" |
| 107 | ) |
| 108 | return 1 |
| 109 | upload_port = port_result.selected_port |
| 110 | assert upload_port is not None |
| 111 | from ci.autoresearch.decode import run_device_decode_autoresearch |
| 112 | |
| 113 | return await run_device_decode_autoresearch(args.decode, upload_port) |
| 114 | from ci.autoresearch.decode import run_decode_autoresearch |
| 115 | |
| 116 | return await run_decode_autoresearch(args.decode) |
| 117 | |
| 118 | # Early return: native platform |
| 119 | if _is_native_platform(ctx.final_environment): |
| 120 | return await _run_native_autoresearch(args) |
| 121 | |
| 122 | # Phase B: Resolve port & environment |
| 123 | rc = await _resolve_port_and_environment(ctx) |
| 124 | if rc is not None: |
| 125 | return rc |
| 126 | |
| 127 | # Print summary banner |
| 128 | print_run_summary(ctx) |
| 129 | |
| 130 | with QuietContext(args.quiet) as qctx: |
| 131 | try: |
| 132 | # Phase C: Build & deploy |
| 133 | rc = await _run_build_deploy(ctx, qctx) |
| 134 | if rc is not None: |
| 135 | return rc |
| 136 |
no test coverage detected