Copilot commented on code in PR #64124:
URL: https://github.com/apache/airflow/pull/64124#discussion_r3025334173


##########
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:
   The cache-hit condition can become a false positive if `node_modules/` is 
modified outside this hook (e.g., running `pnpm install` manually or via 
another prek hook) without updating `.build/ui/pnpm-install-hash.txt`. In that 
case `current_hash == stored_hash` can still be true while `node_modules` no 
longer corresponds to the current lockfile, causing the hook to skip the needed 
install and then run eslint/tsc against mismatched deps. Consider adding an 
extra validity check tied to the actual `node_modules` state (e.g., compare 
timestamps, or read pnpm’s `node_modules/.modules.yaml` lockfile checksum) 
before skipping.



-- 
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]

Reply via email to