Skip to content

Commit 6520dca

Browse files
committed
Include GDS hash in precheck results
Compute the SHA-1 hash of the user_project_wrapper GDS file and store it in the precheck results blob under the gds_hash key. This ties precheck results to a specific design revision so stale results can be detected when the GDS changes. Made-with: Cursor
1 parent 2eb90cf commit 6520dca

3 files changed

Lines changed: 16 additions & 3 deletions

File tree

src/cf_precheck/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.0.2"
1+
__version__ = "1.1.0"

src/cf_precheck/results.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def to_dict(self) -> dict:
3838
@dataclass
3939
class ResultsCollector:
4040
pdk: str = ""
41+
input_file_hash: Optional[str] = None
4142
results: list[CheckResult] = field(default_factory=list)
4243

4344
def add(self, result: CheckResult) -> None:
@@ -95,13 +96,17 @@ def write_to_project_json(self, project_dir: Path) -> None:
9596
for r in self.results:
9697
checks_dict[r.name] = r.to_dict()
9798

98-
data["precheck"] = {
99+
precheck_blob: dict = {
99100
"version": __version__,
100101
"timestamp": datetime.now(timezone.utc).isoformat(),
101102
"pdk": self.pdk,
102103
"passed": self.all_passed,
103104
"checks": checks_dict,
104105
}
106+
if self.input_file_hash:
107+
precheck_blob["input_file_hash"] = self.input_file_hash
108+
109+
data["precheck"] = precheck_blob
105110

106111
project_json_path.write_text(json.dumps(data, indent=2) + "\n")
107112
console.print(f"[dim]Results saved to {project_json_path}[/dim]")

src/cf_precheck/runner.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,15 @@ def run_precheck(
106106
skip=skip_checks,
107107
)
108108

109-
collector = ResultsCollector(pdk=pdk)
109+
input_file_hash = None
110+
gds_path = input_directory / f"gds/{project_config['user_module']}.gds"
111+
if gds_path.exists():
112+
try:
113+
input_file_hash = file_hash(gds_path)
114+
except Exception:
115+
pass
116+
117+
collector = ResultsCollector(pdk=pdk, input_file_hash=input_file_hash)
110118
total = len(sequence)
111119
idx_width = len(str(total))
112120

0 commit comments

Comments
 (0)