codeant-ai-for-open-source[bot] commented on code in PR #45750: URL: https://github.com/apache/superset/pull/45750#discussion_r4384059739
########## .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)" Review Comment: ✅ **CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved** as of `0b0a7f2`. A failed `gh api` lookup now emits a warning, writes `is-current=true` to `GITHUB_OUTPUT`, and exits successfully so the build can proceed. <sub>If that's not right, unresolve this thread and CodeAnt will leave it open.</sub> <!-- codeant-auto-resolve-reply --> -- 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]
