This is an automated email from the ASF dual-hosted git repository.
dongjoon-hyun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push:
new 10481ad1529c [SPARK-60869][INFRA] Skip scheduled branch builds if the
branch is unchanged since the last successful run
10481ad1529c is described below
commit 10481ad1529c39565e2fcb4442651a5039d76046
Author: Dongjoon Hyun <[email protected]>
AuthorDate: Wed Nov 4 10:16:37 2026 -0800
[SPARK-60869][INFRA] Skip scheduled branch builds if the branch is
unchanged since the last successful run
### What changes were proposed in this pull request?
This PR aims to skip a scheduled build dispatch of the branch CI schedulers
(`branch35_scheduler.yml`, `branch40_scheduler.yml`, `branch41_scheduler.yml`,
`branch42_scheduler.yml`, `branch43_scheduler.yml` and
`branch4x_scheduler.yml`) when the target branch has not changed since the last
successful run of the target workflow on that branch.
- Add `dev/dispatch-if-changed.sh` and use it in all dispatch steps of the
schedulers instead of `gh workflow run`.
- On a `schedule` event, it compares the branch head with the head SHA of
the latest successful run of the workflow on the branch (`gh run list --status
success --limit 1`). If they are the same, it skips the dispatch and records
the reason and the SHA in a notice and the step summary.
- On a manual run (`workflow_dispatch`) of a scheduler, it always
dispatches as before.
- If there is no successful run or a lookup fails, it dispatches as
before.
- Check out `dev` (sparse checkout) in each scheduler to run the script,
and add the `contents: read` permission for the checkout and the branch head
lookup.
Example notice of a skipped dispatch:
```
Skipped build_scala213.yml on branch-3.5: unchanged since the last
successful run at d7355a7a74ee9f4b157e3b6b1c7d77fea837bce2.
```
### Why are the changes needed?
To reduce the GitHub Actions usage of Apache Spark. The [ASF GitHub Actions
policy](https://infra.apache.org/github-actions-policy.html) limits a project
to 250,000 runner minutes per calendar week, but `apache/spark` used 315,939
minutes from 2026-10-27 to 2026-11-02 (UTC). About 54% of them came from
scheduled and dispatched builds.
Currently, the schedulers dispatch builds even when nothing has changed.
For example, `branch-3.5` has had no commit since 2026-10-13 (`d7355a7a74e`),
but its Scala 2.13 and Python 3.9 builds kept testing the same commit every
four days and used 3,382 minutes from 2026-10-27 to 2026-11-02.
From 2026-10-06 to 2026-11-02 (four weeks), 26 of the 510 scheduled branch
builds ran on a commit that the same workflow had already passed on the same
branch.
| Branch | Scheduled builds | Skippable builds | Skippable minutes |
|---|---:|---:|---:|
| `branch-3.5` | 14 | 9 | 8,652 |
| `branch-4.0` | 49 | 2 | 473 |
| `branch-4.1` | 112 | 15 | 8,765 |
| `branch-4.2` | 111 | 0 | 0 |
| `branch-4.3` | 112 | 0 | 0 |
| `branch-4.x` | 112 | 0 | 0 |
| Total | 510 | 26 | 17,890 (4,472 per week) |
Minutes are the sum of the job durations rounded up to whole minutes.
Branches with frequent commits had no skippable builds in this period, but the
same check applies automatically as a branch gets fewer commits. The scheduled
builds on `master` are not changed because `master` gets new commits every day.
Only one of its 328 scheduled runs in the same period ran on the same commit as
its previous successful run.
An unchanged branch is no longer re-tested on a schedule, so environment
changes such as new versions of unpinned dependencies are caught by the builds
after its next commit. A failing build is still dispatched on every schedule
until it passes, and a scheduler can be run manually to dispatch builds
regardless of changes.
### Does this PR introduce _any_ user-facing change?
No. This only changes the CI schedulers of the Apache Spark repository.
### How was this patch tested?
The schedulers run only on `master` of `apache/spark`, so I ran the script
locally with real `gh` lookups against `apache/spark`. `gh workflow run` was
replaced by a stub that only prints the command, so nothing was dispatched.
```
GITHUB_REPOSITORY=apache/spark GITHUB_EVENT_NAME=schedule
GITHUB_STEP_SUMMARY=summary.md \
dev/dispatch-if-changed.sh build_scala213.yml branch-3.5
```
| Case | Result |
|---|---|
| `schedule`, `branch-3.5` unchanged (Scala 2.13 and Python 3.9 builds) |
Skipped with the notice and the step summary |
| `schedule`, `branch-4.3` changed (Java 21 build) | Dispatched |
| `schedule`, no successful run (Java 25 build on `branch-4.1`) |
Dispatched |
| `workflow_dispatch`, `branch-3.5` unchanged | Dispatched without lookups |
| `schedule`, failed lookups (invalid token, unknown branch) | Dispatched |
| `schedule`, failed dispatch | The step fails as before |
After this is merged, the next `Branch-3.5 CI Scheduler` run is expected to
skip both builds.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Opus 5.5
Closes #60085 from dongjoon-hyun/SPARK-60869.
Authored-by: Dongjoon Hyun <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
---
.github/workflows/branch35_scheduler.yml | 9 +++++--
.github/workflows/branch40_scheduler.yml | 19 +++++++++-----
.github/workflows/branch41_scheduler.yml | 21 +++++++++------
.github/workflows/branch42_scheduler.yml | 21 +++++++++------
.github/workflows/branch43_scheduler.yml | 21 +++++++++------
.github/workflows/branch4x_scheduler.yml | 21 +++++++++------
dev/dispatch-if-changed.sh | 45 ++++++++++++++++++++++++++++++++
7 files changed, 116 insertions(+), 41 deletions(-)
diff --git a/.github/workflows/branch35_scheduler.yml
b/.github/workflows/branch35_scheduler.yml
index f0dbbdbf5041..687efb5c290d 100644
--- a/.github/workflows/branch35_scheduler.yml
+++ b/.github/workflows/branch35_scheduler.yml
@@ -42,18 +42,23 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions:
actions: write
+ contents: read
steps:
+ - name: Checkout Spark repository
+ uses: actions/checkout@v7
+ with:
+ sparse-checkout: dev
- name: Scala 2.13 Build
if: >-
github.event.schedule == '0 11 */4 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'scala213' || inputs.target == 'all'))
run: |
- gh workflow run build_scala213.yml --repo ${{ github.repository }}
--ref branch-3.5
+ ./dev/dispatch-if-changed.sh build_scala213.yml branch-3.5
- name: Python 3.9 Build
if: >-
github.event.schedule == '0 11 */4 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'python_3.9' || inputs.target == 'all'))
run: |
- gh workflow run build_python_3.9.yml --repo ${{ github.repository }}
--ref branch-3.5
+ ./dev/dispatch-if-changed.sh build_python_3.9.yml branch-3.5
diff --git a/.github/workflows/branch40_scheduler.yml
b/.github/workflows/branch40_scheduler.yml
index b6fb0e9af5fc..ef619dd44791 100644
--- a/.github/workflows/branch40_scheduler.yml
+++ b/.github/workflows/branch40_scheduler.yml
@@ -51,53 +51,58 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions:
actions: write
+ contents: read
steps:
+ - name: Checkout Spark repository
+ uses: actions/checkout@v7
+ with:
+ sparse-checkout: dev
- name: Maven Build
if: >-
github.event.schedule == '0 14 */4 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'maven' || inputs.target == 'all'))
run: |
- gh workflow run build_maven.yml --repo ${{ github.repository }}
--ref branch-4.0
+ ./dev/dispatch-if-changed.sh build_maven.yml branch-4.0
- name: Maven Java 21 Build
if: >-
github.event.schedule == '0 14 */4 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'maven_java21' || inputs.target == 'all'))
run: |
- gh workflow run build_maven_java21.yml --repo ${{ github.repository
}} --ref branch-4.0
+ ./dev/dispatch-if-changed.sh build_maven_java21.yml branch-4.0
- name: Java 17 Build
if: >-
github.event.schedule == '0 12 */4 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'java17' || inputs.target == 'all'))
run: |
- gh workflow run build_java17.yml --repo ${{ github.repository }}
--ref branch-4.0
+ ./dev/dispatch-if-changed.sh build_java17.yml branch-4.0
- name: Java 21 Build
if: >-
github.event.schedule == '0 5 */4 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'java21' || inputs.target == 'all'))
run: |
- gh workflow run build_java21.yml --repo ${{ github.repository }}
--ref branch-4.0
+ ./dev/dispatch-if-changed.sh build_java21.yml branch-4.0
- name: Non-ANSI Build
if: >-
github.event.schedule == '0 2 */4 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'non_ansi' || inputs.target == 'all'))
run: |
- gh workflow run build_non_ansi.yml --repo ${{ github.repository }}
--ref branch-4.0
+ ./dev/dispatch-if-changed.sh build_non_ansi.yml branch-4.0
- name: Python 3.11 Build
if: >-
github.event.schedule == '0 12 */4 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'python_3.11' || inputs.target == 'all'))
run: |
- gh workflow run build_python_3.11.yml --repo ${{ github.repository
}} --ref branch-4.0
+ ./dev/dispatch-if-changed.sh build_python_3.11.yml branch-4.0
- name: Python PyPy 3.10 Build
if: >-
github.event.schedule == '0 16 */4 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'python_pypy3.10' || inputs.target == 'all'))
run: |
- gh workflow run build_python_pypy3.10.yml --repo ${{
github.repository }} --ref branch-4.0
+ ./dev/dispatch-if-changed.sh build_python_pypy3.10.yml branch-4.0
diff --git a/.github/workflows/branch41_scheduler.yml
b/.github/workflows/branch41_scheduler.yml
index e7b14bc0ed7f..2106a559b1b8 100644
--- a/.github/workflows/branch41_scheduler.yml
+++ b/.github/workflows/branch41_scheduler.yml
@@ -55,60 +55,65 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions:
actions: write
+ contents: read
steps:
+ - name: Checkout Spark repository
+ uses: actions/checkout@v7
+ with:
+ sparse-checkout: dev
- name: Maven Build
if: >-
github.event.schedule == '0 13 */2 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'maven' || inputs.target == 'all'))
run: |
- gh workflow run build_maven.yml --repo ${{ github.repository }}
--ref branch-4.1
+ ./dev/dispatch-if-changed.sh build_maven.yml branch-4.1
- name: Maven Java 21 Build
if: >-
github.event.schedule == '0 15 */2 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'maven_java21' || inputs.target == 'all'))
run: |
- gh workflow run build_maven_java21.yml --repo ${{ github.repository
}} --ref branch-4.1
+ ./dev/dispatch-if-changed.sh build_maven_java21.yml branch-4.1
- name: Java 17 Build
if: >-
github.event.schedule == '0 12 */2 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'java17' || inputs.target == 'all'))
run: |
- gh workflow run build_java17.yml --repo ${{ github.repository }}
--ref branch-4.1
+ ./dev/dispatch-if-changed.sh build_java17.yml branch-4.1
- name: Java 21 Build
if: >-
github.event.schedule == '0 5 */2 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'java21' || inputs.target == 'all'))
run: |
- gh workflow run build_java21.yml --repo ${{ github.repository }}
--ref branch-4.1
+ ./dev/dispatch-if-changed.sh build_java21.yml branch-4.1
- name: Non-ANSI Build
if: >-
github.event.schedule == '0 2 */2 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'non_ansi' || inputs.target == 'all'))
run: |
- gh workflow run build_non_ansi.yml --repo ${{ github.repository }}
--ref branch-4.1
+ ./dev/dispatch-if-changed.sh build_non_ansi.yml branch-4.1
- name: Python 3.11 Build
if: >-
github.event.schedule == '0 9 */2 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'python_3.11' || inputs.target == 'all'))
run: |
- gh workflow run build_python_3.11.yml --repo ${{ github.repository
}} --ref branch-4.1
+ ./dev/dispatch-if-changed.sh build_python_3.11.yml branch-4.1
- name: Python 3.14 Build
if: >-
github.event.schedule == '0 10 */2 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'python_3.14' || inputs.target == 'all'))
run: |
- gh workflow run build_python_3.14.yml --repo ${{ github.repository
}} --ref branch-4.1
+ ./dev/dispatch-if-changed.sh build_python_3.14.yml branch-4.1
- name: Python PyPy 3.10 Build
if: >-
github.event.schedule == '0 17 */2 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'python_pypy3.10' || inputs.target == 'all'))
run: |
- gh workflow run build_python_pypy3.10.yml --repo ${{
github.repository }} --ref branch-4.1
+ ./dev/dispatch-if-changed.sh build_python_pypy3.10.yml branch-4.1
diff --git a/.github/workflows/branch42_scheduler.yml
b/.github/workflows/branch42_scheduler.yml
index 08ea5ec2d7ed..a83a6b7e1555 100644
--- a/.github/workflows/branch42_scheduler.yml
+++ b/.github/workflows/branch42_scheduler.yml
@@ -55,60 +55,65 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions:
actions: write
+ contents: read
steps:
+ - name: Checkout Spark repository
+ uses: actions/checkout@v7
+ with:
+ sparse-checkout: dev
- name: Maven Build
if: >-
github.event.schedule == '0 15 */2 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'maven' || inputs.target == 'all'))
run: |
- gh workflow run build_maven.yml --repo ${{ github.repository }}
--ref branch-4.2
+ ./dev/dispatch-if-changed.sh build_maven.yml branch-4.2
- name: Maven Java 21 Build
if: >-
github.event.schedule == '0 17 */2 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'maven_java21' || inputs.target == 'all'))
run: |
- gh workflow run build_maven_java21.yml --repo ${{ github.repository
}} --ref branch-4.2
+ ./dev/dispatch-if-changed.sh build_maven_java21.yml branch-4.2
- name: Java 17 Build
if: >-
github.event.schedule == '0 13 */2 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'java17' || inputs.target == 'all'))
run: |
- gh workflow run build_java17.yml --repo ${{ github.repository }}
--ref branch-4.2
+ ./dev/dispatch-if-changed.sh build_java17.yml branch-4.2
- name: Java 21 Build
if: >-
github.event.schedule == '0 6 */2 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'java21' || inputs.target == 'all'))
run: |
- gh workflow run build_java21.yml --repo ${{ github.repository }}
--ref branch-4.2
+ ./dev/dispatch-if-changed.sh build_java21.yml branch-4.2
- name: Java 25 Build
if: >-
github.event.schedule == '0 8 */2 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'java25' || inputs.target == 'all'))
run: |
- gh workflow run build_java25.yml --repo ${{ github.repository }}
--ref branch-4.2
+ ./dev/dispatch-if-changed.sh build_java25.yml branch-4.2
- name: Non-ANSI Build
if: >-
github.event.schedule == '0 3 */2 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'non_ansi' || inputs.target == 'all'))
run: |
- gh workflow run build_non_ansi.yml --repo ${{ github.repository }}
--ref branch-4.2
+ ./dev/dispatch-if-changed.sh build_non_ansi.yml branch-4.2
- name: Python 3.11 Build
if: >-
github.event.schedule == '0 18 */2 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'python_3.11' || inputs.target == 'all'))
run: |
- gh workflow run build_python_3.11.yml --repo ${{ github.repository
}} --ref branch-4.2
+ ./dev/dispatch-if-changed.sh build_python_3.11.yml branch-4.2
- name: Python 3.14 Build
if: >-
github.event.schedule == '0 20 */2 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'python_3.14' || inputs.target == 'all'))
run: |
- gh workflow run build_python_3.14.yml --repo ${{ github.repository
}} --ref branch-4.2
+ ./dev/dispatch-if-changed.sh build_python_3.14.yml branch-4.2
diff --git a/.github/workflows/branch43_scheduler.yml
b/.github/workflows/branch43_scheduler.yml
index 85c0ab74a421..6ee39d6b4a72 100644
--- a/.github/workflows/branch43_scheduler.yml
+++ b/.github/workflows/branch43_scheduler.yml
@@ -55,60 +55,65 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions:
actions: write
+ contents: read
steps:
+ - name: Checkout Spark repository
+ uses: actions/checkout@v7
+ with:
+ sparse-checkout: dev
- name: Maven Build
if: >-
github.event.schedule == '0 10 */2 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'maven' || inputs.target == 'all'))
run: |
- gh workflow run build_maven.yml --repo ${{ github.repository }}
--ref branch-4.3
+ ./dev/dispatch-if-changed.sh build_maven.yml branch-4.3
- name: Maven Java 21 Build
if: >-
github.event.schedule == '0 14 */2 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'maven_java21' || inputs.target == 'all'))
run: |
- gh workflow run build_maven_java21.yml --repo ${{ github.repository
}} --ref branch-4.3
+ ./dev/dispatch-if-changed.sh build_maven_java21.yml branch-4.3
- name: Java 17 Build
if: >-
github.event.schedule == '0 8 */2 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'java17' || inputs.target == 'all'))
run: |
- gh workflow run build_java17.yml --repo ${{ github.repository }}
--ref branch-4.3
+ ./dev/dispatch-if-changed.sh build_java17.yml branch-4.3
- name: Java 21 Build
if: >-
github.event.schedule == '0 1 */2 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'java21' || inputs.target == 'all'))
run: |
- gh workflow run build_java21.yml --repo ${{ github.repository }}
--ref branch-4.3
+ ./dev/dispatch-if-changed.sh build_java21.yml branch-4.3
- name: Java 25 Build
if: >-
github.event.schedule == '0 6 */2 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'java25' || inputs.target == 'all'))
run: |
- gh workflow run build_java25.yml --repo ${{ github.repository }}
--ref branch-4.3
+ ./dev/dispatch-if-changed.sh build_java25.yml branch-4.3
- name: Non-ANSI Build
if: >-
github.event.schedule == '0 0 */2 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'non_ansi' || inputs.target == 'all'))
run: |
- gh workflow run build_non_ansi.yml --repo ${{ github.repository }}
--ref branch-4.3
+ ./dev/dispatch-if-changed.sh build_non_ansi.yml branch-4.3
- name: Python 3.11 Build
if: >-
github.event.schedule == '0 20 */2 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'python_3.11' || inputs.target == 'all'))
run: |
- gh workflow run build_python_3.11.yml --repo ${{ github.repository
}} --ref branch-4.3
+ ./dev/dispatch-if-changed.sh build_python_3.11.yml branch-4.3
- name: Python 3.14 Build
if: >-
github.event.schedule == '0 23 */2 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'python_3.14' || inputs.target == 'all'))
run: |
- gh workflow run build_python_3.14.yml --repo ${{ github.repository
}} --ref branch-4.3
+ ./dev/dispatch-if-changed.sh build_python_3.14.yml branch-4.3
diff --git a/.github/workflows/branch4x_scheduler.yml
b/.github/workflows/branch4x_scheduler.yml
index 397f1ef2d248..8331ef11d548 100644
--- a/.github/workflows/branch4x_scheduler.yml
+++ b/.github/workflows/branch4x_scheduler.yml
@@ -55,60 +55,65 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions:
actions: write
+ contents: read
steps:
+ - name: Checkout Spark repository
+ uses: actions/checkout@v7
+ with:
+ sparse-checkout: dev
- name: Maven Build
if: >-
github.event.schedule == '0 16 */2 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'maven' || inputs.target == 'all'))
run: |
- gh workflow run build_maven.yml --repo ${{ github.repository }}
--ref branch-4.x
+ ./dev/dispatch-if-changed.sh build_maven.yml branch-4.x
- name: Maven Java 21 Build
if: >-
github.event.schedule == '0 18 */2 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'maven_java21' || inputs.target == 'all'))
run: |
- gh workflow run build_maven_java21.yml --repo ${{ github.repository
}} --ref branch-4.x
+ ./dev/dispatch-if-changed.sh build_maven_java21.yml branch-4.x
- name: Java 17 Build
if: >-
github.event.schedule == '0 11 */2 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'java17' || inputs.target == 'all'))
run: |
- gh workflow run build_java17.yml --repo ${{ github.repository }}
--ref branch-4.x
+ ./dev/dispatch-if-changed.sh build_java17.yml branch-4.x
- name: Java 21 Build
if: >-
github.event.schedule == '0 7 */2 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'java21' || inputs.target == 'all'))
run: |
- gh workflow run build_java21.yml --repo ${{ github.repository }}
--ref branch-4.x
+ ./dev/dispatch-if-changed.sh build_java21.yml branch-4.x
- name: Java 25 Build
if: >-
github.event.schedule == '0 22 */2 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'java25' || inputs.target == 'all'))
run: |
- gh workflow run build_java25.yml --repo ${{ github.repository }}
--ref branch-4.x
+ ./dev/dispatch-if-changed.sh build_java25.yml branch-4.x
- name: Non-ANSI Build
if: >-
github.event.schedule == '0 4 */2 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'non_ansi' || inputs.target == 'all'))
run: |
- gh workflow run build_non_ansi.yml --repo ${{ github.repository }}
--ref branch-4.x
+ ./dev/dispatch-if-changed.sh build_non_ansi.yml branch-4.x
- name: Python 3.11 Build
if: >-
github.event.schedule == '0 19 */2 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'python_3.11' || inputs.target == 'all'))
run: |
- gh workflow run build_python_3.11.yml --repo ${{ github.repository
}} --ref branch-4.x
+ ./dev/dispatch-if-changed.sh build_python_3.11.yml branch-4.x
- name: Python 3.14 Build
if: >-
github.event.schedule == '0 21 */2 * *' ||
(github.event_name == 'workflow_dispatch' &&
(inputs.target == 'python_3.14' || inputs.target == 'all'))
run: |
- gh workflow run build_python_3.14.yml --repo ${{ github.repository
}} --ref branch-4.x
+ ./dev/dispatch-if-changed.sh build_python_3.14.yml branch-4.x
diff --git a/dev/dispatch-if-changed.sh b/dev/dispatch-if-changed.sh
new file mode 100755
index 000000000000..e5c22b4bf227
--- /dev/null
+++ b/dev/dispatch-if-changed.sh
@@ -0,0 +1,45 @@
+#!/usr/bin/env bash
+
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Dispatches a workflow on a branch for the branch CI schedulers
+# (.github/workflows/branch*_scheduler.yml).
+#
+# Usage: dispatch-if-changed.sh <workflow file> <branch>
+#
+# On a scheduled run, the dispatch is skipped if the branch head is the commit
of the last
+# successful run of the workflow on the branch. Otherwise, including when
there is no
+# successful run or a lookup fails, the workflow is dispatched.
+# GH_TOKEN needs the 'actions: write' and 'contents: read' permissions.
+
+WORKFLOW="$1"
+BRANCH="$2"
+
+if [[ "$GITHUB_EVENT_NAME" == "schedule" ]]; then
+ HEAD_SHA=$(gh api "repos/$GITHUB_REPOSITORY/git/ref/heads/$BRANCH" --jq
.object.sha)
+ LAST_SHA=$(gh run list --repo "$GITHUB_REPOSITORY" --workflow "$WORKFLOW"
--branch "$BRANCH" \
+ --status success --limit 1 --json headSha --jq '.[0].headSha')
+ if [[ "$HEAD_SHA" =~ ^[0-9a-f]{40}$ && "$HEAD_SHA" == "$LAST_SHA" ]]; then
+ MESSAGE="Skipped $WORKFLOW on $BRANCH: unchanged since the last successful
run at $HEAD_SHA."
+ echo "::notice::$MESSAGE"
+ echo "$MESSAGE" >> "$GITHUB_STEP_SUMMARY"
+ exit 0
+ fi
+fi
+
+gh workflow run "$WORKFLOW" --repo "$GITHUB_REPOSITORY" --ref "$BRANCH"
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]