Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci_build: Add fail-fast option #847

Merged
merged 3 commits into from
Jul 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions edk2toolext/invocables/edk2_ci_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,14 @@
"""Adds command line arguments to Edk2CiBuild."""
parser.add_argument('-d', '--disable-all', dest="disable", action="store_true", default=False,
help="Disable all plugins. Use <PluginName>=run to re-enable specific plugins")
parser.add_argument('-f', '--fail-fast', dest="fail_fast", action="store_true", default=False,
help="Exit on the first plugin failure.")
super().AddCommandLineOptions(parser)

def RetrieveCommandLineOptions(self, args: argparse.Namespace) -> None:
"""Retrieve command line options from the argparser."""
self.disable_plugins = args.disable
self.fail_fast = args.fail_fast
super().RetrieveCommandLineOptions(args)

def GetSettingsClass(self) -> type:
Expand Down Expand Up @@ -242,23 +245,24 @@
env, self.plugin_manager, self.helper,
tc, plugin_output_stream)
except Exception as exp:
exc_type, exc_value, exc_traceback = sys.exc_info()
_, _, exc_traceback = sys.exc_info()

Check warning on line 248 in edk2toolext/invocables/edk2_ci_build.py

View check run for this annotation

Codecov / codecov/patch

edk2toolext/invocables/edk2_ci_build.py#L248

Added line #L248 was not covered by tests
logging.critical("EXCEPTION: {0}".format(exp))
exceptionPrint = traceback.format_exception(type(exp), exp, exc_traceback)
logging.critical(" ".join(exceptionPrint))
tc.SetError("Exception: {0}".format(
exp), "UNEXPECTED EXCEPTION")
rc = 1

if (rc > 0):
if rc is None or rc > 0:

Check warning on line 256 in edk2toolext/invocables/edk2_ci_build.py

View check run for this annotation

Codecov / codecov/patch

edk2toolext/invocables/edk2_ci_build.py#L256

Added line #L256 was not covered by tests
failure_num += 1
if (rc is None):
logging.error(
f"--->Test Failed: {Descriptor.Name} {target} returned NoneType")
else:
logging.error(
f"--->Test Failed: {Descriptor.Name} {target} returned {rc}")
elif (rc < 0):
logging.error(

Check warning on line 258 in edk2toolext/invocables/edk2_ci_build.py

View check run for this annotation

Codecov / codecov/patch

edk2toolext/invocables/edk2_ci_build.py#L258

Added line #L258 was not covered by tests
f"--->Test Failed: {Descriptor.Name} {target} returned \"{rc}\"")

if self.fail_fast:
logging.error('Exiting Early due to --fail-fast flag.')
JunitReport.Output(os.path.join(self.GetWorkspaceRoot(), "Build", "TestSuites.xml"))
return failure_num
elif rc < 0:

Check warning on line 265 in edk2toolext/invocables/edk2_ci_build.py

View check run for this annotation

Codecov / codecov/patch

edk2toolext/invocables/edk2_ci_build.py#L261-L265

Added lines #L261 - L265 were not covered by tests
logging.warn(f"--->Test Skipped: in plugin! {Descriptor.Name} {target}")
else:
edk2_logging.log_progress(f"--->Test Success: {Descriptor.Name} {target}")
Expand Down