sadpandajoe commented on code in PR #45610:
URL: https://github.com/apache/superset/pull/45610#discussion_r4345303422


##########
.github/workflows/pre-commit.yml:
##########
@@ -151,6 +126,56 @@ jobs:
             } >> "$GITHUB_OUTPUT"
           fi
 
+      # The frontend and docs hooks are the only ones that need node_modules,
+      # and prek only runs hooks whose file filters match the changed files.
+      # Skip the installs (about 30 s for superset-frontend, 60 s for docs)
+      # when nothing under those trees changed; "all" (schedules, or no diff
+      # base) still installs both.
+      - name: Determine which node dependencies the hooks need
+        id: node_deps
+        env:
+          MODE: ${{ steps.changed_files.outputs.mode }}
+          CHANGED_FILES: ${{ steps.changed_files.outputs.files }}
+        run: |
+          set -euo pipefail
+          frontend=false; docs=false
+          if [ "${MODE}" = "all" ]; then
+            frontend=true; docs=true
+          elif [ "${MODE}" = "files" ]; then
+            if printf '%s\n' "${CHANGED_FILES}" | grep -qE 
'^(superset-frontend|superset-websocket)/'; then frontend=true; fi

Review Comment:
   Agreed—when the changed-file list is large (just under the 100,000-byte 
cutoff), `grep -q` exits on its first match while `printf` is still writing; 
under `pipefail` the pipeline returns 141, the `if` treats it as false, and the 
step still exits 0. That leaves `frontend=false`/`docs=false` even though 
matching hooks run, so `oxlint-docs` and the frontend hooks then execute 
without installed dependencies. Would feeding the list through a here-string 
(or `grep -E ... >/dev/null`) so the whole input is consumed work here?



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to