[dvsim] Add git commit and branch info to reports
Signed-off-by: Michael Schaffner <msf@google.com>
diff --git a/hw/data/common_project_cfg.hjson b/hw/data/common_project_cfg.hjson
index 68f9ea9..4558c72 100644
--- a/hw/data/common_project_cfg.hjson
+++ b/hw/data/common_project_cfg.hjson
@@ -25,4 +25,12 @@
results_summary_server_html: "summary.html"
results_summary_server_page: "{results_server_path}/{results_summary_server_html}"
+
+ // If defined, this is printed into the results md files
+ revision_string: '''{eval_cmd}
+ COMMIT_SHORT=`git log -n 1 --abbrev-commit | head -n 1 | awk -F ' ' '{print $2}'`; \
+ COMMIT_LONG=`git log -n 1 | head -n 1 | awk -F ' ' '{print $2}'`; \
+ BRANCH=`git rev-parse --abbrev-ref HEAD`; \
+ echo "Revision: [\`$COMMIT_SHORT\`](https://github.com/lowrisc/opentitan/tree/$COMMIT_LONG) on \`$BRANCH\`";
+ '''
}
diff --git a/util/dvsim/FlowCfg.py b/util/dvsim/FlowCfg.py
index cf6c100..fec3c46 100644
--- a/util/dvsim/FlowCfg.py
+++ b/util/dvsim/FlowCfg.py
@@ -72,6 +72,7 @@
self.errors_seen = False
self.rel_path = ""
self.results_title = ""
+ self.revision_string = ""
self.results_server_prefix = ""
self.results_server_url_prefix = ""
self.results_server_cmd = ""
diff --git a/util/dvsim/FpvCfg.py b/util/dvsim/FpvCfg.py
index 6d21ec3..3db6157 100644
--- a/util/dvsim/FpvCfg.py
+++ b/util/dvsim/FpvCfg.py
@@ -125,7 +125,10 @@
log.info("Create summary of FPV results")
results_str = "## " + self.results_title + " (Summary)\n\n"
- results_str += "### " + self.timestamp_long + "\n\n"
+ results_str += "### " + self.timestamp_long + "\n"
+ if self.revision_string:
+ results_str += "### " + self.revision_string + "\n"
+ results_str += "\n"
colalign = ("center", ) * len(self.summary_header)
table = [self.summary_header]
@@ -216,6 +219,8 @@
# }
results_str = "## " + self.results_title + "\n\n"
results_str += "### " + self.timestamp_long + "\n"
+ if self.revision_string:
+ results_str += "### " + self.revision_string + "\n"
results_str += "### FPV Tool: " + self.tool.upper() + "\n"
results_str += "### LogFile dir: " + self.scratch_path + "/default\n\n"
diff --git a/util/dvsim/LintCfg.py b/util/dvsim/LintCfg.py
index 54d627e..b355b20 100644
--- a/util/dvsim/LintCfg.py
+++ b/util/dvsim/LintCfg.py
@@ -47,7 +47,11 @@
log.info("Create summary of lint results")
results_str = "## " + self.results_title + " (Summary)\n\n"
- results_str += "### " + self.timestamp_long + "\n\n"
+ results_str += "### " + self.timestamp_long + "\n"
+ if self.revision_string:
+ results_str += "### " + self.revision_string + "\n"
+ results_str += "\n"
+
header = [
"Name", "Tool Warnings", "Tool Errors", "Lint Warnings",
@@ -110,6 +114,8 @@
# Generate results table for runs.
results_str = "## " + self.results_title + "\n\n"
results_str += "### " + self.timestamp_long + "\n"
+ if self.revision_string:
+ results_str += "### " + self.revision_string + "\n"
results_str += "### Lint Tool: " + self.tool.upper() + "\n\n"
header = [
diff --git a/util/dvsim/SimCfg.py b/util/dvsim/SimCfg.py
index e6a2361..62516d7 100644
--- a/util/dvsim/SimCfg.py
+++ b/util/dvsim/SimCfg.py
@@ -576,6 +576,8 @@
# Generate results table for runs.
results_str = "## " + self.results_title + "\n"
results_str += "### " + self.timestamp_long + "\n"
+ if self.revision_string:
+ results_str += "### " + self.revision_string + "\n"
# Add path to testplan.
if hasattr(self, "testplan_doc_path"):
@@ -648,6 +650,8 @@
table.append(row)
self.results_summary_md = "## " + self.results_title + " (Summary)\n"
self.results_summary_md += "### " + self.timestamp_long + "\n"
+ if self.revision_string:
+ self.results_summary_md += "### " + self.revision_string + "\n"
self.results_summary_md += tabulate(table,
headers="firstrow",
tablefmt="pipe",
diff --git a/util/dvsim/SynCfg.py b/util/dvsim/SynCfg.py
index 4e329db..270ebf4 100644
--- a/util/dvsim/SynCfg.py
+++ b/util/dvsim/SynCfg.py
@@ -35,7 +35,10 @@
log.info("Create summary of synthesis results")
results_str = "## " + self.results_title + " (Summary)\n\n"
- results_str += "### " + self.timestamp_long + "\n\n"
+ results_str += "### " + self.timestamp_long + "\n"
+ if self.revision_string:
+ results_str += "### " + self.revision_string + "\n"
+ results_str += "\n"
self.results_summary_md = results_str + "\nNot supported yet.\n"
@@ -142,6 +145,8 @@
# Generate results table for runs.
results_str = "## " + self.results_title + "\n\n"
results_str += "### " + self.timestamp_long + "\n"
+ if self.revision_string:
+ results_str += "### " + self.revision_string + "\n"
results_str += "### Synthesis Tool: " + self.tool.upper() + "\n\n"
# TODO: extend this to support multiple build modes