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

zhengruifeng pushed a commit to branch branch-4.x
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-4.x by this push:
     new 2c27655549b1 [SPARK-60924][4.X][INFRA] Use GraphQL to count commits 
for post-merge CI sampling
2c27655549b1 is described below

commit 2c27655549b1cbf1c5a43234ea86ac4ff68732da
Author: Ruifeng Zheng <[email protected]>
AuthorDate: Fri Nov 6 08:59:43 2026 +0800

    [SPARK-60924][4.X][INFRA] Use GraphQL to count commits for post-merge CI 
sampling
    
    ### What changes were proposed in this pull request?
    
    Apply the same commit-count optimization as #60124 to `branch-4.x`, using 
SPARK-60924.
    
    Replace the sampling job's full-history checkout and `git rev-list --count 
HEAD` with a GitHub GraphQL query for `Commit.history.totalCount` at the 
triggering `GITHUB_SHA`. Use the existing read-only workflow token and reject 
missing or invalid counts before calculating the remainder.
    
    The branch's one-in-ten upstream sampling rule, fork builds, job output, 
summary, and downstream build condition are preserved.
    
    ### Why are the changes needed?
    
    The `branch-4.x` sampling job downloads Spark's entire Git history on every 
push to obtain a commit count. Getting that count through GraphQL avoids the 
checkout, including for upstream pushes whose build is sampled out.
    
    This implements [Nicholas Chammas's 
suggestion](https://github.com/apache/spark/pull/60045#discussion_r4455095349) 
for `branch-4.x` separately from the master PR.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    - `actionlint` and `git diff --check`.
    - Executed the actual workflow script against the live API for sampled and 
unsampled `branch-4.x` commits and a commit in the contributor fork; all counts 
matched `git rev-list --count` at the same SHA.
    - Executed the script with controlled counts 1 through 30; only 10, 20, and 
30 selected a build. API failures and empty, null, zero, negative, and 
non-integer counts failed without emitting a build-selection output.
    - Verified that the sampling step matches #60124 and preserves the branch's 
permissions, output, summary, workflow trigger, and downstream build condition.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    Generated-by: Codex (GPT-6)
    
    Closes #60126 from zhengruifeng/infra-ci-graphql-commit-count-4x-20261105.
    
    Authored-by: Ruifeng Zheng <[email protected]>
    Signed-off-by: Ruifeng Zheng <[email protected]>
---
 .github/workflows/build_main.yml | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/.github/workflows/build_main.yml b/.github/workflows/build_main.yml
index 9622901fa813..98c1fb85ef22 100644
--- a/.github/workflows/build_main.yml
+++ b/.github/workflows/build_main.yml
@@ -33,14 +33,28 @@ jobs:
     outputs:
       should-run: ${{ steps.count.outputs.should-run }}
     steps:
-      - name: Check out the full branch history
-        uses: actions/checkout@v6
-        with:
-          fetch-depth: 0
       - name: Check whether this is every tenth commit
         id: count
+        env:
+          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
         run: |
-          count=$(git rev-list --count HEAD)
+          count=$(gh api graphql \
+            -f owner="$GITHUB_REPOSITORY_OWNER" \
+            -f name="${GITHUB_REPOSITORY#*/}" \
+            -f sha="$GITHUB_SHA" \
+            -f query='
+              query($owner: String!, $name: String!, $sha: GitObjectID!) {
+                repository(owner: $owner, name: $name) {
+                  object(oid: $sha) {
+                    ... on Commit { history { totalCount } }
+                  }
+                }
+              }' \
+            --jq '.data.repository.object.history.totalCount')
+          if [[ ! "$count" =~ ^[1-9][0-9]*$ ]]; then
+            echo "::error::Expected a positive commit count, got: $count"
+            exit 1
+          fi
           remainder=$((count % 10))
 
           if ((remainder == 0)); then


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

Reply via email to