vars: commit validation hashes

This commit is contained in:
Jörg Thalheim
2024-12-25 20:36:50 +01:00
parent 42e56b1afe
commit bc48ec738b
2 changed files with 12 additions and 3 deletions

View File

@@ -132,13 +132,14 @@ class StoreBase(ABC):
return None
return hash_file.read_text().strip()
def set_validation(self, generator: "Generator", hash_str: str) -> None:
def set_validation(self, generator: "Generator", hash_str: str) -> Path:
"""
Store the invalidation hash that indicates if a generator needs to be re-run
"""
hash_file = self.directory(generator, ".validation-hash")
hash_file.parent.mkdir(parents=True, exist_ok=True)
hash_file.write_text(hash_str)
return hash_file
def hash_is_valid(self, generator: "Generator") -> bool:
"""

View File

@@ -236,9 +236,17 @@ def execute_generator(
files_to_commit.append(file_path)
if generator.validation is not None:
if public_changed:
public_vars_store.set_validation(generator, generator.validation)
files_to_commit.append(
public_vars_store.set_validation(
generator, generator.validation
)
)
if secret_changed:
secret_vars_store.set_validation(generator, generator.validation)
files_to_commit.append(
secret_vars_store.set_validation(
generator, generator.validation
)
)
commit_files(
files_to_commit,
machine.flake_dir,