dstandish commented on code in PR #64124:
URL: https://github.com/apache/airflow/pull/64124#discussion_r3509364401
##########
scripts/ci/prek/ts_compile_lint_ui.py:
##########
@@ -50,8 +52,20 @@
all_ts_files.append("src/vite-env.d.ts")
print("All TypeScript files:", all_ts_files)
- run_command(["pnpm", "config", "set", "store-dir", ".pnpm-store"], cwd=dir)
- run_command(["pnpm", "install", "--frozen-lockfile",
"--config.confirmModulesPurge=false"], cwd=dir)
+ hash_file = AIRFLOW_ROOT_PATH / ".build" / "ui" / "pnpm-install-hash.txt"
+ node_modules = dir / "node_modules"
+ current_hash = hashlib.sha256(
+ (dir / "package.json").read_bytes() + (dir /
"pnpm-lock.yaml").read_bytes()
+ ).hexdigest()
+ stored_hash = hash_file.read_text().strip() if hash_file.exists() else ""
+
+ if node_modules.exists() and current_hash == stored_hash:
+ print("pnpm deps unchanged — skipping install.")
+ else:
+ run_command(["pnpm", "config", "set", "store-dir", ".pnpm-store"],
cwd=dir)
+ run_command(["pnpm", "install", "--frozen-lockfile",
"--config.confirmModulesPurge=false"], cwd=dir)
Review Comment:
Good catch. I added an mtime guard: the cache is only trusted if the hash
file's mtime is >= node_modules' mtime, so any modification to node_modules
after the hash was last written (manual `pnpm install`, another hook, etc.)
invalidates the cache. Fixed in 9ced3a1cec.
---
Drafted-by: Claude Code (Sonnet 5) (no human review before posting)
##########
scripts/ci/prek/ts_compile_lint_ui.py:
##########
@@ -50,8 +52,20 @@
all_ts_files.append("src/vite-env.d.ts")
print("All TypeScript files:", all_ts_files)
- run_command(["pnpm", "config", "set", "store-dir", ".pnpm-store"], cwd=dir)
- run_command(["pnpm", "install", "--frozen-lockfile",
"--config.confirmModulesPurge=false"], cwd=dir)
+ hash_file = AIRFLOW_ROOT_PATH / ".build" / "ui" / "pnpm-install-hash.txt"
+ node_modules = dir / "node_modules"
+ current_hash = hashlib.sha256(
+ (dir / "package.json").read_bytes() + (dir /
"pnpm-lock.yaml").read_bytes()
+ ).hexdigest()
Review Comment:
Applied — now hashing each file with a `name:length:` prefix before its
bytes, so the digest can't collide across different (package.json,
pnpm-lock.yaml) content splits. Fixed in 9ced3a1cec.
---
Drafted-by: Claude Code (Sonnet 5) (no human review before posting)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]