You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ru...@apache.org on 2026/10/26 22:05:34 UTC
(superset) branch ci/skip-stale-builds-not-cancel created (now 6e3199f73f9)
This is an automated email from the ASF dual-hosted git repository.
rusackas pushed a change to branch ci/skip-stale-builds-not-cancel
in repository https://gitbox.apache.org/repos/asf/superset.git
at 6e3199f73f9 ci: skip stale docker-build runs instead of letting them get cancelled
This branch includes the following new commits:
new 6e3199f73f9 ci: skip stale docker-build runs instead of letting them get cancelled
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(superset) 01/01: ci: skip stale docker-build runs instead of letting them get cancelled
Posted by ru...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rusackas pushed a commit to branch ci/skip-stale-builds-not-cancel
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 6e3199f73f9b4d0b78b3ea89e8eaea1918505e8e
Author: Evan Rusackas <ev...@rusackas.com>
AuthorDate: Mon Oct 26 15:05:02 2026 -0700
ci: skip stale docker-build runs instead of letting them get cancelled
docker.yml's docker-build job serializes each preset behind a per-branch
concurrency group with cancel-in-progress: false. That only protects a
run that's already executing — GitHub unconditionally cancels any run
left queued behind it once a newer one supersedes it, regardless of
cancel-in-progress. Master's bursty push cadence means several runs
routinely pile up in the same group, and everything but the newest
queued run gets force-cancelled, showing up as a failing red "Cancelled"
check on an otherwise-fine commit instead of a clean "Skipped" one.
superset-docs-deploy.yml already solved this for the Docs Deployment
workflow (#42488) with a check-freshness job that runs ahead of its own
concurrency group and skips cleanly when superseded, so the stale run
never joins the queue to begin with. Port the same pattern to
docker-build: a new check-freshness job gates it on whether the commit
is still its branch's tip before it ever reaches the per-preset
concurrency groups.
The freshness script moves from check-docs-deploy-freshness.sh to
check-branch-freshness.sh and gains a BRANCH env var (defaulting to
master) so it can check release-branch pushes too, plus a
pull_request bypass alongside the existing workflow_dispatch one,
since a PR build has no branch tip to race against.
Co-Authored-By: Evan Rusackas <ev...@rusackas.com>
Co-Authored-By: Claude Sonnet 5 <no...@anthropic.com>
---
.github/workflows/docker.yml | 48 +++++++++++++++-
.github/workflows/github-action-validator.yml | 4 +-
.../workflows/scripts/check-branch-freshness.sh | 64 ++++++++++++++++++++++
...ness.test.sh => check-branch-freshness.test.sh} | 64 ++++++++++++++++------
.../scripts/check-docs-deploy-freshness.sh | 49 -----------------
.github/workflows/superset-docs-deploy.yml | 6 +-
6 files changed, 162 insertions(+), 73 deletions(-)
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
index 2ee6cc90351..52c58caf69e 100644
--- a/.github/workflows/docker.yml
+++ b/.github/workflows/docker.yml
@@ -35,6 +35,45 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}
+ # Master (and each release branch) gets frequent, sometimes bursty pushes,
+ # and docker-build's per-preset concurrency groups below are keyed on the
+ # branch, not the run: with cancel-in-progress: false, a burst queues
+ # several runs behind each other in the same group, and GitHub
+ # force-cancels all but the newest queued one regardless of
+ # cancel-in-progress — that shows up as a failing "Cancelled" check on an
+ # otherwise-fine commit instead of a clean "Skipped" one. Check up front
+ # whether this run is still building its branch's current tip and, if
+ # not, skip the whole matrix cleanly before it ever joins that queue.
+ # Deliberately outside any concurrency group so it runs immediately for
+ # every trigger without blocking or being blocked by anything. Mirrors
+ # check-freshness in superset-docs-deploy.yml, which hit the same
+ # cancelled-vs-skipped problem first.
+ check-freshness:
+ runs-on: ubuntu-26.04
+ timeout-minutes: 5
+ outputs:
+ is-current: ${{ steps.check.outputs.is-current }}
+ steps:
+ # Sparse checkout: this job's only job is to be fast, so it fetches
+ # nothing but the freshness-check script itself.
+ - name: Checkout freshness-check script
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
+ sparse-checkout: |
+ .github/workflows/scripts
+ sparse-checkout-cone-mode: false
+ - name: "Check whether this is still the branch's current commit"
+ id: check
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ BUILD_SHA: ${{ github.sha }}
+ EVENT_NAME: ${{ github.event_name }}
+ REPO: ${{ github.repository }}
+ BRANCH: ${{ github.ref_name }}
+ OUTPUT_NAME: is-current
+ run: .github/workflows/scripts/check-branch-freshness.sh
+
setup_matrix:
runs-on: ubuntu-slim
timeout-minutes: 5
@@ -300,13 +339,18 @@ jobs:
docker-build:
name: docker-build
- needs: [setup_matrix, changes]
+ needs: [setup_matrix, changes, check-freshness]
# Only master pushes publish images (see scripts/docker-build-plan.sh).
# Without the Docker Hub credentials (e.g. on a fork or mirror) they can
# publish nothing, so they are skipped there. Version-branch pushes and
# pull_request builds only load the image to validate that it builds, so
- # they run everywhere.
+ # they run everywhere. check-freshness.outputs.is-current is always
+ # 'true' for pull_request (it bypasses the check there — a PR build has
+ # no branch tip to race against, and staleness is instead handled by
+ # this job's own cancel-in-progress: true below), so this only narrows
+ # push triggers superseded by a newer commit on the same branch.
if: >-
+ needs.check-freshness.outputs.is-current == 'true' &&
(github.event_name != 'push' ||
github.ref != 'refs/heads/master' ||
needs.setup_matrix.outputs.has-secrets) &&
diff --git a/.github/workflows/github-action-validator.yml b/.github/workflows/github-action-validator.yml
index 8f625a5e539..d52f7f4d287 100644
--- a/.github/workflows/github-action-validator.yml
+++ b/.github/workflows/github-action-validator.yml
@@ -45,8 +45,8 @@ jobs:
- name: Run Script
run: bash .github/workflows/github-action-validator.sh
- - name: Test docs-deploy freshness gate
- run: bash .github/workflows/scripts/check-docs-deploy-freshness.test.sh
+ - name: Test branch freshness gate
+ run: bash .github/workflows/scripts/check-branch-freshness.test.sh
- name: Test code scanning availability check
run: bash .github/workflows/scripts/check-code-scanning-available.test.sh
diff --git a/.github/workflows/scripts/check-branch-freshness.sh b/.github/workflows/scripts/check-branch-freshness.sh
new file mode 100755
index 00000000000..1a6e26cd9d0
--- /dev/null
+++ b/.github/workflows/scripts/check-branch-freshness.sh
@@ -0,0 +1,64 @@
+#!/bin/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.
+#
+# Shared freshness gate for push-triggered workflows that serialize their
+# real work behind a static (per-branch) concurrency group with
+# cancel-in-progress: false — e.g. the Docs Deployment workflow
+# (superset-docs-deploy.yml, both up front at check-freshness and again right
+# before the deploy step at recheck-freshness) and the Docker image build
+# workflow (docker.yml, check-freshness). Writes an output declaring whether
+# BUILD_SHA is still BRANCH's current tip, so a superseded run can skip
+# cleanly at the job level instead of entering the concurrency group, where a
+# burst of pushes would otherwise queue several runs behind each other and
+# have GitHub force-cancel all but the newest pending one — the queue
+# pruning described at
+# https://docs.github.com/en/actions/using-jobs/using-concurrency, which
+# happens regardless of cancel-in-progress and is why a merely-superseded
+# run shows up as a failing "Cancelled" check instead of a clean "Skipped"
+# one.
+#
+# Required env vars:
+# BUILD_SHA - the commit SHA this run is building
+# REPO - "owner/repo" to query, e.g. github.repository
+# OUTPUT_NAME - the GITHUB_OUTPUT key to write, e.g. "is-current"
+# GITHUB_OUTPUT - path to append outputs to (set by the Actions runner)
+# Optional env vars:
+# BRANCH - the branch whose tip BUILD_SHA is checked against;
+# defaults to "master"
+# EVENT_NAME - if "workflow_dispatch" or "pull_request", bypasses the
+# check and always reports current: a manual dispatch is a
+# deliberate, one-off action, and a pull_request build has
+# no branch tip to race against (PR staleness is instead
+# handled by that workflow's own cancel-in-progress: true)
+# GH_TOKEN - passed through to `gh`, needed to call the GitHub API
+
+set -euo pipefail
+
+branch="${BRANCH:-master}"
+
+if [ "${EVENT_NAME:-}" = "workflow_dispatch" ] || [ "${EVENT_NAME:-}" = "pull_request" ]; then
+ echo "${OUTPUT_NAME}=true" >>"$GITHUB_OUTPUT"
+ exit 0
+fi
+
+latest_sha="$(gh api "repos/${REPO}/commits/${branch}" --jq .sha)"
+if [ "${latest_sha}" = "${BUILD_SHA}" ]; then
+ echo "${OUTPUT_NAME}=true" >>"$GITHUB_OUTPUT"
+else
+ echo "${OUTPUT_NAME}=false" >>"$GITHUB_OUTPUT"
+ echo "::notice::${branch} has moved on to ${latest_sha} since ${BUILD_SHA} was triggered — skipping this stale run."
+fi
diff --git a/.github/workflows/scripts/check-docs-deploy-freshness.test.sh b/.github/workflows/scripts/check-branch-freshness.test.sh
similarity index 54%
rename from .github/workflows/scripts/check-docs-deploy-freshness.test.sh
rename to .github/workflows/scripts/check-branch-freshness.test.sh
index c558c4986de..32c860dba46 100755
--- a/.github/workflows/scripts/check-docs-deploy-freshness.test.sh
+++ b/.github/workflows/scripts/check-branch-freshness.test.sh
@@ -15,36 +15,42 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-# Exercises check-docs-deploy-freshness.sh against a stubbed `gh`, covering
-# the dispatch-bypass, current-tip and stale-tip branches so the output
-# contract (is-current / still-current) can't silently regress. Run
-# directly, no extra tooling required:
-# bash .github/workflows/scripts/check-docs-deploy-freshness.test.sh
+# Exercises check-branch-freshness.sh against a stubbed `gh`, covering the
+# dispatch-bypass, pull_request-bypass, current-tip, stale-tip and
+# explicit-BRANCH cases so the output contract (is-current / still-current)
+# can't silently regress. Run directly, no extra tooling required:
+# bash .github/workflows/scripts/check-branch-freshness.test.sh
set -euo pipefail
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
-script_under_test="${script_dir}/check-docs-deploy-freshness.sh"
+script_under_test="${script_dir}/check-branch-freshness.sh"
failures=0
-# Runs the script under test with a stubbed `gh` reporting $1 as master's
-# latest sha, asserting that GITHUB_OUTPUT ends up containing exactly $4.
+# Runs the script under test with a stubbed `gh` reporting $1 as the
+# configured branch's latest sha, asserting that GITHUB_OUTPUT ends up
+# containing exactly $5 and (unless empty) that `gh` was actually called
+# against the expected branch, to catch BRANCH silently not being honored.
run_case() {
local case_name="$1"
local latest_sha="$2"
local build_sha="$3"
local event_name="$4"
local expected_line="$5"
+ local branch="${6:-}"
+ local expect_branch="${7:-}"
local workdir
workdir="$(mktemp -d)"
trap 'rm -rf "${workdir}"' RETURN
- # Fake `gh` that just echoes back the requested "latest" sha regardless of
- # arguments, so the script under test never touches the network.
+ # Fake `gh` that records the requested commits path and echoes back the
+ # requested "latest" sha, so the script under test never touches the
+ # network and the branch it actually queried can be asserted on.
cat >"${workdir}/gh" <<EOF
#!/bin/bash
+echo "\$@" >>"${workdir}/gh-args"
echo '${latest_sha}'
EOF
chmod +x "${workdir}/gh"
@@ -58,6 +64,7 @@ EOF
REPO="apache/superset" \
BUILD_SHA="${build_sha}" \
EVENT_NAME="${event_name}" \
+ BRANCH="${branch}" \
GH_TOKEN="fake-token" \
bash "${script_under_test}"; then
:
@@ -69,28 +76,49 @@ EOF
local actual
actual="$(cat "${output_file}")"
- if [ "${actual}" = "${expected_line}" ]; then
- echo "PASS (${case_name})"
- else
+ if [ "${actual}" != "${expected_line}" ]; then
echo "FAIL (${case_name}): expected '${expected_line}', got '${actual}'"
failures=$((failures + 1))
+ return
+ fi
+
+ if [ -n "${expect_branch}" ]; then
+ if ! grep -q "repos/apache/superset/commits/${expect_branch}" "${workdir}/gh-args" 2>/dev/null; then
+ echo "FAIL (${case_name}): expected gh to be queried against branch '${expect_branch}'"
+ failures=$((failures + 1))
+ return
+ fi
fi
+
+ echo "PASS (${case_name})"
}
-# `gh` prints "should-not-be-called" for the dispatch case above the trick:
+# `gh` prints "should-not-be-called" for the bypass cases below the trick:
# it's never actually invoked since the bypass short-circuits before the
# `gh api` call, but the fake still needs a body.
run_case "workflow_dispatch bypasses the check" \
"unused" "abc123" "workflow_dispatch" \
"is-current=true"
-run_case "build sha matches master's tip" \
- "abc123" "abc123" "push" \
+run_case "pull_request bypasses the check" \
+ "unused" "abc123" "pull_request" \
"is-current=true"
-run_case "build sha is stale" \
+run_case "build sha matches master's tip (default branch)" \
+ "abc123" "abc123" "push" \
+ "is-current=true" "" "master"
+
+run_case "build sha is stale (default branch)" \
+ "def456" "abc123" "push" \
+ "is-current=false" "" "master"
+
+run_case "build sha matches an explicit release branch's tip" \
+ "abc123" "abc123" "push" \
+ "is-current=true" "7.0" "7.0"
+
+run_case "build sha is stale on an explicit release branch" \
"def456" "abc123" "push" \
- "is-current=false"
+ "is-current=false" "7.0" "7.0"
if [ "${failures}" -gt 0 ]; then
echo "${failures} case(s) failed"
diff --git a/.github/workflows/scripts/check-docs-deploy-freshness.sh b/.github/workflows/scripts/check-docs-deploy-freshness.sh
deleted file mode 100755
index 61b062bf89f..00000000000
--- a/.github/workflows/scripts/check-docs-deploy-freshness.sh
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/bin/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.
-#
-# Shared freshness gate used by the Docs Deployment workflow
-# (superset-docs-deploy.yml) both up front (check-freshness) and again right
-# before the deploy step (recheck-freshness). Writes an output declaring
-# whether BUILD_SHA is still master's current tip, so a superseded run can
-# skip cleanly instead of racing (and clobbering, or being force-cancelled
-# by) a fresher run.
-#
-# Required env vars:
-# BUILD_SHA - the commit SHA this run is building
-# REPO - "owner/repo" to query, e.g. github.repository
-# OUTPUT_NAME - the GITHUB_OUTPUT key to write, e.g. "is-current"
-# GITHUB_OUTPUT - path to append outputs to (set by the Actions runner)
-# Optional env vars:
-# EVENT_NAME - if "workflow_dispatch", bypasses the check and always
-# reports current, since a manual dispatch is a deliberate,
-# one-off action rather than something racing other triggers
-# GH_TOKEN - passed through to `gh`, needed to call the GitHub API
-
-set -euo pipefail
-
-if [ "${EVENT_NAME:-}" = "workflow_dispatch" ]; then
- echo "${OUTPUT_NAME}=true" >>"$GITHUB_OUTPUT"
- exit 0
-fi
-
-latest_sha="$(gh api "repos/${REPO}/commits/master" --jq .sha)"
-if [ "${latest_sha}" = "${BUILD_SHA}" ]; then
- echo "${OUTPUT_NAME}=true" >>"$GITHUB_OUTPUT"
-else
- echo "${OUTPUT_NAME}=false" >>"$GITHUB_OUTPUT"
- echo "::notice::master has moved on to ${latest_sha} since ${BUILD_SHA} was triggered — skipping this stale run."
-fi
diff --git a/.github/workflows/superset-docs-deploy.yml b/.github/workflows/superset-docs-deploy.yml
index 0baec44a959..83832a6b02f 100644
--- a/.github/workflows/superset-docs-deploy.yml
+++ b/.github/workflows/superset-docs-deploy.yml
@@ -68,8 +68,9 @@ jobs:
BUILD_SHA: ${{ github.event.workflow_run.head_sha || github.sha }}
EVENT_NAME: ${{ github.event_name }}
REPO: ${{ github.repository }}
+ BRANCH: master
OUTPUT_NAME: is-current
- run: .github/workflows/scripts/check-docs-deploy-freshness.sh
+ run: .github/workflows/scripts/check-branch-freshness.sh
build-deploy:
needs: [config, check-freshness]
@@ -186,8 +187,9 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BUILD_SHA: ${{ github.event.workflow_run.head_sha || github.sha }}
REPO: ${{ github.repository }}
+ BRANCH: master
OUTPUT_NAME: still-current
- run: .github/workflows/scripts/check-docs-deploy-freshness.sh
+ run: .github/workflows/scripts/check-branch-freshness.sh
- name: deploy docs
if: github.event_name == 'workflow_dispatch' || steps.recheck-freshness.outputs.still-current == 'true'
# github-action-push-to-another-repository is a submodule (not a