Skip to content

Commit 835926b

Browse files
committed
fix: use git commit directly from git
Signed-off-by: James McCorrie <[email protected]>
1 parent 0cbdc49 commit 835926b

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

src/dvsim/flow/base.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import json
88
import os
99
import pprint
10-
import re
1110
import sys
1211
from abc import ABC, abstractmethod
1312
from collections.abc import Mapping, Sequence
@@ -29,6 +28,7 @@
2928
rm_path,
3029
subst_wildcards,
3130
)
31+
from dvsim.utils.git import git_commit_hash
3232

3333
if TYPE_CHECKING:
3434
from dvsim.job.deploy import Deploy
@@ -455,6 +455,9 @@ def gen_results(self, results: Sequence[CompletedJobStatus]) -> None:
455455
456456
"""
457457
reports_dir = Path(self.scratch_base_path) / "reports"
458+
commit = git_commit_hash(path=Path(self.proj_root))
459+
url = f"https://github.com/lowrisc/opentitan/tree/{commit}"
460+
458461
all_flow_results: Mapping[str, FlowResults] = {}
459462

460463
for item in self.cfgs:
@@ -464,7 +467,11 @@ def gen_results(self, results: Sequence[CompletedJobStatus]) -> None:
464467
if res.block.name == item.name and res.block.variant == item.variant
465468
]
466469

467-
flow_results: FlowResults = item._gen_json_results(item_results)
470+
flow_results: FlowResults = item._gen_json_results(
471+
run_results=item_results,
472+
commit=commit,
473+
url=url,
474+
)
468475

469476
# Convert to lowercase to match filename
470477
block_result_index = (
@@ -491,20 +498,13 @@ def gen_results(self, results: Sequence[CompletedJobStatus]) -> None:
491498
.isoformat()
492499
)
493500

494-
# Extract Git properties.
495-
m = re.search(
496-
r"https://github.com/.+?/tree/([0-9a-fA-F]+)",
497-
self.revision,
498-
)
499-
commit = m.group(1) if m else None
500-
501501
results_summary = ResultsSummary(
502502
top=IPMeta(
503503
name=self.name,
504504
variant=self.variant,
505-
commit=str(commit),
505+
commit=commit,
506506
branch=self.branch,
507-
url=self.revision,
507+
url=url,
508508
),
509509
timestamp=timestamp,
510510
flow_results=all_flow_results,

src/dvsim/flow/sim.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"""Class describing simulation configuration object."""
66

77
import fnmatch
8-
import re
98
import sys
109
from collections import OrderedDict, defaultdict
1110
from collections.abc import Sequence
@@ -574,11 +573,18 @@ def cov_unr(self) -> None:
574573
for item in self.cfgs:
575574
item._cov_unr()
576575

577-
def _gen_json_results(self, run_results: Sequence[CompletedJobStatus]) -> FlowResults:
576+
def _gen_json_results(
577+
self,
578+
run_results: Sequence[CompletedJobStatus],
579+
commit: str,
580+
url: str,
581+
) -> FlowResults:
578582
"""Generate structured FlowResults from simulation run data.
579583
580584
Args:
581585
run_results: completed job status.
586+
commit: git commit Hash
587+
url: for the IP source
582588
583589
Returns:
584590
Flow results object.
@@ -591,15 +597,12 @@ def _gen_json_results(self, run_results: Sequence[CompletedJobStatus]) -> FlowRe
591597
# --- Metadata ---
592598
timestamp = datetime.strptime(self.timestamp, TS_FORMAT).replace(tzinfo=timezone.utc)
593599

594-
commit_match = re.search(r"github.com/.+?/tree/([0-9a-f]{7,40})", self.revision)
595-
commit = commit_match.group(1) if commit_match else None
596-
597600
block = IPMeta(
598601
name=self.name.lower(),
599602
variant=(self.variant or "").lower() or None,
600-
commit=commit or "",
603+
commit=commit,
601604
branch=self.branch or "",
602-
url=f"https://github.com/lowrisc/opentitan/tree/{commit}" if commit else "",
605+
url=url,
603606
)
604607
tool = ToolMeta(name=self.tool.lower(), version="unknown")
605608

0 commit comments

Comments
 (0)