codeant-ai-for-open-source[bot] commented on code in PR #45610:
URL: https://github.com/apache/superset/pull/45610#discussion_r4345306678


##########
.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:
   Yes—both approaches avoid the `pipefail`/`SIGPIPE` issue.
   
   The smallest change is to use a here-string, which removes the `printf | 
grep` pipeline:
   
   ```bash
   if grep -qE '^(superset-frontend|superset-websocket)/' <<< 
"${CHANGED_FILES}"; then frontend=true; fi
   ```
   
   Alternatively, `printf '%s\n' "${CHANGED_FILES}" | grep -E '…' >/dev/null` 
works because `grep` reads the entire input when not given `-q`. I’d prefer the 
here-string: it preserves the early-exit behavior without risking a broken pipe.



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