Copilot commented on code in PR #8378:
URL: https://github.com/apache/texera/pull/8378#discussion_r3922489650


##########
.github/workflows/direct-backport-push.yml:
##########
@@ -990,9 +1036,15 @@ jobs:
 
               pr = (await github.rest.pulls.create({
                 owner, repo, base: TARGET_BRANCH, head: BRANCH,
-                title, body, draft: true,
+                title, body, draft: !clean,

Review Comment:
   On a rerun, an existing PR bypasses this `draft: !clean` assignment 
entirely. Because the branch name is deterministic and force-pushed, a backport 
that changes from conflicted to clean remains a draft (so auto-merge cannot be 
armed), while one that changes from clean to conflicted remains ready for 
review despite now containing conflict markers. Synchronize the existing PR's 
draft/readiness state with `clean` before continuing.



##########
.github/workflows/direct-backport-push.yml:
##########
@@ -1059,11 +1115,131 @@ jobs:
             // backport" signal visible on main next to the successful ones.
             try {
               await github.rest.repos.createCommitStatus({
-                owner, repo, sha: MERGE_SHA, state: "failure",
+                owner, repo, sha: MERGE_SHA,
+                // A clean backport is on its way, not stuck: only the ones
+                // needing hands carry the red "needs backport" signal on main.
+                state: clean ? "success" : "failure",
                 context: `backport/${TARGET_BRANCH}`,
-                description: `Draft backport PR #${pr.number} opened`,
+                description: clean
+                  ? `Backport PR #${pr.number} open, auto-merge armed`

Review Comment:
   This records a successful backport and claims auto-merge is armed before the 
next step closes/reopens the PR or enables auto-merge. If reopening fails, the 
status remains green while pointing to a closed, dropped backport; if enabling 
auto-merge fails, its description remains false. Publish a pending status 
first, then update it to success only after reopening/arming succeeds, and to 
failure/manual-action when either operation fails.



##########
.github/workflows/direct-backport-push.yml:
##########
@@ -1059,11 +1115,131 @@ jobs:
             // backport" signal visible on main next to the successful ones.
             try {
               await github.rest.repos.createCommitStatus({
-                owner, repo, sha: MERGE_SHA, state: "failure",
+                owner, repo, sha: MERGE_SHA,
+                // A clean backport is on its way, not stuck: only the ones
+                // needing hands carry the red "needs backport" signal on main.
+                state: clean ? "success" : "failure",
                 context: `backport/${TARGET_BRANCH}`,
-                description: `Draft backport PR #${pr.number} opened`,
+                description: clean
+                  ? `Backport PR #${pr.number} open, auto-merge armed`
+                  : `Draft backport PR #${pr.number} opened`,
                 target_url: prUrl,
               });
             } catch (e) {
               core.warning(`Could not set commit status: ${e.message}`);
             }
+
+            // Handed to the step below, which starts this PR's checks and arms
+            // auto-merge — both need a token that can trigger workflows.
+            if (clean) core.setOutput("clean_pr", String(pr.number));
+
+      # GitHub suppresses workflow runs for anything GITHUB_TOKEN does, so the
+      # pull request opened above starts with no checks at all. A conflicted 
one
+      # does not care: it is a draft, and CI fires when its author pushes a
+      # resolution. A clean one has nobody to push anything, so its three
+      # required contexts would never appear and auto-merge would wait on them
+      # forever — the backport would look like it was progressing while sitting
+      # still.
+      #
+      # Closing and reopening it under a token that can trigger workflows emits
+      # `pull_request: reopened`, which Required Checks, Check License Headers
+      # and Validate PR title all subscribe to. The pull request keeps
+      # github-actions[bot] as its author; only these two events carry the
+      # token owner's name.
+      - name: Start checks and arm auto-merge
+        if: ${{ matrix.clean == 'true' && steps.open.outputs.clean_pr }}
+        uses: actions/github-script@v9
+        env:
+          CLEAN_PR: ${{ steps.open.outputs.clean_pr }}
+          ORIGINAL_PR: ${{ matrix.pr_number }}
+          TARGET_BRANCH: ${{ matrix.target }}
+        with:
+          github-token: ${{ secrets.AUTO_MERGE_TOKEN || secrets.GITHUB_TOKEN }}

Review Comment:
   Falling back to `GITHUB_TOKEN` breaks the purpose of this step: GitHub 
suppresses the close/reopen-triggered workflow runs for that token, yet the 
script can still complete and arm auto-merge with the three required contexts 
never created. Require `AUTO_MERGE_TOKEN` here so a missing secret fails 
visibly instead of producing a permanently waiting backport.



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