dev_container: Add --no-interactive option

This flag is used by luci builders to force non-interactive mode.
The logic is temporary to allow us to change the defaults for the
interactive mode / tty logic in a follow-up CL.

BUG=b:275613273
TEST=dev_container --no-interactive run_tests

Change-Id: I93f315d5f65ed184e9c400531b115cc94312c95f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4818789
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
This commit is contained in:
Dennis Kempin 2023-08-28 13:05:30 -07:00 committed by crosvm LUCI
parent d1a43064eb
commit baf1937010
9 changed files with 28 additions and 10 deletions

View file

@ -60,7 +60,7 @@ Usage:
&emsp; **@property**<br>&mdash; **def [dev\_container\_cache](/infra/recipe_modules/crosvm/api.py#39)(self):**
&mdash; **def [get\_git\_sha](/infra/recipe_modules/crosvm/api.py#185)(self):**
&mdash; **def [get\_git\_sha](/infra/recipe_modules/crosvm/api.py#186)(self):**
&mdash; **def [host\_build\_context](/infra/recipe_modules/crosvm/api.py#113)(self):**
@ -77,7 +77,7 @@ Usage:
Directory used to install local tools required by the build.
&mdash; **def [prepare\_git](/infra/recipe_modules/crosvm/api.py#160)(self):**
&mdash; **def [prepare\_git](/infra/recipe_modules/crosvm/api.py#161)(self):**
&emsp; **@property**<br>&mdash; **def [rustup\_home](/infra/recipe_modules/crosvm/api.py#19)(self):**
@ -97,7 +97,7 @@ Where the crosvm source will be checked out.
Runs a luci step inside the crosvm dev container.
&mdash; **def [upload\_coverage](/infra/recipe_modules/crosvm/api.py#193)(self, filename):**
&mdash; **def [upload\_coverage](/infra/recipe_modules/crosvm/api.py#194)(self, filename):**
## Recipes
### *recipes* / [build\_chromeos\_hatch](/infra/recipes/build_chromeos_hatch.py)

View file

@ -150,6 +150,7 @@ class CrosvmApi(recipe_api.RecipeApi):
[
"vpython3",
self.source_dir.join("tools/dev_container"),
"--no-interactive",
"--verbose",
]
+ (["--cros"] if cros else [])

View file

@ -257,6 +257,7 @@
"cmd": [
"vpython3",
"[CACHE]/builder/crosvm/tools/dev_container",
"--no-interactive",
"--verbose",
"true"
],
@ -271,6 +272,7 @@
"cmd": [
"vpython3",
"[CACHE]/builder/crosvm/tools/dev_container",
"--no-interactive",
"--verbose",
"cargo",
"build"

View file

@ -250,6 +250,7 @@
"cmd": [
"vpython3",
"[CACHE]/builder/crosvm/tools/dev_container",
"--no-interactive",
"--verbose",
"--cros",
"true"
@ -264,6 +265,7 @@
"cmd": [
"vpython3",
"[CACHE]/builder/crosvm/tools/dev_container",
"--no-interactive",
"--verbose",
"--cros",
"true"

View file

@ -3,6 +3,7 @@
"cmd": [
"vpython3",
"[CACHE]/builder/crosvm/tools/dev_container",
"--no-interactive",
"--verbose",
"--cros",
"cros_sdk",

View file

@ -3,6 +3,7 @@
"cmd": [
"vpython3",
"[CACHE]/builder/crosvm/tools/dev_container",
"--no-interactive",
"--verbose",
"mdbook",
"build",
@ -32,6 +33,7 @@
"cmd": [
"vpython3",
"[CACHE]/builder/crosvm/tools/dev_container",
"--no-interactive",
"--verbose",
"./tools/cargo-doc",
"--target-dir",

View file

@ -28,6 +28,7 @@
"cmd": [
"vpython3",
"[CACHE]/builder/crosvm/tools/dev_container",
"--no-interactive",
"--verbose",
"tools/presubmit",
"--no-delta",
@ -55,6 +56,7 @@
"cmd": [
"vpython3",
"[CACHE]/builder/crosvm/tools/dev_container",
"--no-interactive",
"--verbose",
"tools/presubmit",
"--no-delta",
@ -86,6 +88,7 @@
"cmd": [
"vpython3",
"[CACHE]/builder/crosvm/tools/dev_container",
"--no-interactive",
"--verbose",
"./tools/build_release",
"--json",
@ -121,6 +124,7 @@
"cmd": [
"vpython3",
"[CACHE]/builder/crosvm/tools/dev_container",
"--no-interactive",
"--verbose",
"./tools/infra/binary_size",
"--builder-name",

View file

@ -28,6 +28,7 @@
"cmd": [
"vpython3",
"[CACHE]/builder/crosvm/tools/dev_container",
"--no-interactive",
"--verbose",
"tools/presubmit",
"--no-delta",
@ -55,6 +56,7 @@
"cmd": [
"vpython3",
"[CACHE]/builder/crosvm/tools/dev_container",
"--no-interactive",
"--verbose",
"tools/presubmit",
"--no-delta",

View file

@ -201,6 +201,7 @@ def main(argv: List[str]):
parser.add_argument("--clean", action="store_true")
parser.add_argument("--hermetic", action="store_true")
parser.add_argument("--interactive", action="store_true")
parser.add_argument("--no-interactive", action="store_true")
parser.add_argument("--use-docker", action="store_true")
parser.add_argument("--self-test", action="store_true")
parser.add_argument("--pull", action="store_true")
@ -277,13 +278,16 @@ def main(argv: List[str]):
# If a command is provided run non-interactive unless explicitly asked for.
tty_args = []
if not command or args.interactive:
if not sys.stdin.isatty():
raise Exception("Trying to run an interactive session in a non-interactive terminal.")
tty_args = ["--interactive", "--tty"]
elif sys.stdin.isatty():
# Even if run non-interactively, we do want to pass along a tty for proper output.
tty_args = ["--tty"]
if not args.no_interactive:
if not command or args.interactive:
if not sys.stdin.isatty():
raise Exception(
"Trying to run an interactive session in a non-interactive terminal."
)
tty_args = ["--interactive", "--tty"]
elif sys.stdin.isatty():
# Even if run non-interactively, we do want to pass along a tty for proper output.
tty_args = ["--tty"]
# Start an interactive shell by default
if args.hermetic: