Skip to content

Commit 66e096e

Browse files
committed
fix(core): recover a bump branch without a PR and reject SHA pins
A run that pushed core/<tag> but failed to open the PR left the tag skipped for good. The bump script now skips only when a PR exists, and rebuilds and replaces a branch that has none. The core-sync scripts require a release tag as the pin and fail with a clear error on a commit SHA. Signed-off-by: Piotr Mlocek <pmlocek@nvidia.com>
1 parent 3592c98 commit 66e096e

4 files changed

Lines changed: 27 additions & 10 deletions

File tree

‎mise.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ buf = "1.72.0"
1717
uv = "0.10.12"
1818

1919
[env]
20-
# The single core pin: a release tag (or a full commit SHA).
20+
# The single core pin: a release tag. scripts/core-sync/ requires a tag.
2121
OPENSHELL_CORE_REF = "v0.1.7"
2222
SETUPTOOLS_SCM_PRETEND_VERSION_FOR_OPENSHELL = "0.0.0"
2323

‎scripts/core-sync/core-tags.sh‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
# stable version. By default every newer stable tag is printed, plus the
1111
# newest pre-release when it is newer than all of them: one proposal for the
1212
# current release train instead of one per pre-release. --all prints every
13-
# newer tag. --pin overrides the pin, OPENSHELL_CORE_REF in mise.toml.
13+
# newer tag. --pin overrides the pin, OPENSHELL_CORE_REF in mise.toml. The pin
14+
# must be a release tag; a commit SHA fails.
1415
set -euo pipefail
1516

1617
repo=${CORE_REPO:-NVIDIA/OpenShell}
@@ -28,6 +29,9 @@ done
2829
[ -n "$pin" ] || pin=$(sed -n 's/^OPENSHELL_CORE_REF = "\(.*\)"$/\1/p' mise.toml)
2930
[ -n "$pin" ] || { echo "ERROR: no OPENSHELL_CORE_REF in mise.toml" >&2; exit 1; }
3031

32+
[[ "$pin" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-pre\.[0-9]+)?$ ]] ||
33+
{ echo "ERROR: pin '$pin' is not a release tag; commit SHA pins are not supported by core-sync" >&2; exit 1; }
34+
3135
# key <tag>: "major minor patch rank pre" with rank 1 for stable, 0 for pre.
3236
key() {
3337
awk -v t="$1" 'BEGIN {

‎scripts/core-sync/drift-check.sh‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ case $out in /*) ;; *) out="$(pwd)/$out" ;; esac
3636
pin_of() { sed -n 's/^OPENSHELL_CORE_REF = "\(.*\)"$/\1/p'; }
3737
pin=$(pin_of <mise.toml)
3838
[ -n "$pin" ] || { echo "ERROR: no OPENSHELL_CORE_REF in mise.toml" >&2; exit 1; }
39+
[[ "$pin" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-pre\.[0-9]+)?$ ]] || {
40+
echo "ERROR: pin '$pin' is not a release tag; commit SHA pins are not supported by core-sync" >&2
41+
exit 1
42+
}
3943
main_sha=$(git ls-remote "$core_url" refs/heads/main | cut -f1)
4044
[ -n "$main_sha" ] || { echo "ERROR: cannot resolve core main" >&2; exit 1; }
4145

‎scripts/core-sync/open-bump-pr.sh‎

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@
1414
# for older tags. --dry-run does the local part, prints the PR body, and
1515
# changes nothing on GitHub.
1616
#
17-
# Skips the tag when branch core/<tag> exists on origin or any PR from it
18-
# exists (merged or closed), so a closed proposal is never reopened. When the
19-
# core tag no longer exists, closes an open proposal for it.
17+
# Skips the tag when any PR from branch core/<tag> exists (open, merged, or
18+
# closed), so a closed proposal is never reopened. A branch on origin without
19+
# a PR is the leftover of a run that pushed but failed to open the PR; the
20+
# run rebuilds it and replaces the branch (force-with-lease) so the PR gets
21+
# opened. When the core tag no longer exists, closes an open proposal for it.
22+
# The current pin must be a release tag; a commit SHA pin stops the run.
2023
# Git identity and GH_TOKEN come from the environment (the App in CI).
2124
set -euo pipefail
2225

@@ -84,10 +87,6 @@ if ! err=$(gh api "repos/$core_repo/git/ref/tags/$tag" --silent 2>&1); then
8487
exit 0
8588
fi
8689

87-
if [ -n "$(git ls-remote --heads origin "$branch")" ]; then
88-
echo "Branch $branch exists on origin; skipping $tag."
89-
exit 0
90-
fi
9190
# Any earlier proposal is final: merged, closed by a maintainer, or closed as
9291
# superseded by a newer pre-release. Its branch may be gone, so ask for PRs.
9392
prev=$(gh pr list -R "$sdk_repo" --head "$branch" --state all --json number,state \
@@ -96,11 +95,17 @@ if [ -n "$prev" ]; then
9695
echo "Proposal $prev exists for $tag already; skipping."
9796
exit 0
9897
fi
98+
# No PR, but the branch may exist: an earlier run pushed it and then failed
99+
# to open the PR. Remember its tip so the push replaces exactly that.
100+
stale_tip=$(git ls-remote --heads origin "$branch" | cut -f1)
101+
[ -z "$stale_tip" ] || echo "Branch $branch exists on origin without a PR; rebuilding it for $tag."
99102

100103
git fetch --quiet origin
101104
git rev-parse --verify --quiet "$base^{commit}" >/dev/null || die "base $base is not a commit"
102105
old=$(git show "$base:mise.toml" | pin_of)
103106
[ -n "$old" ] || die "no OPENSHELL_CORE_REF in mise.toml on $base"
107+
[[ "$old" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-pre\.[0-9]+)?$ ]] ||
108+
die "OPENSHELL_CORE_REF on $base is '$old', not a release tag; the core-sync automation does not support commit SHA pins"
104109
[ "$old" != "$tag" ] || { echo "The pin on $base is $tag already; skipping."; exit 0; }
105110

106111
work=$(mktemp -d)
@@ -190,7 +195,11 @@ if [ "$dry" -eq 1 ]; then
190195
exit 0
191196
fi
192197

193-
git push --quiet origin "$branch"
198+
if [ -n "$stale_tip" ]; then
199+
git push --quiet --force-with-lease="$branch:$stale_tip" origin "$branch"
200+
else
201+
git push --quiet origin "$branch"
202+
fi
194203
url=$(gh pr create -R "$sdk_repo" --base main --head "$branch" \
195204
--title "chore(core): track $tag" --body-file "$body" \
196205
--label core-bump --label "$kind")

0 commit comments

Comments
 (0)