Skip to content

Commit

Permalink
Add summary to result file (#99)
Browse files Browse the repository at this point in the history
Signed-off-by: hoangtungdinh <[email protected]>
Co-authored-by: hoangtungdinh <[email protected]>
  • Loading branch information
hoangtungdinh and hoangtungdinh committed Sep 25, 2024
1 parent a0c2dec commit 7ee1c24
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 10 deletions.
16 changes: 8 additions & 8 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions qc_opendrive/checks/basic/version_is_defined.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ def check_rule(checker_data: models.CheckerData) -> bool:
status=StatusType.SKIPPED,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME,
CHECKER_ID,
f"The xml file does not contains the 'header' tag.",
)

return True

# Check if 'header' has the attributes 'revMajor' and 'revMinor'
Expand Down
6 changes: 6 additions & 0 deletions qc_opendrive/checks/schema/valid_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ def check_rule(checker_data: models.CheckerData) -> None:
status=StatusType.SKIPPED,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME,
CHECKER_ID,
f"Cannot find the schema file for ASAM OpenDrive version {schema_version}.",
)

return

xsd_file_path = str(
Expand Down
21 changes: 19 additions & 2 deletions qc_opendrive/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ def execute_checker(
status=StatusType.SKIPPED,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME,
checker.CHECKER_ID,
"Preconditions are not satisfied. Skip the check.",
)

return

# Checker definition setting. If not satisfied then set status as SKIPPED and return
Expand All @@ -82,6 +88,12 @@ def execute_checker(
status=StatusType.SKIPPED,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME,
checker.CHECKER_ID,
f"Version {schema_version} is lower than definition setting {definition_setting}. Skip the check.",
)

return

# Execute checker
Expand All @@ -98,14 +110,18 @@ def execute_checker(
checker_id=checker.CHECKER_ID,
status=StatusType.COMPLETED,
)
except Exception:
except Exception as e:
# If any exception occurs during the check, set the status as ERROR
checker_data.result.set_checker_status(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=checker.CHECKER_ID,
status=StatusType.ERROR,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME, checker.CHECKER_ID, f"Error: {str(e)}."
)


def run_checks(config: Configuration, result: Result) -> None:
checker_data = models.CheckerData(
Expand Down Expand Up @@ -213,7 +229,8 @@ def main():
result.write_to_file(
config.get_checker_bundle_param(
checker_bundle_name=constants.BUNDLE_NAME, param_name="resultFile"
)
),
generate_summary=True,
)

if args.generate_markdown:
Expand Down

0 comments on commit 7ee1c24

Please sign in to comment.