From 104ac5b9654c82450cd8290d4c663c3b2f4d4c85 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 13 Jul 2022 14:53:25 -0500 Subject: [PATCH 1/2] signal errors in ci_fetch_deps subprocesses A recent build failed. The original error seemed to be during ci_fetch_deps where a build message said ``` fatal: reference is not a tree: 346c936e14c6ea3a8d3d65cb1fa46202dc92999d fatal: Unable to checkout '346c936e14c6ea3a8d3d65cb1fa46202dc92999d' in submodule path 'extmod/ulab' ``` (along with other problems), but this step didn't signal failure to github actions. By adding the check= parameter, a failure of the subprocess will cause a CalledProcessError to be raised, which will make ci_fetch_deps exit with nonzero status. In turn, this should let Actions understand that something went wrong with this step, instead of waiting for some subsequent step(s) to go wrong. --- tools/ci_fetch_deps.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/ci_fetch_deps.py b/tools/ci_fetch_deps.py index 491d8da0e5..44295a06e9 100644 --- a/tools/ci_fetch_deps.py +++ b/tools/ci_fetch_deps.py @@ -47,9 +47,11 @@ def run(title, command): print("::group::" + title, flush=True) print(command, flush=True) start = time.monotonic() - subprocess.run(shlex.split(command), stderr=subprocess.STDOUT) - print("Duration:", time.monotonic() - start, flush=True) - print("::endgroup::", flush=True) + try: + subprocess.run(shlex.split(command), stderr=subprocess.STDOUT, check=True) + finally: + print("Duration:", time.monotonic() - start, flush=True) + print("::endgroup::", flush=True) run( From 8cdbeb62f6ded5f83ad73de4f66ab446b2fff583 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 14 Jul 2022 15:16:28 -0500 Subject: [PATCH 2/2] Pass check=False for an expected-fail command --- tools/ci_fetch_deps.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/ci_fetch_deps.py b/tools/ci_fetch_deps.py index 44295a06e9..55985ffe15 100644 --- a/tools/ci_fetch_deps.py +++ b/tools/ci_fetch_deps.py @@ -43,12 +43,12 @@ port_deps = { } -def run(title, command): +def run(title, command, check=True): print("::group::" + title, flush=True) print(command, flush=True) start = time.monotonic() try: - subprocess.run(shlex.split(command), stderr=subprocess.STDOUT, check=True) + subprocess.run(shlex.split(command), stderr=subprocess.STDOUT, check=check) finally: print("Duration:", time.monotonic() - start, flush=True) print("::endgroup::", flush=True) @@ -108,7 +108,11 @@ if submodules: submodules = " ".join(submodules) # This line will fail because the submodule's need different commits than the tip of the branch. We # fix it later. - run("Init the submodules we'll need", f"git submodule update --init -N --depth 1 {submodules}") + run( + "Init the submodules we'll need", + f"git submodule update --init -N --depth 1 {submodules}", + check=False, + ) run( "Fetch the submodule sha",