zhengruifeng commented on code in PR #60045:
URL: https://github.com/apache/spark/pull/60045#discussion_r4462240869


##########
.github/workflows/build_main.yml:
##########
@@ -25,13 +25,70 @@ on:
     - '**'
 
 jobs:
+  check-commit-count:
+    name: Check commit count
+    if: github.repository == 'apache/spark' && github.ref == 
'refs/heads/master'
+    runs-on: ubuntu-slim
+    permissions:
+      contents: read
+    outputs:
+      should-run: ${{ steps.count.outputs.should-run }}
+    steps:
+      - name: Check out the full branch history
+        uses: actions/checkout@v6
+        with:
+          fetch-depth: 0

Review Comment:
   Thanks for the suggestion. The current full-history checkout and `git 
rev-list --count HEAD` match the implementation already used on `branch-4.x`. I 
would like to keep this PR aligned with that approach for now; we can make the 
GraphQL optimization separately, ideally for both branches.



##########
.github/workflows/build_main.yml:
##########
@@ -25,13 +25,70 @@ on:
     - '**'
 
 jobs:
+  check-commit-count:
+    name: Check commit count
+    if: github.repository == 'apache/spark' && github.ref == 
'refs/heads/master'
+    runs-on: ubuntu-slim
+    permissions:
+      contents: read
+    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
+        run: |
+          count=$(git rev-list --count HEAD)
+          remainder=$((count % 10))
+
+          if ((remainder == 0)); then
+            should_run=true
+            icon=":white_check_mark:"
+            title="Commit count matched"
+            details="Commit count $count is divisible by 10."
+          else
+            should_run=false
+            icon=":pause_button:"
+            title="Commit count not matched"
+            details="Commit count $count is not divisible by 10."
+          fi
+
+          echo "should-run=$should_run" >> "$GITHUB_OUTPUT"
+          echo "Branch: $GITHUB_REF_NAME"
+          echo "Commit: $GITHUB_SHA"
+          echo "Commit count: $count"
+          echo "Remainder: $remainder"
+          echo "Should run: $should_run"
+          echo "Details: $details"
+          echo "::notice title=$title::$details"
+          echo "### $icon Commit count check" >> "$GITHUB_STEP_SUMMARY"
+          echo "" >> "$GITHUB_STEP_SUMMARY"
+          echo "- Branch: $GITHUB_REF_NAME" >> "$GITHUB_STEP_SUMMARY"
+          echo "- Commit: $GITHUB_SHA" >> "$GITHUB_STEP_SUMMARY"
+          echo "- Commit count: $count" >> "$GITHUB_STEP_SUMMARY"
+          echo "- Remainder: $remainder" >> "$GITHUB_STEP_SUMMARY"
+          echo "- Should run: $should_run" >> "$GITHUB_STEP_SUMMARY"
+          echo "- Details: $details" >> "$GITHUB_STEP_SUMMARY"
+
   call-build-and-test:
     permissions:
       packages: write
     name: Run
+    needs: check-commit-count
     # Skip pushes to `master` on forks: the "Sync fork" button mirrors
     # apache/spark and would otherwise re-run the full build on every sync.
+    # Evaluate this condition even when the master-only sampling check is 
skipped.
     if: >-
-      github.repository == 'apache/spark'
-      || github.ref != 'refs/heads/master'
+      (!cancelled())

Review Comment:
   Updated the workflow comment in 15d81477d72 to explain why `!cancelled()` is 
needed. The sampling job runs only on `apache/spark` master, so it is skipped 
on other upstream branches and on forks. Without a status-check function, 
GitHub adds an implicit `success()` requirement, which would skip the dependent 
build when the sampling job is skipped. `!cancelled()` lets the explicit 
skipped/success handling run while still honoring workflow cancellation.



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