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

Fix python files detection in format and lint scripts #501

Merged
merged 2 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
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
8 changes: 5 additions & 3 deletions cbmc/proofs/lib/print_tool_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ def _format_versions(table):
if version:
v_str = f'<code><pre style="margin: 0">{version}</pre></code>'
else:
v_str = '<em>not found</em>'
v_str = "<em>not found</em>"
lines.append(
f'<tr><td style="font-weight: bold; padding-right: 1em; '
f'text-align: right;">{tool}:</td>'
f'<td>{v_str}</td></tr>')
f"<td>{v_str}</td></tr>"
)
lines.append("</table>")
return "\n".join(lines)

Expand All @@ -55,7 +56,8 @@ def _get_tool_versions():
continue
if proc.returncode:
logging.error(
"%s'%s --version' returned %s", err, tool, str(proc.returncode))
"%s'%s --version' returned %s", err, tool, str(proc.returncode)
)
continue
ret[tool] = out.strip()
return ret
Expand Down
18 changes: 10 additions & 8 deletions cbmc/proofs/lib/summarize.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
def get_args():
"""Parse arguments for summarize script."""
parser = argparse.ArgumentParser(description=DESCRIPTION)
for arg in [{
for arg in [
{
"flags": ["--run-file"],
"help": "path to the Litani run.json file",
"required": True,
}]:
}
]:
flags = arg.pop("flags")
parser.add_argument(*flags, **arg)
return parser.parse_args()
Expand Down Expand Up @@ -111,7 +113,7 @@ def print_proof_results(out_file):
When printing, each string will render as a GitHub flavored Markdown table.
"""
output = "## Summary of CBMC proof results\n\n"
with open(out_file, encoding='utf-8') as run_json:
with open(out_file, encoding="utf-8") as run_json:
run_dict = json.load(run_json)
status_table, proof_table = _get_status_and_proof_summaries(run_dict)
for summary in (status_table, proof_table):
Expand All @@ -126,23 +128,23 @@ def print_proof_results(out_file):
print(output, file=handle)
handle.flush()
else:
logging.warning(
"$GITHUB_STEP_SUMMARY not set, not writing summary file")
logging.warning("$GITHUB_STEP_SUMMARY not set, not writing summary file")

msg = (
"Click the 'Summary' button to view a Markdown table "
"summarizing all proof results")
"summarizing all proof results"
)
if run_dict["status"] != "success":
logging.error("Not all proofs passed.")
logging.error(msg)
sys.exit(1)
logging.info(msg)


if __name__ == '__main__':
if __name__ == "__main__":
args = get_args()
logging.basicConfig(format="%(levelname)s: %(message)s")
try:
print_proof_results(args.run_file)
except Exception as ex: # pylint: disable=broad-except
except Exception as ex: # pylint: disable=broad-except
logging.critical("Could not print results. Exception: %s", str(ex))
Loading
Loading