From 459aa24aad5a8903db6b58266b7497a7ecf33509 Mon Sep 17 00:00:00 2001 From: Pierre Gimalac Date: Wed, 18 Dec 2024 11:33:38 +0100 Subject: [PATCH] Stop lint and test tasks on keyboard interrupt (#32201) --- tasks/go.py | 7 ++++++- tasks/gotest.py | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tasks/go.py b/tasks/go.py index 13f451cce050f..5bb3fcad7d656 100644 --- a/tasks/go.py +++ b/tasks/go.py @@ -78,11 +78,16 @@ def lint_module(target): concurrency_arg = "" if concurrency is None else f"--concurrency {concurrency}" tags_arg = " ".join(sorted(set(tags))) timeout_arg_value = "25m0s" if not timeout else f"{timeout}m0s" - return ctx.run( + res = ctx.run( f'golangci-lint run {verbosity} --timeout {timeout_arg_value} {concurrency_arg} --build-tags "{tags_arg}" --path-prefix "{module_path}" {golangci_lint_kwargs} {target}/...', env=env, warn=True, ) + # early stop on SIGINT: exit code is 128 + signal number, SIGINT is 2, so 130 + # for some reason this becomes -2 here + if res is not None and (res.exited == -2 or res.exited == 130): + raise KeyboardInterrupt() + return res target_path = Path(module_path) / target result, time_result = TimedOperationResult.run( diff --git a/tasks/gotest.py b/tasks/gotest.py index 4aa9a4b3e151f..af889e8b6dcae 100644 --- a/tasks/gotest.py +++ b/tasks/gotest.py @@ -145,6 +145,9 @@ def command(test_results, module, module_result): out_stream=test_profiler, warn=True, ) + # early stop on SIGINT: exit code is 128 + signal number, SIGINT is 2, so 130 + if res is not None and res.exited == 130: + raise KeyboardInterrupt() module_result.result_json_path = os.path.join(module_path, GO_TEST_RESULT_TMP_JSON)