LuciferYang commented on code in PR #13762:
URL: https://github.com/apache/gluten/pull/13762#discussion_r4705652625


##########
.github/workflows/velox_backend_x86.yml:
##########
@@ -224,7 +225,7 @@ jobs:
           match() { echo "$changed" | grep -qE "$1" && echo true || echo 
false; }
 
           echo "cpp=$(match      '^(cpp/|ep/build-velox/|dev/)')"              
                              >> $GITHUB_OUTPUT
-          echo "java=$(match     
'^(\.github/(workflows|actions)/|pom\.xml|backends-velox/|gluten-(uniffle|celeborn|ras|core|substrait|arrow|delta|iceberg|hudi|paimon)/|gluten-ut/(common/|test/|src-iceberg-upstream/|pom\.xml)|package/|build/mvn)')"
 >> $GITHUB_OUTPUT
+          echo "java=$(match     
'^(\.github/workflows/(velox_backend_x86|velox_native_build|iceberg_spark_ut|iceberg_upstream_revision)\.yml$|\.github/workflows/util/(parallel-ut/|iceberg-upstream/|install-spark-deps\.sh$)|\.github/actions/|pom\.xml|backends-velox/|gluten-(uniffle|celeborn|ras|core|substrait|arrow|delta|iceberg|hudi|paimon)/|gluten-ut/(common/|test/|src-iceberg-upstream/|pom\.xml)|package/|build/mvn)')"
 >> $GITHUB_OUTPUT

Review Comment:
   With the narrowing, the `.github` part of this `java` regex has to match the 
`paths` input at line 126 and the `paths:` trigger by hand, and the same holds 
for ARM line 140. The comment at line 125 only mentions two lists. If a later 
PR adds a script under `.github/workflows/util/` to both path lists but not 
here, a fork run for a change to only that script builds the native library, 
skips every test job, and reports "Passed in the fork".
   
   Could the comment at line 125 name this regex as the third list, and the 
`java` legend at line 136 mention the workflow files? Writing the `.github` 
alternatives in the same order as `paths` would also make the two easy to 
compare.



##########
.github/workflows/util/update-fork-build-status.js:
##########
@@ -53,6 +68,40 @@ function isTransient(e) {
 
 const runPath = (w) => '.github/workflows/' + w.file;
 
+// The `paths` and `paths-ignore` regexes the workflow passes to 
squash-merge-upstream,
+// read from its file so that the two cannot drift apart. Only the `with:` 
block of that
+// step is searched, and a value may be single- or double-quoted and followed 
by a
+// comment. Returns null, so that the workflow counts as relevant for every 
pull
+// request, when the inputs can't be read; a warning is logged instead of 
failing the
+// pass, which would stop the statuses of every pull request.
+function pathFilterOf(w, core) {
+  try {
+    const text = fs.readFileSync(path.join(process.env.GITHUB_WORKSPACE || 
'.', runPath(w)), 'utf8');
+    const lines = text.split('\n');
+    const start = lines.findIndex((l) => 
/^\s*(-\s+)?uses:\s*\.\/\.github\/actions\/squash-merge-upstream\s*$/.test(l));
+    if (start < 0) throw new Error('no squash-merge-upstream step');
+    // The step ends at the next step or at a line indented less than its 
`uses:`.
+    const indent = lines[start].search(/\S/);
+    let end = start + 1;
+    while (end < lines.length && !/^\s*-\s/.test(lines[end]) &&
+           (lines[end].trim() == '' || lines[end].search(/\S/) >= indent)) 
end++;
+    const step = lines.slice(start + 1, end);
+    const input = (name) => {
+      for (const l of step) {
+        const m = new 
RegExp(`^\\s*${name}:\\s*(?:'((?:[^']|'')*)'|"((?:[^"\\\\]|\\\\.)*)")\\s*(#.*)?$`).exec(l);
+        if (m) return m[1] !== undefined ? m[1].replace(/''/g, "'") : 
JSON.parse(`"${m[2]}"`);
+      }
+      return null;
+    };
+    const paths = input('paths');
+    if (!paths) throw new Error('no quoted one-line `paths` input in the 
squash-merge-upstream step');
+    return { paths: new RegExp(paths), ignore: new 
RegExp(input('paths-ignore') || '^$') };

Review Comment:
   `pathFilterOf` returns null with a warning for most inputs it can't read, 
but two valid forms get a wrong filter instead. A quoted expression such as 
`paths: '${{ env.VELOX_CI_PATHS }}'` is compiled literally, and that regex 
matches no path, so every fork PR pushed after that edit without a run would 
show a green "Not needed", `cpp/` changes included. An unquoted or block-scalar 
`paths-ignore` becomes `^$` at line 98, with no warning.
   
   Could the function throw, and so return null, when a value contains `${{`, 
and when a `paths-ignore:` key is present but `input()` can't read it? Keeping 
`^$` only for a missing key matches the action's default.



##########
.github/workflows/util/update-fork-build-status.js:
##########
@@ -179,11 +254,15 @@ module.exports = async ({ github, context, core }) => {
         // Two branches can share a head commit; the newer run keeps the 
status.
         if (at && at.id > run.id) continue;
         if (at && at.id == run.id && at.attempt == run.run_attempt && 
isFinal(current)) continue;
-        const next = statusOf(run, await jobsOf(pr, run));
-        const same = current && ['state', 'description', 
'target_url'].every((k) => current[k] == next[k]);
-        if (!same) await setStatus(pr, w, next);
-      } else if (!current) {
-        await setStatus(pr, w, { state: 'error', target_url: SETUP_URL, 
description: NO_RUN });
+        // The run decides for itself, after merging onto main, whether to 
skip its jobs.
+        await update(w, current, statusOf(run, await jobsOf(pr, run)));
+      } else if (!current || current.description == LEGACY_NO_RUN) {
+        // Leave an old error for a pass that can read the workflow's paths.
+        if (current && filters.get(w.file) === null) continue;
+        const next = (await isRelevant(w))

Review Comment:
   When a workflow's `paths` input can't be parsed, `isRelevant` returns true 
(line 241) and this branch writes `NO_RUN`, which tells the author the commit 
"changes files this workflow tests". Nothing checked that, and the status is 
final, since line 259 only rechecks `LEGACY_NO_RUN`. So if a later edit to one 
of the three workflow files trips the parser, which only logs a warning, every 
Flink-only PR whose fork has no run gets the red error this PR removes, with a 
wrong reason. Fixing the YAML doesn't clear it; the author has to push again.
   
   Could this branch write `LEGACY_NO_RUN` when `filters.get(w.file)` is null, 
and the comment at line 47 say that the script still writes it then? Line 261 
already leaves that text for a pass that can read the filter, so those PRs 
would get the same one recheck as the old errors.



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