This is an automated email from the ASF dual-hosted git repository.

philo-he pushed a commit to branch ci-skip-spark-for-flink-changes
in repository https://gitbox.apache.org/repos/asf/gluten.git

commit 46e791220b1fba033194e3bfa78bbebbc7bc12c0
Author: Philo He <[email protected]>
AuthorDate: Mon Nov 23 05:06:55 2026 +0000

    [GLUTEN-13541][CI] Report fork Velox runs only for pull requests that 
change files they test
    
    A pull request that changes only .github/workflows/flink.yml and Flink 
module
    code (gluten-flink/**) matches none of the paths that the Gluten Spark
    workflows cover (velox_backend_x86.yml, velox_backend_arm.yml and
    velox_kafka.yml). Those workflows run no tests for it, either upstream or in
    the fork. Even so, it got error statuses "Velox Backend (x86) in fork",
    "Velox Backend (ARM) in fork" and "Velox Kafka in fork" when its fork had no
    run, because update-fork-build-status.js did not look at the changed files.
    
    update-fork-build-status.js now matches the pull request's changed files
    against the paths/paths-ignore inputs each workflow passes to
    squash-merge-upstream, read from the workflow file. A workflow that covers
    none of them gets a passing "Not needed" status. Statuses that earlier
    versions wrote without this check are rechecked once.
    
    detect-changes in velox_backend_x86.yml and velox_backend_arm.yml no longer
    sets java=true for any file under .github/workflows/, only for the files of
    that workflow. Before, a pull request that changed flink.yml together with
    Gluten's native code under cpp/ (the C++ library the Spark Velox backend
    uses) ran every Spark test job. It now runs only the jobs that the cpp/
    change needs, the same as a cpp/-only change.
---
 .github/workflows/update_fork_build_status.yml     |  8 ++-
 .github/workflows/util/update-fork-build-status.js | 69 ++++++++++++++++++++--
 .github/workflows/velox_backend_arm.yml            |  2 +-
 .github/workflows/velox_backend_x86.yml            |  2 +-
 4 files changed, 72 insertions(+), 9 deletions(-)

diff --git a/.github/workflows/update_fork_build_status.yml 
b/.github/workflows/update_fork_build_status.yml
index 1810c28d8b..9462f84f1c 100644
--- a/.github/workflows/update_fork_build_status.yml
+++ b/.github/workflows/update_fork_build_status.yml
@@ -45,7 +45,13 @@ jobs:
     steps:
       - uses: actions/checkout@v7
         with:
-          sparse-checkout: .github/workflows/util/update-fork-build-status.js
+          # Only these files are checked out. The script also opens the three 
workflow
+          # files, to read which changed files each workflow tests (its 
`paths:` regex).
+          sparse-checkout: |
+            .github/workflows/util/update-fork-build-status.js
+            .github/workflows/velox_backend_x86.yml
+            .github/workflows/velox_backend_arm.yml
+            .github/workflows/velox_kafka.yml
           sparse-checkout-cone-mode: false
       - uses: actions/github-script@v9
         with:
diff --git a/.github/workflows/util/update-fork-build-status.js 
b/.github/workflows/util/update-fork-build-status.js
index 03905666e2..bcd0d7d8ee 100644
--- a/.github/workflows/util/update-fork-build-status.js
+++ b/.github/workflows/util/update-fork-build-status.js
@@ -19,6 +19,14 @@
 // the fork's push run of each workflow below as the commit status named next 
to it.
 // A check run would join the check suite of some other workflow run on the 
commit, and
 // the pull request page stops listing it once that workflow runs again.
+//
+// A workflow is only reported for a pull request that changes a file it 
covers, by the
+// `paths` and `paths-ignore` inputs its merge-upstream job passes to
+// squash-merge-upstream. Other pull requests, such as a Flink-only change, 
get a passing
+// status saying the workflow is not needed, rather than an error for a 
missing run.
+
+const fs = require('fs');
+const path = require('path');
 
 const WORKFLOWS = [
   { file: 'velox_backend_x86.yml', context: 'Velox Backend (x86) in fork' },
@@ -33,7 +41,13 @@ const PASSED = ['success', 'skipped', 'neutral'];
 
 const MAX_DESCRIPTION = 140;
 const SETUP_URL = 
'https://github.com/apache/gluten/blob/main/CONTRIBUTING.md#velox-backend-ci';
-const NO_RUN = 'No run in your fork for this commit. Enable Actions, allow all 
actions, rebase on main and push.';
+const NO_RUN =
+  'No run in your fork for this commit, which changes files this workflow 
tests. Enable Actions, allow all actions, rebase on main and push.';
+// What earlier versions wrote without checking the changed files. Rechecked 
once.
+const LEGACY_NO_RUN = 'No run in your fork for this commit. Enable Actions, 
allow all actions, rebase on main and push.';
+const NOT_NEEDED = 'Not needed: this pull request changes no file this 
workflow tests.';
+// The pull request files API lists at most this many files.
+const MAX_PR_FILES = 3000;
 const UNLISTED = 'The run failed. Its failed jobs could not be read yet.';
 // Marks a failure list that can still grow.
 const SO_FAR = ' so far';
@@ -53,6 +67,19 @@ 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.
+function pathFilterOf(w) {
+  const text = fs.readFileSync(path.join(process.env.GITHUB_WORKSPACE || '.', 
runPath(w)), 'utf8');
+  const input = (name) => {
+    const m = new RegExp(`^\\s*${name}: '(.+)'\\s*$`, 'm').exec(text);
+    return m ? m[1].replace(/''/g, "'") : null;
+  };
+  const paths = input('paths');
+  if (!paths) throw new Error(`${runPath(w)} passes no single-quoted \`paths\` 
input to squash-merge-upstream`);
+  return { paths: new RegExp(paths), ignore: new RegExp(input('paths-ignore') 
|| '^$') };
+}
+
 // The fork run attempt a status links to, or null.
 function attemptOf(s) {
   const m = /\/actions\/runs\/(\d+)\/attempts\/(\d+)$/.exec((s && 
s.target_url) || '');
@@ -90,6 +117,19 @@ function statusOf(run, jobs) {
 module.exports = async ({ github, context, core }) => {
   const repo = { owner: context.repo.owner, repo: context.repo.repo };
   const contexts = WORKFLOWS.map((w) => w.context);
+  const filters = new Map(WORKFLOWS.map((w) => [w.file, pathFilterOf(w)]));
+
+  // Files the pull request changes, including the old name of a renamed file, 
or null
+  // when the list may be cut off, in which case every workflow counts as 
relevant.
+  const listPullFiles = async (pr) => {
+    const files = await github.paginate('GET 
/repos/{owner}/{repo}/pulls/{pull_number}/files', {
+      ...repo,
+      pull_number: pr.number,
+      per_page: 100,
+    });
+    if (files.length >= MAX_PR_FILES) return null;
+    return files.flatMap((f) => (f.previous_filename ? [f.filename, 
f.previous_filename] : [f.filename]));
+  };
 
   // The latest status of each context on the commit.
   const listStatuses = async (sha) =>
@@ -171,6 +211,18 @@ module.exports = async ({ github, context, core }) => {
     // Only a workflow with nothing reported yet can have a run that hasn't 
registered.
     const fresh = WORKFLOWS.filter((w) => !statusOfContext(w) && 
legacyOf(w).length == 0);
     const runs = await listForkRuns(pr, fresh, fresh.length ? 3 : 1);
+    // Read only when a status is about to be written, and at most once per 
pull request.
+    let files;
+    const isRelevant = async (w) => {
+      if (files === undefined) files = await listPullFiles(pr);
+      if (files === null) return true;
+      const { paths, ignore } = filters.get(w.file);
+      return files.some((f) => !ignore.test(f) && paths.test(f));
+    };
+    const update = (w, current, next) => {
+      const same = current && ['state', 'description', 'target_url'].every((k) 
=> current[k] == next[k]);
+      return same ? null : setStatus(pr, w, next);
+    };
     for (const w of WORKFLOWS) {
       const current = statusOfContext(w);
       const run = runs.filter((r) => r.path == runPath(w)).sort((a, b) => b.id 
- a.id)[0];
@@ -179,11 +231,16 @@ 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 });
+        // An irrelevant run skips its jobs. Linking it makes the status final.
+        const next = (await isRelevant(w))
+          ? statusOf(run, await jobsOf(pr, run))
+          : { state: 'success', target_url: 
`${run.html_url}/attempts/${run.run_attempt}`, description: NOT_NEEDED };
+        await update(w, current, next);
+      } else if (!current || current.description == LEGACY_NO_RUN) {
+        const next = (await isRelevant(w))
+          ? { state: 'error', target_url: SETUP_URL, description: NO_RUN }
+          : { state: 'success', target_url: SETUP_URL, description: NOT_NEEDED 
};
+        await update(w, current, next);
       }
     }
     // A legacy check would show next to the status with an older result. The 
status
diff --git a/.github/workflows/velox_backend_arm.yml 
b/.github/workflows/velox_backend_arm.yml
index f53ac85e26..e4d7f6663e 100644
--- a/.github/workflows/velox_backend_arm.yml
+++ b/.github/workflows/velox_backend_arm.yml
@@ -137,7 +137,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/|pom\.xml)|package/|build/mvn)')"
 >> $GITHUB_OUTPUT
+          echo "java=$(match     
'^(\.github/workflows/velox_backend_arm\.yml|\.github/actions/|pom\.xml|backends-velox/|gluten-(uniffle|celeborn|ras|core|substrait|arrow|delta|iceberg|hudi|paimon)/|gluten-ut/(common/|test/|pom\.xml)|package/|build/mvn)')"
 >> $GITHUB_OUTPUT
           echo "tools_it=$(match '^tools/gluten-it/')"                         
                              >> $GITHUB_OUTPUT
 
   build-native-lib-centos-9:
diff --git a/.github/workflows/velox_backend_x86.yml 
b/.github/workflows/velox_backend_x86.yml
index 3f8c362cd1..79e289017f 100644
--- a/.github/workflows/velox_backend_x86.yml
+++ b/.github/workflows/velox_backend_x86.yml
@@ -224,7 +224,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
           echo "udf=$(match      
'^(backends-velox/src/test/scala/org/apache/gluten/expression/VeloxUdfSuite\.scala|\.github/workflows/velox_backend_x86\.yml)$')"
 >> $GITHUB_OUTPUT
           echo "jni_test=$(match 
'^(\.github/workflows/velox_backend_x86\.yml|pom\.xml|gluten-(arrow|core)/pom\.xml|build/mvn|gluten-arrow/src/test/java/org/apache/gluten/jni/.*|gluten-arrow/src/main/java/org/apache/gluten/exception/JniExceptionDescriber\.java|gluten-core/src/main/java/org/apache/gluten/exception/GlutenException\.java)$')"
 >> $GITHUB_OUTPUT
           echo "shims34=$(match  
'^(shims/(spark34|common)/|gluten-ut/spark34/)')"                           >> 
$GITHUB_OUTPUT


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

Reply via email to