vatsrahul1001 commented on code in PR #75329:
URL: https://github.com/apache/airflow/pull/75329#discussion_r4367915279


##########
.github/workflows/release-constraints.yml:
##########
@@ -231,39 +230,37 @@ jobs:
         with:
           pattern: constraints-*
           path: ./files
-      # A candidate's branch and tag belong to that candidate alone, so 
re-running for the same
-      # rc replaces them rather than adding to them: the branch would 
otherwise already hold the
-      # previous run's constraints (making the push a non-fast-forward) and 
the tag already exist.
-      # A final never gets this - it commits onto the shared constraints-X-Y 
branch, whose history
-      # every other build reads.
-      - name: "Delete the previous ${{ needs.build-info.outputs.target-branch 
}} branch and tag"
+      # Re-running for the same pre-release adds a commit on constraints-X-Y 
and moves its tag, so
+      # the previous run's tag is deleted first. A leftover 
constraints-<VERSION> branch (from when
+      # pre-releases had a branch of their own) would make that tag name 
ambiguous, so it fails fast.
+      - name: "Check for a stale constraints-${{ inputs.version }} branch and 
replace the tag"
         if: needs.build-info.outputs.allow-pre-releases == 'true'
         working-directory: "constraints"
         shell: bash
         run: |
-          if git ls-remote --exit-code origin "refs/heads/${TARGET_BRANCH}" > 
/dev/null; then
-            echo "Deleting the existing '${TARGET_BRANCH}' branch."
-            git push origin --delete "refs/heads/${TARGET_BRANCH}"
+          if git ls-remote --exit-code origin 
"refs/heads/constraints-${VERSION}" > /dev/null; then
+            echo "ERROR! Branch 'constraints-${VERSION}' must not exist -" \
+              "it would make the 'constraints-${VERSION}' tag ambiguous."
+            echo "Delete it first, e.g.: git push upstream --delete 
'refs/heads/constraints-${VERSION}'"
+            exit 1
           fi
           if git ls-remote --exit-code origin 
"refs/tags/constraints-${VERSION}" > /dev/null; then
             echo "Deleting the existing 'constraints-${VERSION}' tag."
             git push origin --delete "refs/tags/constraints-${VERSION}"
           fi
           git tag --delete "constraints-${VERSION}" > /dev/null 2>&1 || true
-          git branch --delete --force "${TARGET_BRANCH}" > /dev/null 2>&1 || 
true
       - name: "Switch to ${{ needs.build-info.outputs.target-branch }}"
         working-directory: "constraints"
         shell: bash
-        run: git switch -c "${TARGET_BRANCH}" 2>/dev/null || git switch 
"${TARGET_BRANCH}"
+        run: git switch "${TARGET_BRANCH}"
       - name: "Diff in constraints for Python: ${{ 
needs.build-info.outputs.python-versions-list-as-string }}"
         run: ./scripts/ci/constraints/ci_diff_constraints.sh
       - name: "Commit changed constraint files"
         run: ./scripts/ci/constraints/ci_commit_constraints.sh
       - name: "Push ${{ needs.build-info.outputs.target-branch }}"
         working-directory: "constraints"
         shell: bash
-        # Qualify as refs/heads/ -- for a release candidate the branch and the 
tag share a name
-        # (both constraints-<VERSION>), so a bare refspec is ambiguous 
("matches more than one").
+        # Qualify as refs/heads/ so the push never resolves to a same-named 
tag.
         run: git push origin "refs/heads/${TARGET_BRANCH}"

Review Comment:
   Addressed in 4a09f1f — the push step now rebases onto the latest 
`constraints-X-Y` and retries (up to 5x) on a non-fast-forward, so a concurrent 
`update-constraints-on-push` commit landing during the beta/rc window no longer 
fails the run or forces a manual re-run.



##########
.github/workflows/release-constraints.yml:
##########
@@ -231,39 +230,37 @@ jobs:
         with:
           pattern: constraints-*
           path: ./files
-      # A candidate's branch and tag belong to that candidate alone, so 
re-running for the same
-      # rc replaces them rather than adding to them: the branch would 
otherwise already hold the
-      # previous run's constraints (making the push a non-fast-forward) and 
the tag already exist.
-      # A final never gets this - it commits onto the shared constraints-X-Y 
branch, whose history
-      # every other build reads.
-      - name: "Delete the previous ${{ needs.build-info.outputs.target-branch 
}} branch and tag"
+      # Re-running for the same pre-release adds a commit on constraints-X-Y 
and moves its tag, so
+      # the previous run's tag is deleted first. A leftover 
constraints-<VERSION> branch (from when
+      # pre-releases had a branch of their own) would make that tag name 
ambiguous, so it fails fast.
+      - name: "Check for a stale constraints-${{ inputs.version }} branch and 
replace the tag"
         if: needs.build-info.outputs.allow-pre-releases == 'true'
         working-directory: "constraints"
         shell: bash
         run: |
-          if git ls-remote --exit-code origin "refs/heads/${TARGET_BRANCH}" > 
/dev/null; then
-            echo "Deleting the existing '${TARGET_BRANCH}' branch."
-            git push origin --delete "refs/heads/${TARGET_BRANCH}"
+          if git ls-remote --exit-code origin 
"refs/heads/constraints-${VERSION}" > /dev/null; then
+            echo "ERROR! Branch 'constraints-${VERSION}' must not exist -" \
+              "it would make the 'constraints-${VERSION}' tag ambiguous."
+            echo "Delete it first, e.g.: git push upstream --delete 
'refs/heads/constraints-${VERSION}'"

Review Comment:
   Fixed in 4a09f1f — the hint now prints `git push origin --delete …` to match 
the `origin` used throughout the workflow.



##########
.github/workflows/release-constraints.yml:
##########
@@ -118,15 +118,14 @@ jobs:
           constraints_branch="constraints-${major}-${minor}"
           echo "constraints-branch=${constraints_branch}" >> "${GITHUB_OUTPUT}"
           # A pre-release - beta or rc - pins the providers at the versions 
PyPI holds (rc provider
-          # waves included) and lands on a branch and tag of its own, so it 
never moves the shared
-          # constraints-X-Y branch. A final pins released providers and 
commits onto the shared branch.
+          # waves included); a final pins released providers. Both commit onto 
the shared
+          # constraints-X-Y branch and are tagged constraints-<VERSION>.

Review Comment:
   Acknowledged — keeping the behavior as-is; it's the intended tradeoff. 
Resolving. (The only edge is a patch line like `constraints-3-3` transiently 
exposing rc provider pins on the rolling branch between this run and the next 
`update-constraints-on-push`, which is acceptable.)



-- 
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]

Reply via email to