Skip to content

Commit 2d0350d

Browse files
committed
up
1 parent 5f1d953 commit 2d0350d

1 file changed

Lines changed: 98 additions & 0 deletions

File tree

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Promote commit to viable/strict
2+
3+
# Manual escape hatch for the sampled-CI gating in
4+
# `_ci-run-decision.yml` + `viable-strict-gate.yml`.
5+
#
6+
# Pushes a `ciflow/trunk/<sha>` tag at a chosen commit, which:
7+
# 1. Re-triggers `pull.yml` / `trunk.yml` against that commit with
8+
# ``is-full-run = true`` (every gated job runs regardless of
9+
# path filter or SHA sample).
10+
# 2. Triggers `viable-strict-gate.yml` for that commit; the gate
11+
# succeeds because tag pushes always count as a full-run.
12+
#
13+
# Once those tag-triggered runs all pass, the next
14+
# `update-viablestrict` cron run will be able to advance viable/strict
15+
# to the chosen commit.
16+
#
17+
# Use cases:
18+
# - Bisecting a regression on a non-sampled commit.
19+
# - Pre-release validation: pin viable/strict to a specific commit
20+
# (e.g. release branch tip) regardless of its SHA's sample bit.
21+
# - Recovering when recent sampled commits all happen to be red.
22+
23+
on:
24+
workflow_dispatch:
25+
inputs:
26+
sha:
27+
description: "Full 40-char SHA on main / release/* to promote"
28+
required: true
29+
type: string
30+
31+
permissions:
32+
contents: write
33+
34+
concurrency:
35+
# One in-flight promotion at a time; safer than racing tag pushes.
36+
group: promote-to-viable-strict
37+
cancel-in-progress: false
38+
39+
jobs:
40+
push-ciflow-tag:
41+
if: ${{ github.repository_owner == 'pytorch' }}
42+
runs-on: ubuntu-22.04
43+
steps:
44+
- uses: actions/checkout@v4
45+
with:
46+
fetch-depth: 0
47+
48+
- name: Validate SHA and push ciflow tag
49+
env:
50+
SHA: ${{ inputs.sha }}
51+
run: |
52+
set -euo pipefail
53+
54+
# Reject anything that isn't a full 40-char lowercase hex SHA.
55+
if [[ ! "$SHA" =~ ^[0-9a-f]{40}$ ]]; then
56+
echo "::error::Input must be a full 40-char lowercase hex SHA; got: '$SHA'"
57+
exit 1
58+
fi
59+
60+
# The commit must exist locally (fetch-depth: 0 above pulls
61+
# everything, but defensively confirm it's an object).
62+
if ! git cat-file -e "$SHA^{commit}" 2>/dev/null; then
63+
echo "::error::SHA $SHA is not a commit in this repository."
64+
exit 1
65+
fi
66+
67+
# Restrict promotion to commits reachable from a release-track
68+
# branch. Prevents tagging arbitrary commits (PR heads,
69+
# rewritten branches, etc.) that aren't part of the official
70+
# main/release history.
71+
REACHABLE=false
72+
for branch in main $(git branch -r | grep -E 'origin/release/' | sed 's|origin/||'); do
73+
if git merge-base --is-ancestor "$SHA" "origin/$branch" 2>/dev/null; then
74+
echo "SHA is reachable from origin/$branch"
75+
REACHABLE=true
76+
break
77+
fi
78+
done
79+
if [ "$REACHABLE" = "false" ]; then
80+
echo "::error::SHA $SHA is not reachable from main or any release/* branch."
81+
exit 1
82+
fi
83+
84+
TAG="ciflow/trunk/$SHA"
85+
86+
# If the tag already exists (e.g. someone already promoted
87+
# this commit), exit cleanly — no-op is a valid outcome.
88+
if git ls-remote --tags --exit-code origin "refs/tags/$TAG" >/dev/null 2>&1; then
89+
echo "Tag $TAG already exists on origin; nothing to do."
90+
exit 0
91+
fi
92+
93+
git config user.name "pytorchbot"
94+
git config user.email "pytorchbot@users.noreply.github.com"
95+
git tag "$TAG" "$SHA"
96+
git push origin "$TAG"
97+
98+
echo "::notice::Pushed $TAG. Watch the tag-triggered workflow runs (pull / trunk / viable-strict-gate); once they pass, the next update-viablestrict cron (every 30 min) will advance viable/strict."

0 commit comments

Comments
 (0)