You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@texera.apache.org by "mengw15 (via GitHub)" <gi...@apache.org> on 2026/08/29 06:41:17 UTC

[PR] ci: gate each backport on its release manager's approval [texera]

mengw15 opened a new pull request, #8096:
URL: https://github.com/apache/texera/pull/8096

   ### What changes were proposed in this PR?
   
   A `fix:` PR into `main` is auto-labeled with every actively-supported `release/*` branch, and until now that label alone decided the backport: whatever was labeled at merge time got cherry-picked to the release branch, whether or not the branch's release manager had looked at it. The review request #6940 added is advisory only.
   
   This makes the label a nomination and the manager's approval the decision. In Direct Backport Push's discover step, each labeled target is now checked against the latest review state of the `manager` configured for that branch in `.github/release-branches.yml`, before any of the much more expensive apply/build signal reads. Managers gate their own branch and nothing else, so approvals compose — with `release/v1.2` and `release/v1.3` both labeled, an approval from the v1.2 manager alone lands the fix on v1.2 and leaves v1.3 behind; both approving lands it on both; neither approving lands it on neither.
   
   `COMMENTED` reviews never change an approval and a later `CHANGES_REQUESTED` or `DISMISSED` revokes one; a manager who authored the fix counts as approving it, since GitHub does not let anyone approve their own PR; a target configuring no `manager` stays ungated; and an unreadable review list holds every gated target back rather than guessing.
   
   A held-back target otherwise leaves no trace — no cherry-pick, no draft backport PR, no check — so the merged PR gets a comment naming each one and why it was held back: no approval yet, an approval dismissed before the merge, changes requested, or a review list that could not be read at all. The distinction matters because a flat "not approved" reads as "you never looked at it" even when the manager had approved; it is also why an unreadable review list is kept distinct from an empty one instead of collapsing both to "nobody approved". The pre-merge auto-label report states the requirement up front, so it is visible before the merge rather than only after it.
   
   ### Any related issues, documentation, discussions?
   
   Closes #8084. Follow-on to #6940, which built this backport pipeline.
   
   ### How was this PR tested?
   
   Drove the gate (`managerReviewStates` + `splitByApproval`) and the comment's reason renderer through a Node harness covering 17 cases: the three headline outcomes (both managers approve / one approves / neither), revocation by a later `CHANGES_REQUESTED` and by a `DISMISSED`, an approval surviving a later `COMMENTED`, re-approval after changes were requested, a non-manager's approval not counting, manager-as-author, an ungated target, case-insensitive login matching, a failing `listReviews` holding every gated target back, and the wording each of the four hold-back reasons produces.
   
   All pass. Deliberately inverting the approval check, dropping the dismissed-approval wording, and collapsing the unreadable-review-list case each turn the run red (exit 1), so the harness can genuinely fail. Both edited workflows parse as YAML, every embedded `github-script` body passes `node --check`, and `release_branches.py` still parses the annotated config unchanged.
   
   The harness is not checked in: it recovers the logic by slicing the inline script out of the YAML, so an unrelated comment edit would break it, and the repo has no precedent for unit-testing inline `github-script` bodies.
   
   ### Was this PR authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code (claude-opus-5)
   


-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ci: block the merge until each release/* label has its manager's approval [texera]

Posted by "mengw15 (via GitHub)" <gi...@apache.org>.
mengw15 commented on code in PR #8096:
URL: https://github.com/apache/texera/pull/8096#discussion_r3921723700


##########
.github/workflows/backport-approval-check.yml:
##########
@@ -0,0 +1,296 @@
+# 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.
+
+# Blocks the merge while a `release/*` label on the PR has not been approved by
+# that branch's release manager (.github/release-branches.yml).
+#
+# The point is that a merged PR's labels should be a truthful record. A label
+# only nominates a branch, so before this check a manager declined a backport by
+# staying silent — and the label stayed on, which read afterwards as "this
+# shipped in 1.2" when it had not. Here declining is an action: the manager
+# either approves, or removes their label. Since the merge waits for every
+# remaining label to be approved, the labels on a merged PR are exactly the
+# branches Direct Backport Push then sends the fix to.
+#
+# The author's job is to ask the manager for that call, not to make it for them.
+# Editing labels needs triage access, so outside contributors and Renovate or
+# Dependabot PRs cannot remove a label themselves — the failure report says so
+# and names who to ask.
+#
+# `Backport Approvals` is listed in .asf.yaml's required_status_checks, so this
+# job must produce a result on EVERY pull request, or a PR that never runs it
+# waits forever. That is why it is not conditioned on the title, the labels, or
+# the base branch: it always runs and reports success when there is nothing to
+# approve. Merge groups are re-evaluated rather than waved through, because a
+# queued PR's own checks are no longer consulted once it is queued; a group
+# whose PRs cannot be resolved fails closed rather than passing unchecked. Do
+# not rename the job — its display name is the required context.
+
+name: Backport Approval Check
+
+on:
+  pull_request:
+    types:
+      - opened
+      - reopened
+      - synchronize
+      - labeled
+      - unlabeled
+      # Retargeting arrives as `edited`, and the verdict depends on the base
+      # branch: a backport PR into release/* has nothing to approve, the same
+      # PR moved onto main does.
+      - edited
+  pull_request_review:
+    types:
+      - submitted
+      - dismissed
+  merge_group:
+
+# Read-only: this job never writes to the PR, and `pull_request_review` runs
+# with the base repository's token even for fork PRs.
+permissions:
+  contents: read
+  pull-requests: read
+
+concurrency:
+  group: backport-approvals-${{ github.event.pull_request.number || github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  backport-approvals:
+    # Do not rename — this display name is the required status check context
+    # referenced in .asf.yaml.
+    name: Backport Approvals
+    runs-on: ubuntu-latest
+    steps:
+      # The PR's own head (or the queued group's), so the config is the one that
+      # will govern this change once it merges. Checking out the base would not
+      # be a security boundary anyway: on `pull_request` the workflow definition
+      # itself comes from the PR. What bounds this is the event — a fork gets a
+      # read-only token and no secrets, and nothing here writes to the PR.
+      - name: Checkout
+        uses: actions/checkout@v7
+        with:
+          ref: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }}
+          persist-credentials: false
+
+      - name: Read release branches
+        id: targets
+        run: |
+          entries=$(python3 .github/scripts/release_branches.py .github/release-branches.yml)
+          echo "entries=${entries}" >> "$GITHUB_OUTPUT"
+          echo "Release branch targets: ${entries}"
+
+      - name: Check release manager approvals
+        uses: actions/github-script@v9
+        env:
+          ENTRIES: ${{ steps.targets.outputs.entries }}
+        with:
+          script: |
+            const { owner, repo } = context.repo;
+            const managers = new Map(
+              JSON.parse(process.env.ENTRIES || "[]").map((e) => [
+                e.branch,
+                e.manager || "",
+              ])
+            );
+
+            // A merge group carries several PRs and its commits are the squash
+            // merges, so the number is parsed out of each subject — the same way
+            // precheck.yml resolves them.
+            async function pullRequestNumbers() {
+              if (context.eventName !== "merge_group") {
+                return [context.payload.pull_request.number];
+              }
+              const mg = context.payload.merge_group;
+              const { data: comparison } = await github.rest.repos.compareCommits({
+                owner, repo, base: mg.base_sha, head: mg.head_sha,
+              });
+              return comparison.commits.map((c) => {
+                const m = c.commit.message.split("\n", 1)[0].match(/\(#(\d+)\)\s*$/);
+                if (!m) throw new Error(`no PR number in the message of ${c.sha}`);
+                return Number(m[1]);
+              });
+            }
+
+            // Latest review state per login. COMMENTED never changes an approval;
+            // a later CHANGES_REQUESTED or DISMISSED revokes one. listReviews is
+            // documented to return reviews chronologically, so the last state
+            // recorded for a login is the one that counts. `null` means the list
+            // could not be read at all — kept distinct from an empty list, since
+            // "we did not look" must never be reported as "nobody approved".
+            async function reviewStates(number) {
+              try {
+                const reviews = await github.paginate(github.rest.pulls.listReviews, {
+                  owner, repo, pull_number: number, per_page: 100,
+                });
+                const states = new Map();
+                for (const review of reviews) {
+                  const login = review.user?.login;
+                  if (!login || review.state === "COMMENTED") continue;
+                  states.set(login.toLowerCase(), review.state);
+                }
+                return states;
+              } catch (e) {
+                core.warning(
+                  `listReviews for #${number} failed (${e.status ?? "?"}): ${e.message}`
+                );
+                return null;
+              }
+            }
+
+            // Managers gate their own branch and nothing else, so approvals
+            // compose: an approval from the v1.2 manager alone clears v1.2 and
+            // leaves v1.3 blocked.
+            function decide(targets, author, states) {
+              const authorLogin = (author || "").toLowerCase();
+              const cleared = [];
+              const blocked = [];
+              for (const target of targets) {
+                // release-branches.yml is the authorization source, so a label
+                // naming a branch it does not list has nobody who could approve
+                // it. That differs from an entry that deliberately omits
+                // `manager`, and the difference is reachable: retiring a branch
+                // means dropping its entry while its label lives on.
+                if (!managers.has(target)) {
+                  blocked.push({ target, manager: "", state: "UNCONFIGURED" });
+                  continue;
+                }
+                const manager = managers.get(target);
+                if (!manager) {
+                  cleared.push({ target, note: "no release manager configured for this branch" });
+                  continue;
+                }
+                // GitHub does not let anyone approve their own PR, so a manager
+                // who wrote the fix counts as having signed off. Logins are
+                // case-insensitive while `manager` is typed by hand, so fold both.
+                if (manager.toLowerCase() === authorLogin) {
+                  cleared.push({ target, note: `@${manager} is the author of this PR` });
+                  continue;
+                }
+                const state = states ? states.get(manager.toLowerCase()) : "UNKNOWN";
+                if (state === "APPROVED") {
+                  cleared.push({ target, note: `approved by @${manager}` });
+                } else {
+                  blocked.push({ target, manager, state: state || "NONE" });
+                }
+              }
+              return { cleared, blocked };
+            }
+
+            // Say only what the state proves. A dismissal lands on DISMISSED
+            // whatever the review was — GitHub dismisses a blocking
+            // CHANGES_REQUESTED as readily as it clears a stale approval — so
+            // naming it an approval would put a guess in the manager's mouth.
+            function reason(e) {
+              if (e.state === "UNCONFIGURED") {
+                return "this branch is not listed in .github/release-branches.yml, " +
+                  "so no release manager governs it — drop the label, or add the " +
+                  "branch back to that file";
+              }
+              if (e.state === "DISMISSED") {
+                return `@${e.manager}'s review was dismissed, so no approval stands`;
+              }
+              if (e.state === "CHANGES_REQUESTED") {
+                return `@${e.manager} requested changes and has not approved since`;
+              }
+              if (e.state === "UNKNOWN") {
+                return `this PR's reviews could not be read, so @${e.manager}'s ` +
+                  `approval could not be confirmed`;
+              }
+              return `needs an approving review from @${e.manager}`;
+            }
+
+            let numbers;
+            try {
+              numbers = await pullRequestNumbers();
+            } catch (e) {
+              // Fail closed. Only reachable for a merge group whose commits
+              // cannot be mapped back to PRs, and a group whose approvals
+              // cannot be read is not a group this can vouch for — passing it
+              // would leave the queue ungated in exactly the window this job
+              // exists to cover. Ejecting the group is recoverable: its PRs
+              // re-queue, and each still holds its own passing check.
+              core.setFailed(
+                `Could not resolve the pull requests in this merge group ` +
+                `(${e.message}). Refusing to pass a check that could not be ` +
+                `computed.`
+              );
+              return;
+            }
+
+            const lines = [];
+            let failed = false;
+
+            for (const number of numbers) {
+              const { data: pr } = await github.rest.pulls.get({
+                owner, repo, pull_number: number,
+              });
+              // A PR already targeting a release branch is itself a backport and
+              // is not backported onward; `no-backport-needed` vetoes the lot,
+              // the same way it does in precheck and in the post-merge push.
+              const labels = (pr.labels || []).map((l) => l.name);
+              const targets =
+                pr.base.ref !== "main" || labels.includes("no-backport-needed")

Review Comment:
   Thanks — taking that, and the reasoning is better than mine: the veto rewriting the record silently is exactly the failure this check exists to make impossible, and doing it from the one `pull_request_target` workflow with a write token is the worst place for an unattended mutation. Leaving it as a report. Agreed the `precheck.yml:327-331` wording is now half-true and belongs in its own change.



##########
.github/workflows/backport-approval-check.yml:
##########
@@ -0,0 +1,316 @@
+# 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.
+
+# Blocks the merge while a `release/*` label on the PR has not been approved by
+# that branch's release manager (.github/release-branches.yml).
+#
+# The point is that a merged PR's labels should be a truthful record. A label
+# only nominates a branch, so before this check a manager declined a backport by
+# staying silent — and the label stayed on, which read afterwards as "this
+# shipped in 1.2" when it had not. Here declining is an action: the manager
+# either approves, or removes their label. Since the merge waits for every
+# remaining label to be approved, the labels on a merged PR are exactly the
+# branches Direct Backport Push then sends the fix to.
+#
+# The author's job is to ask the manager for that call, not to make it for them.
+# Editing labels needs triage access, so outside contributors and Renovate or
+# Dependabot PRs cannot remove a label themselves — the failure report says so
+# and names who to ask.
+#
+# `Backport Approvals` is listed in .asf.yaml's required_status_checks, so this
+# job must produce a result on EVERY pull request, or a PR that never runs it
+# waits forever. That is why it is not conditioned on the title, the labels, or
+# the base branch: it always runs and reports success when there is nothing to
+# approve. Merge groups are re-evaluated rather than waved through, because a
+# queued PR's own checks are no longer consulted once it is queued; a group
+# whose PRs cannot be resolved fails closed rather than passing unchecked. Do
+# not rename the job — its display name is the required context.
+
+name: Backport Approval Check
+
+on:
+  pull_request:
+    types:
+      - opened
+      - reopened
+      - synchronize
+      - labeled
+      - unlabeled
+      # Retargeting arrives as `edited`, and the verdict depends on the base
+      # branch: a backport PR into release/* has nothing to approve, the same
+      # PR moved onto main does.
+      - edited
+  pull_request_review:
+    types:
+      - submitted
+      - dismissed
+  merge_group:
+
+# Read-only: this job never writes to the PR, and `pull_request_review` runs
+# with the base repository's token even for fork PRs.
+permissions:
+  contents: read
+  pull-requests: read
+
+concurrency:
+  group: backport-approvals-${{ github.event.pull_request.number || github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  backport-approvals:
+    # Do not rename — this display name is the required status check context
+    # referenced in .asf.yaml.
+    name: Backport Approvals
+    runs-on: ubuntu-latest
+    steps:
+      # The PR's own head (or the queued group's), so the config is the one that
+      # will govern this change once it merges. Checking out the base would not
+      # be a security boundary anyway: on `pull_request` the workflow definition
+      # itself comes from the PR. What bounds this is the event — a fork gets a
+      # read-only token and no secrets, and nothing here writes to the PR.
+      - name: Checkout
+        uses: actions/checkout@v7
+        with:
+          ref: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }}
+          persist-credentials: false
+
+      - name: Read release branches
+        id: targets
+        run: |
+          entries=$(python3 .github/scripts/release_branches.py .github/release-branches.yml)
+          echo "entries=${entries}" >> "$GITHUB_OUTPUT"
+          echo "Release branch targets: ${entries}"
+
+      - name: Check release manager approvals
+        uses: actions/github-script@v9
+        env:
+          ENTRIES: ${{ steps.targets.outputs.entries }}
+        with:
+          script: |
+            const { owner, repo } = context.repo;
+            const managers = new Map(
+              JSON.parse(process.env.ENTRIES || "[]").map((e) => [
+                e.branch,
+                e.manager || "",
+              ])
+            );
+
+            // A merge group carries several PRs and its commits are the squash
+            // merges, so the number is parsed out of each subject — the same way
+            // precheck.yml resolves them.
+            async function pullRequestNumbers() {
+              if (context.eventName !== "merge_group") {
+                return [context.payload.pull_request.number];
+              }
+              const mg = context.payload.merge_group;
+              const { data: comparison } = await github.rest.repos.compareCommits({
+                owner, repo, base: mg.base_sha, head: mg.head_sha,
+              });
+              return comparison.commits.map((c) => {
+                const m = c.commit.message.split("\n", 1)[0].match(/\(#(\d+)\)\s*$/);
+                if (!m) throw new Error(`no PR number in the message of ${c.sha}`);
+                return Number(m[1]);
+              });
+            }
+
+            // Latest review state per login. COMMENTED never changes an approval;
+            // a later CHANGES_REQUESTED or DISMISSED revokes one. listReviews is
+            // documented to return reviews chronologically, so the last state
+            // recorded for a login is the one that counts. `null` means the list
+            // could not be read at all — kept distinct from an empty list, since
+            // "we did not look" must never be reported as "nobody approved".
+            async function reviewStates(number) {
+              try {
+                const reviews = await github.paginate(github.rest.pulls.listReviews, {
+                  owner, repo, pull_number: number, per_page: 100,
+                });
+                const states = new Map();
+                for (const review of reviews) {
+                  const login = review.user?.login;
+                  if (!login || review.state === "COMMENTED") continue;
+                  states.set(login.toLowerCase(), review.state);
+                }
+                return states;
+              } catch (e) {
+                core.warning(
+                  `listReviews for #${number} failed (${e.status ?? "?"}): ${e.message}`
+                );
+                return null;
+              }
+            }
+
+            // Managers gate their own branch and nothing else, so approvals
+            // compose: an approval from the v1.2 manager alone clears v1.2 and
+            // leaves v1.3 blocked.
+            function decide(targets, author, states) {

Review Comment:
   Not taking this one in this PR, and I want to give the reason rather than just deferring.
   
   Extracting my copy would not remove any of the three duplications you name — the other halves live in `precheck.yml`, `direct-backport-push.yml` and `backport-auto-label.yml`, files this PR does not touch. Real dedup means changing all four to share one module, which is a larger change than an extraction and deserves its own review. So the benefit here is testability alone, not the duplication.
   
   And testability has not been where the risk was. Across the rounds on this PR the findings were a ruleset scope, a head-vs-base checkout, a veto design gap, a doc mirror, a `bash -e` swallow, and an empty merge-group array — none of which a unit test on `decide` would have caught, and the empty-array one is in `pullRequestNumbers`, outside the pure logic. Your own traces have twice said the gate itself comes out clean, and "every copy agrees today" matches what I see.
   
   What I did take from it is the coverage gap you named in the summary: the linked proof run took the zero-target early return, so the blocked path had never executed in CI. It has now — https://github.com/apache/texera/actions/runs/33723336875 fails with `BLOCKED release/v1.2 — needs an approving review from @xuang7`, and https://github.com/apache/texera/actions/runs/33723396801 passes once the label is removed. Both are linked in the description.
   
   If you would rather this land with the extraction, say so and I will do it — I just do not want to pay for it with a fourth structural change to a PR whose logic has traced clean every round.



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ci: gate each backport on its release manager's approval [texera]

Posted by "mengw15 (via GitHub)" <gi...@apache.org>.
mengw15 commented on code in PR #8096:
URL: https://github.com/apache/texera/pull/8096#discussion_r3885967220


##########
.github/workflows/direct-backport-push.yml:
##########
@@ -270,15 +272,101 @@ jobs:
               ])
             );
 
+            // Whether a fix reaches a release branch is that branch's release
+            // manager's call, so a `release/*` label only *nominates* a target:
+            // the manager named in release-branches.yml must have approved the
+            // PR for anything to land on their branch.
+            //
+            // "Approved" is the manager's *latest* review state. COMMENTED
+            // reviews never change an approval, and a later CHANGES_REQUESTED
+            // or DISMISSED revokes an earlier one. Any dismissal lands on
+            // DISMISSED — a stale approval cleared by a push, or a blocking
+            // review dismissed by hand — so the state proves an approval is
+            // not standing, never what the dismissed review had been.
+            // listReviews returns reviews oldest-first (documented), so the
+            // last state recorded for a login is the one that counts.
+            async function managerReviewStates(pullRequest) {
+              const states = new Map();
+              try {
+                const reviews = await github.paginate(github.rest.pulls.listReviews, {
+                  owner,
+                  repo,
+                  pull_number: pullRequest.number,
+                  per_page: 100,
+                });
+                for (const review of reviews) {
+                  const login = review.user?.login;
+                  if (!login || review.state === "COMMENTED") continue;
+                  states.set(login.toLowerCase(), review.state);
+                }
+              } catch (e) {
+                // Without the review list we cannot prove an approval, and
+                // backporting unreviewed is the worse failure, so every gated
+                // target is held back. `null` (not an empty map) keeps that
+                // distinct from "read fine, nobody approved" — we must not
+                // report that a manager did not approve when we never looked.
+                core.warning(
+                  `listReviews for #${pullRequest.number} failed ` +
+                  `(${e.status ?? "?"}): ${e.message}. Treating every gated ` +
+                  `target as unapproved.`
+                );
+                return null;
+              }
+              return states;
+            }
+
+            // Split the labeled targets into the ones their release manager has
+            // signed off on and the ones still waiting. Managers gate their own
+            // branch and nothing else, so the approvals compose: with v1.2 and
+            // v1.3 both labeled, an approval from the v1.2 manager alone sends
+            // the fix to v1.2 and leaves v1.3 behind.
+            function splitByApproval(pullRequest, targets, states) {
+              const author = (pullRequest.user?.login || "").toLowerCase();
+              const approved = [];
+              const unapproved = [];
+              for (const target of targets) {
+                const manager = releaseManagers.get(target) || "";
+                if (!manager) {
+                  core.info(`${target}: no release manager configured; ungated.`);
+                  approved.push(target);

Review Comment:
   Good catch — `get(target) || ""` collapsed "absent from the config" into "listed with no manager", and it is reachable: retiring a branch means dropping its entry entirely while its `release/*` label lives on, and targets are derived from labels alone. Fixed in `cd5819bc1`: an unlisted target is now held back and reported ("not listed in .github/release-branches.yml … remove the label, or add the branch back"), and only a present entry with an empty manager stays ungated.



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ci: block the merge until each release/* label has its manager's approval [texera]

Posted by "mengw15 (via GitHub)" <gi...@apache.org>.
mengw15 commented on code in PR #8096:
URL: https://github.com/apache/texera/pull/8096#discussion_r3892809457


##########
.github/workflows/backport-approval-check.yml:
##########
@@ -0,0 +1,195 @@
+# 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.
+
+# Blocks the merge while a `release/*` label on the PR has not been approved by
+# that branch's release manager (.github/release-branches.yml).
+#
+# The point is not extra ceremony, it is that a merged PR's labels should be a
+# truthful record. A label only nominates a branch, so before this check a
+# manager declined a backport by staying silent — and the label stayed on, which
+# read afterwards as "this shipped in 1.2" when it had not. Here a decline is an
+# action: the manager either approves, or removes their label. Since the merge
+# waits for every remaining label to be approved, the label set on a merged PR
+# equals the set of branches it was backported to, by construction.
+#
+# The author's job is to ask the manager for that call, not to make it for them.
+# Editing labels needs triage access, so outside contributors and Renovate or
+# Dependabot PRs cannot remove a label themselves — the failure report says so
+# and names who to ask.
+#
+# `Backport Approvals` is listed in .asf.yaml's required_status_checks, so this
+# job must produce a result on EVERY pull request, or a PR that never runs it
+# waits forever. That is why it is not conditioned on the title, the labels, or
+# the base branch: it always runs and reports success when there is nothing to
+# approve, and merge groups pass straight through (the PRs in them were already
+# checked). Do not rename the job — its display name is the required context.
+#
+# The decision itself lives in .github/scripts/backport-gate.js, shared with
+# Direct Backport Push so the pre-merge and post-merge answers cannot drift, and
+# covered by .github/scripts/test_backport_gate.sh.
+
+name: Backport Approval Check
+
+on:
+  pull_request:
+    types:
+      - opened
+      - reopened
+      - synchronize
+      - labeled
+      - unlabeled
+  pull_request_review:
+    types:
+      - submitted
+      - dismissed
+  merge_group:
+
+# Read-only: this job never writes to the PR, and `pull_request_review` runs
+# with the base repository's token even for fork PRs.
+permissions:
+  contents: read
+  pull-requests: read
+
+concurrency:
+  group: backport-approvals-${{ github.event.pull_request.number || github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  backport-approvals:
+    # Do not rename — this display name is the required status check context
+    # referenced in .asf.yaml.
+    name: Backport Approvals
+    runs-on: ubuntu-latest
+    steps:
+      - name: Skip for merge groups
+        if: ${{ github.event_name == 'merge_group' }}
+        run: |
+          echo "Backport approvals are checked on the pull requests themselves,"
+          echo "before they enter the merge queue."

Review Comment:
   Fixed in `14cff782f` — merge groups are evaluated instead of waved through. The group's PRs are resolved with `compareCommits` plus the `(#N)` subject, mirroring how `precheck.yml` does it, and each is re-checked. If that resolution ever fails it warns and passes rather than ejecting the queue over an infrastructure hiccup, since every PR in the group passed this check individually before queueing.



##########
.github/workflows/backport-approval-check.yml:
##########
@@ -0,0 +1,195 @@
+# 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.
+
+# Blocks the merge while a `release/*` label on the PR has not been approved by
+# that branch's release manager (.github/release-branches.yml).
+#
+# The point is not extra ceremony, it is that a merged PR's labels should be a
+# truthful record. A label only nominates a branch, so before this check a
+# manager declined a backport by staying silent — and the label stayed on, which
+# read afterwards as "this shipped in 1.2" when it had not. Here a decline is an
+# action: the manager either approves, or removes their label. Since the merge
+# waits for every remaining label to be approved, the label set on a merged PR
+# equals the set of branches it was backported to, by construction.
+#
+# The author's job is to ask the manager for that call, not to make it for them.
+# Editing labels needs triage access, so outside contributors and Renovate or
+# Dependabot PRs cannot remove a label themselves — the failure report says so
+# and names who to ask.
+#
+# `Backport Approvals` is listed in .asf.yaml's required_status_checks, so this
+# job must produce a result on EVERY pull request, or a PR that never runs it
+# waits forever. That is why it is not conditioned on the title, the labels, or
+# the base branch: it always runs and reports success when there is nothing to
+# approve, and merge groups pass straight through (the PRs in them were already
+# checked). Do not rename the job — its display name is the required context.
+#
+# The decision itself lives in .github/scripts/backport-gate.js, shared with
+# Direct Backport Push so the pre-merge and post-merge answers cannot drift, and
+# covered by .github/scripts/test_backport_gate.sh.
+
+name: Backport Approval Check
+
+on:
+  pull_request:
+    types:
+      - opened
+      - reopened
+      - synchronize

Review Comment:
   Added — you're right that the verdict depends on `pr.base.ref`, so a retarget has to recompute it.



##########
.github/scripts/backport-gate.js:
##########
@@ -0,0 +1,221 @@
+// 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.
+
+// Decides which `release/*` labels on a pull request are cleared to backport.
+//
+// A label only nominates a branch; the release manager configured for it in
+// .github/release-branches.yml has to have approved the PR for the fix to land
+// there. Two workflows ask that same question and must never drift apart, so
+// the rule lives here rather than inline in either of them:
+//
+//   - Backport Approvals (.github/workflows/backport-approval-check.yml) asks
+//     it before the merge and is a required check, so a PR cannot merge while
+//     one of its labels is unapproved. That is what makes the label set on a
+//     merged PR equal to the set of branches it was backported to: declining a
+//     backport is removing the label, not staying silent.
+//   - Direct Backport Push (.github/workflows/direct-backport-push.yml) asks it
+//     again after the merge, immediately before pushing, and pushes only what
+//     is cleared. The pre-merge check cannot cover an approval dismissed in the
+//     window between it going green and the merge landing.
+//
+// Usage (JSON on stdin):
+//   backport-gate.js            -> decision as JSON on stdout, always exit 0
+//   backport-gate.js --report   -> human-readable report, exit 1 if any target
+//                                  is held back (this is the required check)
+//
+// Input:
+//   {
+//     "entries":  [{"branch": "release/v1.2", "manager": "xuang7", ...}],
+//     "targets":  ["release/v1.2", "release/v1.3"],
+//     "author":   "some-contributor",
+//     "reviews":  [{"user": {"login": "xuang7"}, "state": "APPROVED"}] | null,
+//   }
+//
+// `reviews` is the PR's review list oldest-first, exactly as the REST API
+// returns it. `null` means the list could not be read at all, which is kept
+// distinct from an empty list: "we did not look" must never be reported as
+// "nobody approved".
+
+"use strict";
+
+// A dismissal lands on DISMISSED whatever the review was — a stale approval
+// cleared by a push, or a blocking review dismissed by hand — so the state
+// proves an approval is not standing, never what the dismissed review had been.
+const HOLD_REASONS = {
+  UNCONFIGURED: (e) =>
+    `\`${e.target}\` is not listed in .github/release-branches.yml, so no ` +
+    `release manager governs it — drop the label, or add the branch back to ` +
+    `that file`,
+  DISMISSED: (e) =>
+    `@${e.manager}'s review was dismissed, so no approval stands`,
+  CHANGES_REQUESTED: (e) =>
+    `@${e.manager} requested changes and has not approved since`,
+  UNKNOWN: (e) =>
+    `this PR's reviews could not be read, so @${e.manager}'s approval could ` +
+    `not be confirmed`,
+  NONE: (e) => `needs an approving review from @${e.manager}`,
+};
+
+function holdReason(entry) {
+  const render = HOLD_REASONS[entry.state] || HOLD_REASONS.NONE;
+  return render(entry);
+}
+
+// Latest review state per login. COMMENTED reviews never change an approval,
+// and a later CHANGES_REQUESTED or DISMISSED revokes an earlier one. The REST
+// API documents that reviews come back in chronological order, so the last
+// state recorded for a login is the one that counts. `null` in, `null` out —
+// see the note on `reviews` above.
+function reviewStates(reviews) {
+  if (reviews === null || reviews === undefined) return null;
+  const states = new Map();
+  for (const review of reviews) {
+    const login = review && review.user && review.user.login;
+    if (!login || review.state === "COMMENTED") continue;
+    states.set(login.toLowerCase(), review.state);
+  }
+  return states;
+}
+
+function managerIndex(entries) {
+  return new Map(
+    (entries || []).map((entry) => [entry.branch, entry.manager || ""])
+  );
+}
+
+// Split the labeled targets into the ones their release manager has signed off
+// on and the ones still held back. Managers gate their own branch and nothing
+// else, so approvals compose: with v1.2 and v1.3 both labeled, an approval from
+// the v1.2 manager alone clears v1.2 and leaves v1.3 held back.
+// Every held-back target carries the sentence explaining it, so that the
+// required check and the post-merge skip comment quote the same words instead
+// of each re-deriving them from the state.
+function held(entry) {
+  return { ...entry, reason: holdReason(entry) };
+}
+
+function splitByApproval({ entries, targets, author, reviews }) {
+  const managers = managerIndex(entries);
+  const states = reviewStates(reviews);
+  const authorLogin = (author || "").toLowerCase();
+  const approved = [];
+  const unapproved = [];
+
+  for (const target of targets || []) {
+    // release-branches.yml is the authorization source, so a label naming a
+    // branch it does not list has nobody who could approve the backport. That
+    // is not the same as an entry that deliberately omits `manager`, and the
+    // difference is reachable: retiring a branch means dropping its entry
+    // entirely while its `release/*` label lives on.
+    if (!managers.has(target)) {
+      unapproved.push(held({ target, manager: "", state: "UNCONFIGURED" }));
+      continue;
+    }
+    const manager = managers.get(target);
+    if (!manager) {
+      approved.push({ target, manager: "", state: "UNGATED" });
+      continue;
+    }
+    // GitHub does not let anyone approve their own PR, so a manager who wrote
+    // the fix counts as having signed off on it. Logins are case-insensitive
+    // while `manager` is typed by hand into the config, so fold both.
+    if (manager.toLowerCase() === authorLogin) {
+      approved.push({ target, manager, state: "AUTHORED" });
+      continue;
+    }
+    const state = states ? states.get(manager.toLowerCase()) : "UNKNOWN";
+    if (state === "APPROVED") {
+      approved.push({ target, manager, state: "APPROVED" });
+    } else {
+      unapproved.push(held({ target, manager, state: state || "NONE" }));
+    }
+  }
+
+  return { approved, unapproved, ok: unapproved.length === 0 };
+}
+
+// What the required check prints. It is the whole explanation an author gets,
+// and the author may be an outside contributor or a bot that cannot edit
+// labels at all (that needs triage access), so it has to name both ways out
+// and say who to ask when neither is available to them.
+function renderReport(decision, targets) {
+  const lines = [];
+  if (!targets || targets.length === 0) {
+    lines.push("No `release/*` labels on this PR — nothing to approve.");
+    return lines.join("\n");
+  }
+
+  const approvedNote = {
+    APPROVED: (e) => `approved by @${e.manager}`,
+    AUTHORED: (e) => `@${e.manager} is the author of this PR`,
+    UNGATED: () => "no release manager configured for this branch",
+  };
+  for (const entry of decision.approved) {
+    const note = (approvedNote[entry.state] || approvedNote.UNGATED)(entry);
+    lines.push(`  OK    ${entry.target} — ${note}`);
+  }
+  for (const entry of decision.unapproved) {
+    lines.push(`  BLOCK ${entry.target} — ${entry.reason}`);
+  }
+
+  if (decision.ok) {
+    lines.unshift(
+      `All ${decision.approved.length} backport target(s) approved.`,
+      ""
+    );
+    return lines.join("\n");
+  }
+
+  lines.unshift(
+    `${decision.unapproved.length} of ${targets.length} backport target(s) ` +
+      `not approved.`,
+    ""
+  );
+  lines.push(
+    "",
+    "Every `release/*` label on this PR must be approved by that branch's",
+    "release manager before it can merge, so that the labels on a merged PR",
+    "are exactly the branches it was backported to.",
+    "",
+    "Each BLOCK above is the named manager's call, and either answer clears it:",
+    "  - approve this PR, to send the fix to their branch; or",
+    "  - remove the label, to decline the backport to their branch.",

Review Comment:
   Fixed — the footer is now built per block kind: the approve-or-remove guidance appears only when a block actually names a manager, and an unlisted branch gets its own "remove the label, or restore the branch's entry" sentence.



##########
.github/scripts/test_backport_gate.sh:
##########
@@ -0,0 +1,190 @@
+#!/usr/bin/env 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.
+
+# Regression tests for backport-gate.js -- the rule deciding which release/*
+# labels are cleared to backport. It is an authorization check consulted both
+# before the merge (the required Backport Approvals check) and after it (Direct
+# Backport Push), so a silent change of behaviour here would either block every
+# merge or let an unapproved fix onto a release branch.
+#
+# Discovered and run automatically by the `infra` job in build.yml, which
+# executes every .github/scripts/test_*.sh -- no workflow edit needed.
+
+set -uo pipefail
+
+command -v node >/dev/null || { echo "node is required to run these tests" >&2; exit 1; }
+
+script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+gate="$script_dir/backport-gate.js"
+rc=0
+
+pass()   { echo "ok:   $1"; }
+failed() { echo "FAIL: $1"; rc=1; }
+
+# Two active branches with distinct managers, plus the retired v1.0 that is
+# deliberately absent so "label with no config entry" stays covered.
+entries='[{"branch":"release/v1.2","manager":"xuang7","active":true},
+          {"branch":"release/v1.3","manager":"mengw15","active":true},
+          {"branch":"release/v1.1","manager":"","active":false}]'
+
+# Runs the gate and flattens its decision to "ok|approved|held" so a case reads
+# as one comparable line. Held targets carry the state that explains them,
+# which is what the report turns into prose.
+decide() {
+  node "$gate" 2>/dev/null | node -e '
+    let s = "";
+    process.stdin.on("data", (d) => (s += d)).on("end", () => {
+      const d = JSON.parse(s);
+      const approved = d.approved.map((e) => e.target).join(",");
+      const held = d.unapproved.map((e) => `${e.target}:${e.state}`).join(",");
+      process.stdout.write(`${d.ok ? "ok" : "blocked"}|${approved}|${held}`);
+    });'
+}
+
+check() { # <description> <input-json> <expected>
+  local desc="$1" input="$2" want="$3" got
+  got="$(printf '%s' "$input" | decide)"
+  if [[ "$got" == "$want" ]]; then pass "$desc"; else
+    failed "$desc"
+    echo "        want: $want"
+    echo "        got:  $got"
+  fi
+}
+
+review() { printf '{"user":{"login":"%s"},"state":"%s"}' "$1" "$2"; }
+
+input() { # <author> <targets-json> <reviews-json-or-null>
+  printf '{"entries":%s,"author":"%s","targets":%s,"reviews":%s}' \
+    "$entries" "$1" "$2" "$3"
+}
+
+both='["release/v1.2","release/v1.3"]'
+
+# --- the three outcomes the flow is built around -----------------------------
+check "both managers approve -> both cleared" \
+  "$(input contributor "$both" "[$(review xuang7 APPROVED),$(review mengw15 APPROVED)]")" \
+  "ok|release/v1.2,release/v1.3|"
+
+check "only the v1.3 manager approves -> v1.3 only" \
+  "$(input contributor "$both" "[$(review mengw15 APPROVED)]")" \
+  "blocked|release/v1.3|release/v1.2:NONE"
+
+check "neither approves -> nothing cleared" \
+  "$(input contributor "$both" '[]')" \
+  "blocked||release/v1.2:NONE,release/v1.3:NONE"
+
+# --- how an approval is won, kept and lost -----------------------------------
+check "a later CHANGES_REQUESTED revokes an approval" \
+  "$(input contributor '["release/v1.2"]' "[$(review xuang7 APPROVED),$(review xuang7 CHANGES_REQUESTED)]")" \
+  "blocked||release/v1.2:CHANGES_REQUESTED"
+
+check "a dismissal revokes an approval" \
+  "$(input contributor '["release/v1.2"]' "[$(review xuang7 APPROVED),$(review xuang7 DISMISSED)]")" \
+  "blocked||release/v1.2:DISMISSED"
+
+check "a later COMMENTED review keeps the approval" \
+  "$(input contributor '["release/v1.2"]' "[$(review xuang7 APPROVED),$(review xuang7 COMMENTED)]")" \
+  "ok|release/v1.2|"
+
+check "re-approving after changes requested restores it" \
+  "$(input contributor '["release/v1.2"]' "[$(review xuang7 CHANGES_REQUESTED),$(review xuang7 APPROVED)]")" \
+  "ok|release/v1.2|"
+
+check "someone else's approval does not count" \
+  "$(input contributor '["release/v1.2"]' "[$(review yicong-huang APPROVED)]")" \
+  "blocked||release/v1.2:NONE"
+
+check "logins compare case-insensitively" \
+  "$(input contributor '["release/v1.2"]' "[$(review XuAnG7 APPROVED)]")" \
+  "ok|release/v1.2|"
+
+# --- cases that must not deadlock a PR ---------------------------------------
+check "a manager who authored the PR counts as approving" \
+  "$(input XuAng7 '["release/v1.2"]' '[]')" \
+  "ok|release/v1.2|"
+
+check "an entry that omits its manager stays ungated" \
+  "$(input contributor '["release/v1.1"]' '[]')" \
+  "ok|release/v1.1|"
+
+check "no release labels at all -> nothing to approve" \
+  "$(input contributor '[]' '[]')" \
+  "ok||"
+
+# --- fail closed, and never claim more than the state proves -----------------
+check "a label with no config entry is held, not waved through" \
+  "$(input contributor '["release/v1.0"]' "[$(review xuang7 APPROVED)]")" \
+  "blocked||release/v1.0:UNCONFIGURED"
+
+check "an unreadable review list holds every gated target" \
+  "$(input contributor "$both" 'null')" \
+  "blocked||release/v1.2:UNKNOWN,release/v1.3:UNKNOWN"
+
+# --- the required check's verdict and its wording ----------------------------
+report() { printf '%s' "$1" | node "$gate" --report 2>/dev/null; }
+
+if report "$(input contributor "$both" "[$(review xuang7 APPROVED),$(review mengw15 APPROVED)]")" >/dev/null; then
+  pass "--report exits 0 when every target is approved"
+else
+  failed "--report should exit 0 when every target is approved"
+fi
+
+if report "$(input contributor "$both" "[$(review mengw15 APPROVED)]")" >/dev/null; then
+  failed "--report should exit non-zero while a target is unapproved"
+else
+  pass "--report exits non-zero while a target is unapproved"
+fi
+
+if report "$(input contributor '[]' '[]')" >/dev/null; then
+  pass "--report exits 0 on a PR with no release labels"
+else
+  failed "--report must exit 0 on a PR with no release labels (it is a required check)"
+fi
+
+# The report is the whole explanation an author gets, so it has to name both
+# ways out and say the call belongs to the manager.
+out="$(report "$(input contributor "$both" "[$(review mengw15 APPROVED)]")")"
+for phrase in "approve this PR" "remove the label" "triage access" "@xuang7"; do
+  if [[ "$out" == *"$phrase"* ]]; then
+    pass "report mentions \"$phrase\""
+  else
+    failed "report should mention \"$phrase\""
+  fi
+done
+
+# A dismissal lands on DISMISSED whatever the review had been, so the report
+# must not tell readers an approval existed.
+out="$(report "$(input contributor '["release/v1.2"]' "[$(review xuang7 APPROVED),$(review xuang7 DISMISSED)]")")"
+if [[ "$out" == *"approved"* && "$out" != *"was dismissed"* ]]; then
+  failed "a dismissed review must not be reported as a standing approval"
+else
+  pass "a dismissed review is reported without claiming an approval existed"
+fi

Review Comment:
   Correct, and the old sentence would have sailed through it — `approval was dismissed` contains both substrings, and the report's own "not approved" header makes the first one unconditional. It now asserts the wrong phrasing is absent and the intended one present; I checked that reintroducing the old wording turns the suite red.



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ci: gate each backport on its release manager's approval [texera]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #8096:
URL: https://github.com/apache/texera/pull/8096#issuecomment-5460893638

   <!-- texera-benchmarks-comment -->
   ## ⚠️ Benchmark changes need a look
   
   🟢 0 better · 🔴 8 worse · ⚪ 7 noise (<±5%) · 0 without baseline
   
   > Compared against main `90d0404` benchmarked on **this same runner**, so the delta is largely free of cross-runner hardware noise. The "7d avg" column still reflects the gh-pages dashboard. Treat <±5% as noise unless repeated.
   
   [Dashboard](https://apache.github.io/texera/dev/bench/) · [Run](https://github.com/apache/texera/actions/runs/33239068966)
   
   | | config | throughput | MB/s | latency | max Δ latest / 7d |
   |---|---|---:|---:|---:|---:|
   | 🔴 | bs=10 sw=10 sl=64 | 397 | 0.242 | 21,949/72,597/72,597 us | 🔴 +136.2% / 🔴 +410.6% |
   | 🔴 | bs=100 sw=10 sl=64 | 937 | 0.572 | 105,023/150,849/150,849 us | 🔴 +24.2% / 🔴 +58.7% |
   | ⚪ | bs=1000 sw=10 sl=64 | 1,097 | 0.67 | 913,428/967,594/967,594 us | ⚪ within ±5% / 🔴 -7.6% |
   
   <details><summary>Baseline details</summary>
   
   Latest main `90d0404` from same runner
   
   | config | metric | PR | latest main | 7d avg | Δ latest | Δ 7d |
   |---|---|---:|---:|---:|---:|---:|
   | bs=10 sw=10 sl=64 | throughput | 397 tuples/sec | 462 tuples/sec | 894.27 tuples/sec | -14.1% | -55.6% |
   | bs=10 sw=10 sl=64 | MB/s | 0.242 MB/s | 0.282 MB/s | 0.546 MB/s | -14.2% | -55.7% |
   | bs=10 sw=10 sl=64 | p50 | 21,949 us | 22,082 us | 11,164 us | -0.6% | +96.6% |
   | bs=10 sw=10 sl=64 | p95 | 72,597 us | 30,741 us | 14,219 us | +136.2% | +410.6% |
   | bs=10 sw=10 sl=64 | p99 | 72,597 us | 30,741 us | 16,863 us | +136.2% | +330.5% |
   | bs=100 sw=10 sl=64 | throughput | 937 tuples/sec | 992 tuples/sec | 1,158 tuples/sec | -5.5% | -19.1% |
   | bs=100 sw=10 sl=64 | MB/s | 0.572 MB/s | 0.605 MB/s | 0.707 MB/s | -5.5% | -19.1% |
   | bs=100 sw=10 sl=64 | p50 | 105,023 us | 100,608 us | 88,711 us | +4.4% | +18.4% |
   | bs=100 sw=10 sl=64 | p95 | 150,849 us | 121,500 us | 95,062 us | +24.2% | +58.7% |
   | bs=100 sw=10 sl=64 | p99 | 150,849 us | 121,500 us | 102,275 us | +24.2% | +47.5% |
   | bs=1000 sw=10 sl=64 | throughput | 1,097 tuples/sec | 1,088 tuples/sec | 1,188 tuples/sec | +0.8% | -7.6% |
   | bs=1000 sw=10 sl=64 | MB/s | 0.67 MB/s | 0.664 MB/s | 0.725 MB/s | +0.9% | -7.6% |
   | bs=1000 sw=10 sl=64 | p50 | 913,428 us | 922,330 us | 874,204 us | -1.0% | +4.5% |
   | bs=1000 sw=10 sl=64 | p95 | 967,594 us | 1,007,605 us | 916,845 us | -4.0% | +5.5% |
   | bs=1000 sw=10 sl=64 | p99 | 967,594 us | 1,007,605 us | 947,186 us | -4.0% | +2.2% |
   
   </details>
   
   <details><summary>Raw CSV</summary>
   
   ```csv
   config_idx,batch_size,schema_width,string_len,num_batches,total_ms,total_tuples,total_bytes,tuples_per_sec,mb_per_sec,lat_p50_us,lat_p95_us,lat_p99_us
   0,10,10,64,20,503.61,200,128000,397,0.242,21949.17,72596.78,72596.78
   1,100,10,64,20,2135.44,2000,1280000,937,0.572,105022.61,150849.01,150849.01
   2,1000,10,64,20,18223.27,20000,12800000,1097,0.670,913427.66,967594.19,967594.19
   ```
   
   </details>
   


-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ci: block the merge until each release/* label has its manager's approval [texera]

Posted by "mengw15 (via GitHub)" <gi...@apache.org>.
mengw15 commented on code in PR #8096:
URL: https://github.com/apache/texera/pull/8096#discussion_r3920697752


##########
.asf.yaml:
##########
@@ -111,6 +111,11 @@ github:
               - context: Required Checks
               - context: Check License Headers
               - context: Validate PR title
+              # Every release/* label must be approved by that branch's release
+              # manager before the merge, so a merged PR's labels are exactly
+              # the branches it was backported to
+              # (.github/workflows/backport-approval-check.yml).
+              - context: Backport Approvals

Review Comment:
   Confirmed, and worse than fourteen — 17 PRs into `release/v1.2` are open right now, and #8111 added `refs/heads/release/v1.3` to the same ruleset since this review. A required context that is never reported is not a red X either, it is a permanent "waiting for status", so each of those would have been stuck with nothing to re-run.
   
   Fixed in `77d573c1a`: the context moved into its own ruleset scoped to `~DEFAULT_BRANCH`, so PRs into a release branch require exactly the three contexts they require today. Backporting the workflow to those branches was the alternative and is worse — it has nothing to say there (a PR already targeting a release branch reports success) and would leave a dead CI file on each release line. The Merge Queue context list now carries a comment saying not to add it back, since that list sits beside the branch list a release manager edits when cutting a new line.



##########
.github/workflows/backport-approval-check.yml:
##########
@@ -0,0 +1,296 @@
+# 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.
+
+# Blocks the merge while a `release/*` label on the PR has not been approved by
+# that branch's release manager (.github/release-branches.yml).
+#
+# The point is that a merged PR's labels should be a truthful record. A label
+# only nominates a branch, so before this check a manager declined a backport by
+# staying silent — and the label stayed on, which read afterwards as "this
+# shipped in 1.2" when it had not. Here declining is an action: the manager
+# either approves, or removes their label. Since the merge waits for every
+# remaining label to be approved, the labels on a merged PR are exactly the
+# branches Direct Backport Push then sends the fix to.
+#
+# The author's job is to ask the manager for that call, not to make it for them.
+# Editing labels needs triage access, so outside contributors and Renovate or
+# Dependabot PRs cannot remove a label themselves — the failure report says so
+# and names who to ask.
+#
+# `Backport Approvals` is listed in .asf.yaml's required_status_checks, so this
+# job must produce a result on EVERY pull request, or a PR that never runs it
+# waits forever. That is why it is not conditioned on the title, the labels, or
+# the base branch: it always runs and reports success when there is nothing to
+# approve. Merge groups are re-evaluated rather than waved through, because a
+# queued PR's own checks are no longer consulted once it is queued; a group
+# whose PRs cannot be resolved fails closed rather than passing unchecked. Do
+# not rename the job — its display name is the required context.
+
+name: Backport Approval Check
+
+on:
+  pull_request:
+    types:
+      - opened
+      - reopened
+      - synchronize
+      - labeled
+      - unlabeled
+      # Retargeting arrives as `edited`, and the verdict depends on the base
+      # branch: a backport PR into release/* has nothing to approve, the same
+      # PR moved onto main does.
+      - edited
+  pull_request_review:
+    types:
+      - submitted
+      - dismissed
+  merge_group:
+
+# Read-only: this job never writes to the PR, and `pull_request_review` runs
+# with the base repository's token even for fork PRs.
+permissions:
+  contents: read
+  pull-requests: read
+
+concurrency:
+  group: backport-approvals-${{ github.event.pull_request.number || github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  backport-approvals:
+    # Do not rename — this display name is the required status check context
+    # referenced in .asf.yaml.
+    name: Backport Approvals
+    runs-on: ubuntu-latest
+    steps:
+      # The PR's own head (or the queued group's), so the config is the one that
+      # will govern this change once it merges. Checking out the base would not
+      # be a security boundary anyway: on `pull_request` the workflow definition
+      # itself comes from the PR. What bounds this is the event — a fork gets a
+      # read-only token and no secrets, and nothing here writes to the PR.
+      - name: Checkout
+        uses: actions/checkout@v7
+        with:
+          ref: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }}
+          persist-credentials: false
+
+      - name: Read release branches
+        id: targets
+        run: |
+          entries=$(python3 .github/scripts/release_branches.py .github/release-branches.yml)
+          echo "entries=${entries}" >> "$GITHUB_OUTPUT"
+          echo "Release branch targets: ${entries}"
+
+      - name: Check release manager approvals
+        uses: actions/github-script@v9
+        env:
+          ENTRIES: ${{ steps.targets.outputs.entries }}
+        with:
+          script: |
+            const { owner, repo } = context.repo;
+            const managers = new Map(
+              JSON.parse(process.env.ENTRIES || "[]").map((e) => [
+                e.branch,
+                e.manager || "",
+              ])
+            );
+
+            // A merge group carries several PRs and its commits are the squash
+            // merges, so the number is parsed out of each subject — the same way
+            // precheck.yml resolves them.
+            async function pullRequestNumbers() {
+              if (context.eventName !== "merge_group") {
+                return [context.payload.pull_request.number];
+              }
+              const mg = context.payload.merge_group;
+              const { data: comparison } = await github.rest.repos.compareCommits({
+                owner, repo, base: mg.base_sha, head: mg.head_sha,
+              });
+              return comparison.commits.map((c) => {
+                const m = c.commit.message.split("\n", 1)[0].match(/\(#(\d+)\)\s*$/);
+                if (!m) throw new Error(`no PR number in the message of ${c.sha}`);
+                return Number(m[1]);
+              });
+            }
+
+            // Latest review state per login. COMMENTED never changes an approval;
+            // a later CHANGES_REQUESTED or DISMISSED revokes one. listReviews is
+            // documented to return reviews chronologically, so the last state
+            // recorded for a login is the one that counts. `null` means the list
+            // could not be read at all — kept distinct from an empty list, since
+            // "we did not look" must never be reported as "nobody approved".
+            async function reviewStates(number) {
+              try {
+                const reviews = await github.paginate(github.rest.pulls.listReviews, {
+                  owner, repo, pull_number: number, per_page: 100,
+                });
+                const states = new Map();
+                for (const review of reviews) {
+                  const login = review.user?.login;
+                  if (!login || review.state === "COMMENTED") continue;
+                  states.set(login.toLowerCase(), review.state);
+                }
+                return states;
+              } catch (e) {
+                core.warning(
+                  `listReviews for #${number} failed (${e.status ?? "?"}): ${e.message}`
+                );
+                return null;
+              }
+            }
+
+            // Managers gate their own branch and nothing else, so approvals
+            // compose: an approval from the v1.2 manager alone clears v1.2 and
+            // leaves v1.3 blocked.
+            function decide(targets, author, states) {
+              const authorLogin = (author || "").toLowerCase();
+              const cleared = [];
+              const blocked = [];
+              for (const target of targets) {
+                // release-branches.yml is the authorization source, so a label
+                // naming a branch it does not list has nobody who could approve
+                // it. That differs from an entry that deliberately omits
+                // `manager`, and the difference is reachable: retiring a branch
+                // means dropping its entry while its label lives on.
+                if (!managers.has(target)) {
+                  blocked.push({ target, manager: "", state: "UNCONFIGURED" });
+                  continue;
+                }
+                const manager = managers.get(target);
+                if (!manager) {
+                  cleared.push({ target, note: "no release manager configured for this branch" });
+                  continue;
+                }
+                // GitHub does not let anyone approve their own PR, so a manager
+                // who wrote the fix counts as having signed off. Logins are
+                // case-insensitive while `manager` is typed by hand, so fold both.
+                if (manager.toLowerCase() === authorLogin) {
+                  cleared.push({ target, note: `@${manager} is the author of this PR` });
+                  continue;
+                }
+                const state = states ? states.get(manager.toLowerCase()) : "UNKNOWN";
+                if (state === "APPROVED") {
+                  cleared.push({ target, note: `approved by @${manager}` });
+                } else {
+                  blocked.push({ target, manager, state: state || "NONE" });
+                }
+              }
+              return { cleared, blocked };
+            }
+
+            // Say only what the state proves. A dismissal lands on DISMISSED
+            // whatever the review was — GitHub dismisses a blocking
+            // CHANGES_REQUESTED as readily as it clears a stale approval — so
+            // naming it an approval would put a guess in the manager's mouth.
+            function reason(e) {
+              if (e.state === "UNCONFIGURED") {
+                return "this branch is not listed in .github/release-branches.yml, " +
+                  "so no release manager governs it — drop the label, or add the " +
+                  "branch back to that file";
+              }
+              if (e.state === "DISMISSED") {
+                return `@${e.manager}'s review was dismissed, so no approval stands`;
+              }
+              if (e.state === "CHANGES_REQUESTED") {
+                return `@${e.manager} requested changes and has not approved since`;
+              }
+              if (e.state === "UNKNOWN") {
+                return `this PR's reviews could not be read, so @${e.manager}'s ` +
+                  `approval could not be confirmed`;
+              }
+              return `needs an approving review from @${e.manager}`;
+            }
+
+            let numbers;
+            try {
+              numbers = await pullRequestNumbers();
+            } catch (e) {
+              // Fail closed. Only reachable for a merge group whose commits
+              // cannot be mapped back to PRs, and a group whose approvals
+              // cannot be read is not a group this can vouch for — passing it
+              // would leave the queue ungated in exactly the window this job
+              // exists to cover. Ejecting the group is recoverable: its PRs
+              // re-queue, and each still holds its own passing check.
+              core.setFailed(
+                `Could not resolve the pull requests in this merge group ` +
+                `(${e.message}). Refusing to pass a check that could not be ` +
+                `computed.`
+              );
+              return;
+            }
+
+            const lines = [];
+            let failed = false;
+
+            for (const number of numbers) {
+              const { data: pr } = await github.rest.pulls.get({
+                owner, repo, pull_number: number,
+              });
+              // A PR already targeting a release branch is itself a backport and
+              // is not backported onward; `no-backport-needed` vetoes the lot,
+              // the same way it does in precheck and in the post-merge push.
+              const labels = (pr.labels || []).map((l) => l.name);
+              const targets =
+                pr.base.ref !== "main" || labels.includes("no-backport-needed")

Review Comment:
   Confirmed — `grep -rn removeLabel` over `.github/` returns nothing here too, and `precheck.yml` does document adding the veto mid-review. One thing worth adding: `no-backport-needed` does not exist as a label in this repo at all (`GET /labels/no-backport-needed` 404s, and no PR has ever carried one), so the path has never actually been walked — but `direct-backport-push.yml` suggests creating it, so it is reachable.
   
   Fixed in `77d573c1a`, though not by removing the labels. The check now reports the contradiction per label instead of resolving it in the veto's favour: `no-backport-needed` says the fix reaches no release branch, so a `release/*` label beside it is a state the merge should not carry, and removing either one clears it. Reporting rather than auto-removing keeps this workflow read-only and avoids adding a second place that mutates labels — but if you would rather the veto did the cleanup itself, that belongs in `backport-auto-label.yml`, which already holds the write token, and I am happy to move it there.



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ci: block the merge until each release/* label has its manager's approval [texera]

Posted by "mengw15 (via GitHub)" <gi...@apache.org>.
mengw15 commented on code in PR #8096:
URL: https://github.com/apache/texera/pull/8096#discussion_r3923365730


##########
.github/workflows/backport-approval-check.yml:
##########
@@ -0,0 +1,340 @@
+# 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.
+
+# Blocks the merge while a `release/*` label on the PR has not been approved by
+# that branch's release manager (.github/release-branches.yml).
+#
+# The point is that a merged PR's labels should be a truthful record. A label
+# only nominates a branch, so before this check a manager declined a backport by
+# staying silent — and the label stayed on, which read afterwards as "this
+# shipped in 1.2" when it had not. Here declining is an action: the manager
+# either approves, or removes their label. Since the merge waits for every
+# remaining label to be approved, the labels on a merged PR are exactly the
+# branches Direct Backport Push then sends the fix to.
+#
+# The author's job is to ask the manager for that call, not to make it for them.
+# Editing labels needs triage access, so outside contributors and Renovate or
+# Dependabot PRs cannot remove a label themselves — the failure report says so
+# and names who to ask.
+#
+# `Backport Approvals` is a required status check on the default branch
+# (.asf.yaml), so this job must produce a result on every pull request into
+# `main`, or a PR that never runs it waits forever. That is why it is not
+# conditioned on the title or the labels. It is not conditioned on the base
+# branch either, for a different reason: a PR already targeting a release
+# branch is itself a backport, so the check reports success there.
+# Merge groups are re-evaluated rather than waved through, because a
+# queued PR's own checks are no longer consulted once it is queued; a group
+# whose PRs cannot be resolved fails closed rather than passing unchecked. Do
+# not rename the job — its display name is the required context.
+
+name: Backport Approval Check
+
+on:
+  pull_request:
+    types:
+      - opened
+      - reopened
+      - synchronize
+      - labeled
+      - unlabeled
+      # Retargeting arrives as `edited`, and the verdict depends on the base
+      # branch: a backport PR into release/* has nothing to approve, the same
+      # PR moved onto main does.
+      - edited
+  pull_request_review:
+    types:
+      - submitted
+      - dismissed
+  merge_group:
+
+# Read-only: this job never writes to the PR, and `pull_request_review` runs
+# with the base repository's token even for fork PRs.
+permissions:
+  contents: read
+  pull-requests: read
+
+concurrency:
+  group: backport-approvals-${{ github.event.pull_request.number || github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  backport-approvals:
+    # Do not rename — this display name is the required status check context
+    # referenced in .asf.yaml.
+    name: Backport Approvals
+    runs-on: ubuntu-latest
+    steps:
+      # The default branch, not anything the pull request points at. Neither
+      # release-branches.yml nor its parser existed before #6941, and both the
+      # head and `base.sha` can predate it: `base.sha` is main's tip at the PR's
+      # last synchronize, not now, which is stale for 33 of the open PRs into
+      # main. Either would fail the `run:` step below with a file-not-found and
+      # turn this required check red with nothing the author could do about it —
+      # backport-auto-label.yml pins `base.sha` and has been failing exactly that

Review Comment:
   Confirmed and fixed in `875812cac` — same one-liner. Checked the count while verifying: it is 20 failed runs, not twelve, from 2026-07-28 through 2026-08-11.
   
   The composition argument is the part worth keeping in the record. On its own this was a red advisory check on a PR nobody was waiting on. With the gate in place the two failures point the same way: no labeler run means no `release/*` label, which means Backport Approvals finds nothing to approve and passes, and the fix is never backported with nothing anywhere saying so. A gate whose input can fail open is not a gate — and `base.sha` was the input.
   
   That is three rounds on one line now: head (stale), base (stale in a way neither of us had priced), default branch. The pattern was that we kept asking which revision was trustworthy and neither of us asked which one existed.



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ci: gate each backport on its release manager's approval [texera]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #8096:
URL: https://github.com/apache/texera/pull/8096#discussion_r3885859456


##########
.github/workflows/direct-backport-push.yml:
##########
@@ -333,10 +440,81 @@ jobs:
 
             core.info(`Push entries: ${JSON.stringify(pushEntries)}`);
             core.info(`PR entries: ${JSON.stringify(prEntries)}`);
+            core.info(`Skipped entries: ${JSON.stringify(skippedEntries)}`);
             core.setOutput("push_entries", JSON.stringify(pushEntries));
             core.setOutput("pr_entries", JSON.stringify(prEntries));
             core.setOutput("has_push", pushEntries.length > 0 ? "true" : "false");
             core.setOutput("has_pr", prEntries.length > 0 ? "true" : "false");
+            core.setOutput("skipped_entries", JSON.stringify(skippedEntries));
+            core.setOutput("has_skipped", skippedEntries.length > 0 ? "true" : "false");
+
+      # A target held back for want of its release manager's approval leaves no
+      # other trace — no cherry-pick, no draft backport PR, no check — so say so
+      # on the PR itself. One comment per PR, naming the manager whose approval
+      # would have carried the fix across, so a merge that outran the review is
+      # visible instead of silent.
+      - name: Report approval-gated targets
+        if: ${{ steps.discover.outputs.has_skipped == 'true' }}
+        uses: actions/github-script@v9
+        env:
+          SKIPPED: ${{ steps.discover.outputs.skipped_entries }}
+        with:
+          script: |
+            const skipped = JSON.parse(process.env.SKIPPED || "[]");
+            const { owner, repo } = context.repo;
+            const runUrl =
+              `${context.serverUrl}/${owner}/${repo}/actions/runs/${context.runId}`;
+
+            const byPr = new Map();
+            for (const entry of skipped) {
+              const list = byPr.get(entry.pr_number) || [];
+              list.push(entry);
+              byPr.set(entry.pr_number, list);
+            }
+
+            for (const [prNumber, entries] of byPr) {
+              // Why a target was held back decides what the manager does
+              // about it, so name the actual reason instead of a flat "not
+              // approved" — which reads as "you never looked at it" even when
+              // they approved and the approval was later dismissed.
+              const reason = (e) => {
+                if (e.state === "DISMISSED") {
+                  return `@${e.manager} approved, but that approval was dismissed before the merge`;

Review Comment:
   `DISMISSED` does not prove that the manager previously approved: GitHub also allows a `CHANGES_REQUESTED` review to be dismissed, and both appear here as `DISMISSED`. In that case this comment falsely tells readers that an approval existed. Use wording that identifies a dismissed review without asserting its original state.



##########
.github/workflows/backport-auto-label.yml:
##########
@@ -205,6 +210,13 @@ jobs:
               for (const entry of entries) {
                 const label = entry.branch;
                 const manager = entry.manager;
+                // Say who has to sign off, so the label is not mistaken for the
+                // decision. A manager who wrote the fix needs no approval —
+                // GitHub does not let anyone approve their own PR.
+                const gate =
+                  manager && manager !== author

Review Comment:
   GitHub logins are case-insensitive, but this comparison is case-sensitive. If the configured manager differs from the author's canonical casing, the report incorrectly says the author must approve even though the post-merge gate treats them as approved. Normalize both values before comparing.
   
   This issue also appears on line 284 of the same file.



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ci: gate each backport on its release manager's approval [texera]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #8096:
URL: https://github.com/apache/texera/pull/8096#issuecomment-5460873266

   ## [Codecov](https://app.codecov.io/gh/apache/texera/pull/8096?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 93.51%. Comparing base ([`d9c0e19`](https://app.codecov.io/gh/apache/texera/commit/d9c0e19aeed027c4a61d746d875a8b46dd1db568?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`1d09fda`](https://app.codecov.io/gh/apache/texera/commit/1d09fdac1110784154d45de8fe4f9911af4c5ad7?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 5 commits behind head on main.
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@            Coverage Diff            @@
   ##               main    #8096   +/-   ##
   =========================================
     Coverage     93.51%   93.51%           
     Complexity     4708     4708           
   =========================================
     Files          1195     1195           
     Lines         48467    48467           
     Branches       5378     5378           
   =========================================
     Hits          45326    45326           
     Misses         1693     1693           
     Partials       1448     1448           
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/texera/pull/8096/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | | *Carryforward flag |
   |---|---|---|---|
   | [access-control-service](https://app.codecov.io/gh/apache/texera/pull/8096/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `81.00% <ø> (ø)` | | Carriedforward from [d9c0e19](https://app.codecov.io/gh/apache/texera/commit/d9c0e19aeed027c4a61d746d875a8b46dd1db568?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [agent-service](https://app.codecov.io/gh/apache/texera/pull/8096/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `99.32% <ø> (ø)` | | |
   | [amber](https://app.codecov.io/gh/apache/texera/pull/8096/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `89.58% <ø> (ø)` | | Carriedforward from [d9c0e19](https://app.codecov.io/gh/apache/texera/commit/d9c0e19aeed027c4a61d746d875a8b46dd1db568?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [computing-unit-managing-service](https://app.codecov.io/gh/apache/texera/pull/8096/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `73.67% <ø> (ø)` | | Carriedforward from [d9c0e19](https://app.codecov.io/gh/apache/texera/commit/d9c0e19aeed027c4a61d746d875a8b46dd1db568?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [config-service](https://app.codecov.io/gh/apache/texera/pull/8096/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `86.86% <ø> (ø)` | | Carriedforward from [d9c0e19](https://app.codecov.io/gh/apache/texera/commit/d9c0e19aeed027c4a61d746d875a8b46dd1db568?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [file-service](https://app.codecov.io/gh/apache/texera/pull/8096/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `87.91% <ø> (ø)` | | Carriedforward from [d9c0e19](https://app.codecov.io/gh/apache/texera/commit/d9c0e19aeed027c4a61d746d875a8b46dd1db568?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [frontend](https://app.codecov.io/gh/apache/texera/pull/8096/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `95.86% <ø> (ø)` | | Carriedforward from [d9c0e19](https://app.codecov.io/gh/apache/texera/commit/d9c0e19aeed027c4a61d746d875a8b46dd1db568?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [notebook-migration-service](https://app.codecov.io/gh/apache/texera/pull/8096/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `79.31% <ø> (ø)` | | Carriedforward from [d9c0e19](https://app.codecov.io/gh/apache/texera/commit/d9c0e19aeed027c4a61d746d875a8b46dd1db568?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [pyamber](https://app.codecov.io/gh/apache/texera/pull/8096/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `98.54% <ø> (ø)` | | Carriedforward from [d9c0e19](https://app.codecov.io/gh/apache/texera/commit/d9c0e19aeed027c4a61d746d875a8b46dd1db568?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [workflow-compiling-service](https://app.codecov.io/gh/apache/texera/pull/8096/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `77.19% <ø> (ø)` | | Carriedforward from [d9c0e19](https://app.codecov.io/gh/apache/texera/commit/d9c0e19aeed027c4a61d746d875a8b46dd1db568?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   
   *This pull request uses carry forward flags. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/texera/pull/8096?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ci: block the merge until each release/* label has its manager's approval [texera]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #8096:
URL: https://github.com/apache/texera/pull/8096#discussion_r3894366331


##########
.github/workflows/backport-approval-check.yml:
##########
@@ -0,0 +1,292 @@
+# 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.
+
+# Blocks the merge while a `release/*` label on the PR has not been approved by
+# that branch's release manager (.github/release-branches.yml).
+#
+# The point is that a merged PR's labels should be a truthful record. A label
+# only nominates a branch, so before this check a manager declined a backport by
+# staying silent — and the label stayed on, which read afterwards as "this
+# shipped in 1.2" when it had not. Here declining is an action: the manager
+# either approves, or removes their label. Since the merge waits for every
+# remaining label to be approved, the labels on a merged PR are exactly the
+# branches Direct Backport Push then sends the fix to.
+#
+# The author's job is to ask the manager for that call, not to make it for them.
+# Editing labels needs triage access, so outside contributors and Renovate or
+# Dependabot PRs cannot remove a label themselves — the failure report says so
+# and names who to ask.
+#
+# `Backport Approvals` is listed in .asf.yaml's required_status_checks, so this
+# job must produce a result on EVERY pull request, or a PR that never runs it
+# waits forever. That is why it is not conditioned on the title, the labels, or
+# the base branch: it always runs and reports success when there is nothing to
+# approve. Merge groups are re-evaluated rather than waved through, because a
+# queued PR's own checks are no longer consulted. Do not rename the job — its
+# display name is the required context.
+
+name: Backport Approval Check
+
+on:
+  pull_request:
+    types:
+      - opened
+      - reopened
+      - synchronize
+      - labeled
+      - unlabeled
+      # Retargeting arrives as `edited`, and the verdict depends on the base
+      # branch: a backport PR into release/* has nothing to approve, the same
+      # PR moved onto main does.
+      - edited
+  pull_request_review:
+    types:
+      - submitted
+      - dismissed
+  merge_group:
+
+# Read-only: this job never writes to the PR, and `pull_request_review` runs
+# with the base repository's token even for fork PRs.
+permissions:
+  contents: read
+  pull-requests: read
+
+concurrency:
+  group: backport-approvals-${{ github.event.pull_request.number || github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  backport-approvals:
+    # Do not rename — this display name is the required status check context
+    # referenced in .asf.yaml.
+    name: Backport Approvals
+    runs-on: ubuntu-latest
+    steps:
+      # The PR's own head (or the queued group's), so the config is the one that
+      # will govern this change once it merges. Checking out the base would not
+      # be a security boundary anyway: on `pull_request` the workflow definition
+      # itself comes from the PR. What bounds this is the event — a fork gets a
+      # read-only token and no secrets, and nothing here writes to the PR.
+      - name: Checkout
+        uses: actions/checkout@v7
+        with:
+          ref: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }}
+          persist-credentials: false
+
+      - name: Read release branches
+        id: targets
+        run: |
+          entries=$(python3 .github/scripts/release_branches.py .github/release-branches.yml)
+          echo "entries=${entries}" >> "$GITHUB_OUTPUT"
+          echo "Release branch targets: ${entries}"
+
+      - name: Check release manager approvals
+        uses: actions/github-script@v9
+        env:
+          ENTRIES: ${{ steps.targets.outputs.entries }}
+        with:
+          script: |
+            const { owner, repo } = context.repo;
+            const managers = new Map(
+              JSON.parse(process.env.ENTRIES || "[]").map((e) => [
+                e.branch,
+                e.manager || "",
+              ])
+            );
+
+            // A merge group carries several PRs and its commits are the squash
+            // merges, so the number is parsed out of each subject — the same way
+            // precheck.yml resolves them.
+            async function pullRequestNumbers() {
+              if (context.eventName !== "merge_group") {
+                return [context.payload.pull_request.number];
+              }
+              const mg = context.payload.merge_group;
+              const { data: comparison } = await github.rest.repos.compareCommits({
+                owner, repo, base: mg.base_sha, head: mg.head_sha,
+              });
+              return comparison.commits.map((c) => {
+                const m = c.commit.message.split("\n", 1)[0].match(/\(#(\d+)\)\s*$/);
+                if (!m) throw new Error(`no PR number in the message of ${c.sha}`);
+                return Number(m[1]);
+              });
+            }
+
+            // Latest review state per login. COMMENTED never changes an approval;
+            // a later CHANGES_REQUESTED or DISMISSED revokes one. listReviews is
+            // documented to return reviews chronologically, so the last state
+            // recorded for a login is the one that counts. `null` means the list
+            // could not be read at all — kept distinct from an empty list, since
+            // "we did not look" must never be reported as "nobody approved".
+            async function reviewStates(number) {
+              try {
+                const reviews = await github.paginate(github.rest.pulls.listReviews, {
+                  owner, repo, pull_number: number, per_page: 100,
+                });
+                const states = new Map();
+                for (const review of reviews) {
+                  const login = review.user?.login;
+                  if (!login || review.state === "COMMENTED") continue;
+                  states.set(login.toLowerCase(), review.state);
+                }
+                return states;
+              } catch (e) {
+                core.warning(
+                  `listReviews for #${number} failed (${e.status ?? "?"}): ${e.message}`
+                );
+                return null;
+              }
+            }
+
+            // Managers gate their own branch and nothing else, so approvals
+            // compose: an approval from the v1.2 manager alone clears v1.2 and
+            // leaves v1.3 blocked.
+            function decide(targets, author, states) {
+              const authorLogin = (author || "").toLowerCase();
+              const cleared = [];
+              const blocked = [];
+              for (const target of targets) {
+                // release-branches.yml is the authorization source, so a label
+                // naming a branch it does not list has nobody who could approve
+                // it. That differs from an entry that deliberately omits
+                // `manager`, and the difference is reachable: retiring a branch
+                // means dropping its entry while its label lives on.
+                if (!managers.has(target)) {
+                  blocked.push({ target, manager: "", state: "UNCONFIGURED" });
+                  continue;
+                }
+                const manager = managers.get(target);
+                if (!manager) {
+                  cleared.push({ target, note: "no release manager configured for this branch" });
+                  continue;
+                }
+                // GitHub does not let anyone approve their own PR, so a manager
+                // who wrote the fix counts as having signed off. Logins are
+                // case-insensitive while `manager` is typed by hand, so fold both.
+                if (manager.toLowerCase() === authorLogin) {
+                  cleared.push({ target, note: `@${manager} is the author of this PR` });
+                  continue;
+                }
+                const state = states ? states.get(manager.toLowerCase()) : "UNKNOWN";
+                if (state === "APPROVED") {
+                  cleared.push({ target, note: `approved by @${manager}` });
+                } else {
+                  blocked.push({ target, manager, state: state || "NONE" });
+                }
+              }
+              return { cleared, blocked };
+            }
+
+            // Say only what the state proves. A dismissal lands on DISMISSED
+            // whatever the review was — GitHub dismisses a blocking
+            // CHANGES_REQUESTED as readily as it clears a stale approval — so
+            // naming it an approval would put a guess in the manager's mouth.
+            function reason(e) {
+              if (e.state === "UNCONFIGURED") {
+                return "this branch is not listed in .github/release-branches.yml, " +
+                  "so no release manager governs it — drop the label, or add the " +
+                  "branch back to that file";
+              }
+              if (e.state === "DISMISSED") {
+                return `@${e.manager}'s review was dismissed, so no approval stands`;
+              }
+              if (e.state === "CHANGES_REQUESTED") {
+                return `@${e.manager} requested changes and has not approved since`;
+              }
+              if (e.state === "UNKNOWN") {
+                return `this PR's reviews could not be read, so @${e.manager}'s ` +
+                  `approval could not be confirmed`;
+              }
+              return `needs an approving review from @${e.manager}`;
+            }
+
+            let numbers;
+            try {
+              numbers = await pullRequestNumbers();
+            } catch (e) {
+              // Only reachable for a merge group whose commits cannot be mapped
+              // back to PRs. Each was checked individually before queueing, so
+              // ejecting the queue over an infrastructure hiccup would cost more
+              // than the narrow window it would close.
+              core.warning(
+                `Could not resolve the pull requests in this merge group ` +
+                `(${e.message}); they were checked individually before queueing.`
+              );
+              return;

Review Comment:
   On `merge_group` events, failing to resolve PR numbers currently returns early and leaves the job successful, which can allow the merge queue to proceed without enforcing the backport-approval gate (contradicting the workflow’s stated purpose that merge groups must be re-evaluated). Consider failing closed here (e.g., `core.setFailed(...)` / throw) so an inability to map merge-group commits to PRs blocks the merge until the check can be computed.



##########
.github/workflows/backport-approval-check.yml:
##########
@@ -0,0 +1,292 @@
+# 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.
+
+# Blocks the merge while a `release/*` label on the PR has not been approved by
+# that branch's release manager (.github/release-branches.yml).
+#
+# The point is that a merged PR's labels should be a truthful record. A label
+# only nominates a branch, so before this check a manager declined a backport by
+# staying silent — and the label stayed on, which read afterwards as "this
+# shipped in 1.2" when it had not. Here declining is an action: the manager
+# either approves, or removes their label. Since the merge waits for every
+# remaining label to be approved, the labels on a merged PR are exactly the
+# branches Direct Backport Push then sends the fix to.
+#
+# The author's job is to ask the manager for that call, not to make it for them.
+# Editing labels needs triage access, so outside contributors and Renovate or
+# Dependabot PRs cannot remove a label themselves — the failure report says so
+# and names who to ask.
+#
+# `Backport Approvals` is listed in .asf.yaml's required_status_checks, so this
+# job must produce a result on EVERY pull request, or a PR that never runs it
+# waits forever. That is why it is not conditioned on the title, the labels, or
+# the base branch: it always runs and reports success when there is nothing to
+# approve. Merge groups are re-evaluated rather than waved through, because a
+# queued PR's own checks are no longer consulted. Do not rename the job — its
+# display name is the required context.
+
+name: Backport Approval Check
+
+on:
+  pull_request:
+    types:
+      - opened
+      - reopened
+      - synchronize
+      - labeled
+      - unlabeled
+      # Retargeting arrives as `edited`, and the verdict depends on the base
+      # branch: a backport PR into release/* has nothing to approve, the same
+      # PR moved onto main does.
+      - edited
+  pull_request_review:
+    types:
+      - submitted
+      - dismissed
+  merge_group:
+
+# Read-only: this job never writes to the PR, and `pull_request_review` runs
+# with the base repository's token even for fork PRs.
+permissions:
+  contents: read
+  pull-requests: read
+
+concurrency:
+  group: backport-approvals-${{ github.event.pull_request.number || github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  backport-approvals:
+    # Do not rename — this display name is the required status check context
+    # referenced in .asf.yaml.
+    name: Backport Approvals
+    runs-on: ubuntu-latest
+    steps:
+      # The PR's own head (or the queued group's), so the config is the one that
+      # will govern this change once it merges. Checking out the base would not
+      # be a security boundary anyway: on `pull_request` the workflow definition
+      # itself comes from the PR. What bounds this is the event — a fork gets a
+      # read-only token and no secrets, and nothing here writes to the PR.
+      - name: Checkout
+        uses: actions/checkout@v7
+        with:
+          ref: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }}
+          persist-credentials: false
+
+      - name: Read release branches
+        id: targets
+        run: |
+          entries=$(python3 .github/scripts/release_branches.py .github/release-branches.yml)
+          echo "entries=${entries}" >> "$GITHUB_OUTPUT"
+          echo "Release branch targets: ${entries}"
+
+      - name: Check release manager approvals
+        uses: actions/github-script@v9
+        env:
+          ENTRIES: ${{ steps.targets.outputs.entries }}
+        with:
+          script: |
+            const { owner, repo } = context.repo;
+            const managers = new Map(
+              JSON.parse(process.env.ENTRIES || "[]").map((e) => [
+                e.branch,
+                e.manager || "",
+              ])
+            );
+
+            // A merge group carries several PRs and its commits are the squash
+            // merges, so the number is parsed out of each subject — the same way
+            // precheck.yml resolves them.
+            async function pullRequestNumbers() {
+              if (context.eventName !== "merge_group") {
+                return [context.payload.pull_request.number];
+              }
+              const mg = context.payload.merge_group;
+              const { data: comparison } = await github.rest.repos.compareCommits({
+                owner, repo, base: mg.base_sha, head: mg.head_sha,
+              });
+              return comparison.commits.map((c) => {
+                const m = c.commit.message.split("\n", 1)[0].match(/\(#(\d+)\)\s*$/);
+                if (!m) throw new Error(`no PR number in the message of ${c.sha}`);
+                return Number(m[1]);
+              });

Review Comment:
   Merge-group PR resolution depends on parsing `(#<n>)` from the first line of each commit message. That’s brittle to commit-subject formatting changes and can break the gate unexpectedly. Prefer a source of truth that doesn’t depend on message conventions (e.g., merge_group payload metadata if available, or querying GitHub for PRs associated with each commit SHA) and treat any unresolved association as a hard block rather than an ignorable condition.



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ci: block the merge until each release/* label has its manager's approval [texera]

Posted by "mengw15 (via GitHub)" <gi...@apache.org>.
mengw15 commented on PR #8096:
URL: https://github.com/apache/texera/pull/8096#issuecomment-5521553971

   All of it addressed in `1273f493e`, replies on the threads. Both new must-fixes were mine and both were verified before fixing rather than taken on the description — the head-vs-base one especially: I moved that off `base.sha` last round on an argument that priced the security question correctly and the staleness question not at all.
   
   On the two conventions items:
   
   **Proof run.** You were right that the linked run took the zero-target early return, so `decide`'s blocked path had never executed. It has now, on this PR, using the sequence you suggested:
   
   | | run | result |
   | --- | --- | --- |
   | labelled `release/v1.2`, unapproved | [33723336875](https://github.com/apache/texera/actions/runs/33723336875) | fails — `BLOCKED release/v1.2 — needs an approving review from @xuang7` |
   | label removed (the decline action) | [33723396801](https://github.com/apache/texera/actions/runs/33723396801) | passes |
   | no `release/*` label | [33722853310](https://github.com/apache/texera/actions/runs/33722853310) | passes — "nothing to approve" |
   
   That is the whole flow the description claims, executed rather than argued. All three are linked there now.
   
   **Rollout note.** Extended: the description now says that pull requests already open into `main` at the cutover show the context as "Expected" until some event triggers the workflow on them, alongside the release-branch scoping and the one-ruleset revert.
   
   The `precheck.yml:327-331` wording you flagged on the veto thread — that adding `no-backport-needed` mid-review is how you cancel a backport, now only half the action — I agree is real and belongs in its own change rather than here.


-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ci: block the merge until each release/* label has its manager's approval [texera]

Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on code in PR #8096:
URL: https://github.com/apache/texera/pull/8096#discussion_r3911023372


##########
.asf.yaml:
##########
@@ -111,6 +111,11 @@ github:
               - context: Required Checks
               - context: Check License Headers
               - context: Validate PR title
+              # Every release/* label must be approved by that branch's release
+              # manager before the merge, so a merged PR's labels are exactly
+              # the branches it was backported to
+              # (.github/workflows/backport-approval-check.yml).
+              - context: Backport Approvals

Review Comment:
   This registers `Backport Approvals` in a ruleset whose `ref_name.include` also covers `refs/heads/release/v1.1` and `refs/heads/release/v1.2` — and nothing on those branches can produce it.
   
   Verified rather than inferred: the workflow, `release_branches.py` and `release-branches.yml` all 404 on both release refs; `gh api .../rules/branches/release%2Fv1.2` returns exactly the three contexts required today; merged PR #7905 reports those same three. And `pull_request` / `merge_group` runs use the workflow from the merge ref, which for a backport PR is the release-branch base — confirmed against a run on #8124.
   
   Fourteen PRs into `release/v1.2` are open right now, nearly all draft backports this pipeline opened. They become unmergeable the moment this lands. Scoping the context to the default branch closes it.



##########
.github/workflows/backport-approval-check.yml:
##########
@@ -0,0 +1,296 @@
+# 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.
+
+# Blocks the merge while a `release/*` label on the PR has not been approved by
+# that branch's release manager (.github/release-branches.yml).
+#
+# The point is that a merged PR's labels should be a truthful record. A label
+# only nominates a branch, so before this check a manager declined a backport by
+# staying silent — and the label stayed on, which read afterwards as "this
+# shipped in 1.2" when it had not. Here declining is an action: the manager
+# either approves, or removes their label. Since the merge waits for every
+# remaining label to be approved, the labels on a merged PR are exactly the
+# branches Direct Backport Push then sends the fix to.
+#
+# The author's job is to ask the manager for that call, not to make it for them.
+# Editing labels needs triage access, so outside contributors and Renovate or
+# Dependabot PRs cannot remove a label themselves — the failure report says so
+# and names who to ask.
+#
+# `Backport Approvals` is listed in .asf.yaml's required_status_checks, so this
+# job must produce a result on EVERY pull request, or a PR that never runs it
+# waits forever. That is why it is not conditioned on the title, the labels, or
+# the base branch: it always runs and reports success when there is nothing to
+# approve. Merge groups are re-evaluated rather than waved through, because a
+# queued PR's own checks are no longer consulted once it is queued; a group
+# whose PRs cannot be resolved fails closed rather than passing unchecked. Do
+# not rename the job — its display name is the required context.
+
+name: Backport Approval Check
+
+on:
+  pull_request:
+    types:
+      - opened
+      - reopened
+      - synchronize
+      - labeled
+      - unlabeled
+      # Retargeting arrives as `edited`, and the verdict depends on the base
+      # branch: a backport PR into release/* has nothing to approve, the same
+      # PR moved onto main does.
+      - edited
+  pull_request_review:
+    types:
+      - submitted
+      - dismissed
+  merge_group:
+
+# Read-only: this job never writes to the PR, and `pull_request_review` runs
+# with the base repository's token even for fork PRs.
+permissions:
+  contents: read
+  pull-requests: read
+
+concurrency:
+  group: backport-approvals-${{ github.event.pull_request.number || github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  backport-approvals:
+    # Do not rename — this display name is the required status check context
+    # referenced in .asf.yaml.
+    name: Backport Approvals
+    runs-on: ubuntu-latest
+    steps:
+      # The PR's own head (or the queued group's), so the config is the one that
+      # will govern this change once it merges. Checking out the base would not
+      # be a security boundary anyway: on `pull_request` the workflow definition
+      # itself comes from the PR. What bounds this is the event — a fork gets a
+      # read-only token and no secrets, and nothing here writes to the PR.
+      - name: Checkout
+        uses: actions/checkout@v7
+        with:
+          ref: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }}
+          persist-credentials: false
+
+      - name: Read release branches
+        id: targets
+        run: |
+          entries=$(python3 .github/scripts/release_branches.py .github/release-branches.yml)
+          echo "entries=${entries}" >> "$GITHUB_OUTPUT"
+          echo "Release branch targets: ${entries}"
+
+      - name: Check release manager approvals
+        uses: actions/github-script@v9
+        env:
+          ENTRIES: ${{ steps.targets.outputs.entries }}
+        with:
+          script: |
+            const { owner, repo } = context.repo;
+            const managers = new Map(
+              JSON.parse(process.env.ENTRIES || "[]").map((e) => [
+                e.branch,
+                e.manager || "",
+              ])
+            );
+
+            // A merge group carries several PRs and its commits are the squash
+            // merges, so the number is parsed out of each subject — the same way
+            // precheck.yml resolves them.
+            async function pullRequestNumbers() {
+              if (context.eventName !== "merge_group") {
+                return [context.payload.pull_request.number];
+              }
+              const mg = context.payload.merge_group;
+              const { data: comparison } = await github.rest.repos.compareCommits({
+                owner, repo, base: mg.base_sha, head: mg.head_sha,
+              });
+              return comparison.commits.map((c) => {
+                const m = c.commit.message.split("\n", 1)[0].match(/\(#(\d+)\)\s*$/);
+                if (!m) throw new Error(`no PR number in the message of ${c.sha}`);
+                return Number(m[1]);
+              });
+            }
+
+            // Latest review state per login. COMMENTED never changes an approval;
+            // a later CHANGES_REQUESTED or DISMISSED revokes one. listReviews is
+            // documented to return reviews chronologically, so the last state
+            // recorded for a login is the one that counts. `null` means the list
+            // could not be read at all — kept distinct from an empty list, since
+            // "we did not look" must never be reported as "nobody approved".
+            async function reviewStates(number) {
+              try {
+                const reviews = await github.paginate(github.rest.pulls.listReviews, {
+                  owner, repo, pull_number: number, per_page: 100,
+                });
+                const states = new Map();
+                for (const review of reviews) {
+                  const login = review.user?.login;
+                  if (!login || review.state === "COMMENTED") continue;
+                  states.set(login.toLowerCase(), review.state);
+                }
+                return states;
+              } catch (e) {
+                core.warning(
+                  `listReviews for #${number} failed (${e.status ?? "?"}): ${e.message}`
+                );
+                return null;
+              }
+            }
+
+            // Managers gate their own branch and nothing else, so approvals
+            // compose: an approval from the v1.2 manager alone clears v1.2 and
+            // leaves v1.3 blocked.
+            function decide(targets, author, states) {
+              const authorLogin = (author || "").toLowerCase();
+              const cleared = [];
+              const blocked = [];
+              for (const target of targets) {
+                // release-branches.yml is the authorization source, so a label
+                // naming a branch it does not list has nobody who could approve
+                // it. That differs from an entry that deliberately omits
+                // `manager`, and the difference is reachable: retiring a branch
+                // means dropping its entry while its label lives on.
+                if (!managers.has(target)) {
+                  blocked.push({ target, manager: "", state: "UNCONFIGURED" });
+                  continue;
+                }
+                const manager = managers.get(target);
+                if (!manager) {
+                  cleared.push({ target, note: "no release manager configured for this branch" });
+                  continue;
+                }
+                // GitHub does not let anyone approve their own PR, so a manager
+                // who wrote the fix counts as having signed off. Logins are
+                // case-insensitive while `manager` is typed by hand, so fold both.
+                if (manager.toLowerCase() === authorLogin) {
+                  cleared.push({ target, note: `@${manager} is the author of this PR` });
+                  continue;
+                }
+                const state = states ? states.get(manager.toLowerCase()) : "UNKNOWN";
+                if (state === "APPROVED") {
+                  cleared.push({ target, note: `approved by @${manager}` });
+                } else {
+                  blocked.push({ target, manager, state: state || "NONE" });
+                }
+              }
+              return { cleared, blocked };
+            }
+
+            // Say only what the state proves. A dismissal lands on DISMISSED
+            // whatever the review was — GitHub dismisses a blocking
+            // CHANGES_REQUESTED as readily as it clears a stale approval — so
+            // naming it an approval would put a guess in the manager's mouth.
+            function reason(e) {
+              if (e.state === "UNCONFIGURED") {
+                return "this branch is not listed in .github/release-branches.yml, " +
+                  "so no release manager governs it — drop the label, or add the " +
+                  "branch back to that file";
+              }
+              if (e.state === "DISMISSED") {
+                return `@${e.manager}'s review was dismissed, so no approval stands`;
+              }
+              if (e.state === "CHANGES_REQUESTED") {
+                return `@${e.manager} requested changes and has not approved since`;
+              }
+              if (e.state === "UNKNOWN") {
+                return `this PR's reviews could not be read, so @${e.manager}'s ` +
+                  `approval could not be confirmed`;
+              }
+              return `needs an approving review from @${e.manager}`;
+            }
+
+            let numbers;
+            try {
+              numbers = await pullRequestNumbers();
+            } catch (e) {
+              // Fail closed. Only reachable for a merge group whose commits
+              // cannot be mapped back to PRs, and a group whose approvals
+              // cannot be read is not a group this can vouch for — passing it
+              // would leave the queue ungated in exactly the window this job
+              // exists to cover. Ejecting the group is recoverable: its PRs
+              // re-queue, and each still holds its own passing check.
+              core.setFailed(
+                `Could not resolve the pull requests in this merge group ` +
+                `(${e.message}). Refusing to pass a check that could not be ` +
+                `computed.`
+              );
+              return;
+            }
+
+            const lines = [];
+            let failed = false;
+
+            for (const number of numbers) {
+              const { data: pr } = await github.rest.pulls.get({
+                owner, repo, pull_number: number,
+              });
+              // A PR already targeting a release branch is itself a backport and
+              // is not backported onward; `no-backport-needed` vetoes the lot,
+              // the same way it does in precheck and in the post-merge push.
+              const labels = (pr.labels || []).map((l) => l.name);
+              const targets =
+                pr.base.ref !== "main" || labels.includes("no-backport-needed")

Review Comment:
   This empties the target list under the veto, so the check passes — but nothing anywhere removes the `release/*` labels. `grep -rn removeLabel` over `.github/` returns nothing.
   
   So the PR merges still carrying a label that promises a backport, `direct-backport-push.yml:296-297` skips it, and the label stands as a false record — which is the exact artifact this PR exists to eliminate.
   
   `precheck.yml:330-331` makes it reachable by design: it documents adding `no-backport-needed` mid-review as the supported way to cancel, and by then the auto-labeler has already applied the labels. Removing them alongside the veto would close it.



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ci: block the merge until each release/* label has its manager's approval [texera]

Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on code in PR #8096:
URL: https://github.com/apache/texera/pull/8096#discussion_r3921600865


##########
.github/workflows/backport-approval-check.yml:
##########
@@ -0,0 +1,296 @@
+# 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.
+
+# Blocks the merge while a `release/*` label on the PR has not been approved by
+# that branch's release manager (.github/release-branches.yml).
+#
+# The point is that a merged PR's labels should be a truthful record. A label
+# only nominates a branch, so before this check a manager declined a backport by
+# staying silent — and the label stayed on, which read afterwards as "this
+# shipped in 1.2" when it had not. Here declining is an action: the manager
+# either approves, or removes their label. Since the merge waits for every
+# remaining label to be approved, the labels on a merged PR are exactly the
+# branches Direct Backport Push then sends the fix to.
+#
+# The author's job is to ask the manager for that call, not to make it for them.
+# Editing labels needs triage access, so outside contributors and Renovate or
+# Dependabot PRs cannot remove a label themselves — the failure report says so
+# and names who to ask.
+#
+# `Backport Approvals` is listed in .asf.yaml's required_status_checks, so this
+# job must produce a result on EVERY pull request, or a PR that never runs it
+# waits forever. That is why it is not conditioned on the title, the labels, or
+# the base branch: it always runs and reports success when there is nothing to
+# approve. Merge groups are re-evaluated rather than waved through, because a
+# queued PR's own checks are no longer consulted once it is queued; a group
+# whose PRs cannot be resolved fails closed rather than passing unchecked. Do
+# not rename the job — its display name is the required context.
+
+name: Backport Approval Check
+
+on:
+  pull_request:
+    types:
+      - opened
+      - reopened
+      - synchronize
+      - labeled
+      - unlabeled
+      # Retargeting arrives as `edited`, and the verdict depends on the base
+      # branch: a backport PR into release/* has nothing to approve, the same
+      # PR moved onto main does.
+      - edited
+  pull_request_review:
+    types:
+      - submitted
+      - dismissed
+  merge_group:
+
+# Read-only: this job never writes to the PR, and `pull_request_review` runs
+# with the base repository's token even for fork PRs.
+permissions:
+  contents: read
+  pull-requests: read
+
+concurrency:
+  group: backport-approvals-${{ github.event.pull_request.number || github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  backport-approvals:
+    # Do not rename — this display name is the required status check context
+    # referenced in .asf.yaml.
+    name: Backport Approvals
+    runs-on: ubuntu-latest
+    steps:
+      # The PR's own head (or the queued group's), so the config is the one that
+      # will govern this change once it merges. Checking out the base would not
+      # be a security boundary anyway: on `pull_request` the workflow definition
+      # itself comes from the PR. What bounds this is the event — a fork gets a
+      # read-only token and no secrets, and nothing here writes to the PR.
+      - name: Checkout
+        uses: actions/checkout@v7
+        with:
+          ref: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }}
+          persist-credentials: false
+
+      - name: Read release branches
+        id: targets
+        run: |
+          entries=$(python3 .github/scripts/release_branches.py .github/release-branches.yml)
+          echo "entries=${entries}" >> "$GITHUB_OUTPUT"
+          echo "Release branch targets: ${entries}"
+
+      - name: Check release manager approvals
+        uses: actions/github-script@v9
+        env:
+          ENTRIES: ${{ steps.targets.outputs.entries }}
+        with:
+          script: |
+            const { owner, repo } = context.repo;
+            const managers = new Map(
+              JSON.parse(process.env.ENTRIES || "[]").map((e) => [
+                e.branch,
+                e.manager || "",
+              ])
+            );
+
+            // A merge group carries several PRs and its commits are the squash
+            // merges, so the number is parsed out of each subject — the same way
+            // precheck.yml resolves them.
+            async function pullRequestNumbers() {
+              if (context.eventName !== "merge_group") {
+                return [context.payload.pull_request.number];
+              }
+              const mg = context.payload.merge_group;
+              const { data: comparison } = await github.rest.repos.compareCommits({
+                owner, repo, base: mg.base_sha, head: mg.head_sha,
+              });
+              return comparison.commits.map((c) => {
+                const m = c.commit.message.split("\n", 1)[0].match(/\(#(\d+)\)\s*$/);
+                if (!m) throw new Error(`no PR number in the message of ${c.sha}`);
+                return Number(m[1]);
+              });
+            }
+
+            // Latest review state per login. COMMENTED never changes an approval;
+            // a later CHANGES_REQUESTED or DISMISSED revokes one. listReviews is
+            // documented to return reviews chronologically, so the last state
+            // recorded for a login is the one that counts. `null` means the list
+            // could not be read at all — kept distinct from an empty list, since
+            // "we did not look" must never be reported as "nobody approved".
+            async function reviewStates(number) {
+              try {
+                const reviews = await github.paginate(github.rest.pulls.listReviews, {
+                  owner, repo, pull_number: number, per_page: 100,
+                });
+                const states = new Map();
+                for (const review of reviews) {
+                  const login = review.user?.login;
+                  if (!login || review.state === "COMMENTED") continue;
+                  states.set(login.toLowerCase(), review.state);
+                }
+                return states;
+              } catch (e) {
+                core.warning(
+                  `listReviews for #${number} failed (${e.status ?? "?"}): ${e.message}`
+                );
+                return null;
+              }
+            }
+
+            // Managers gate their own branch and nothing else, so approvals
+            // compose: an approval from the v1.2 manager alone clears v1.2 and
+            // leaves v1.3 blocked.
+            function decide(targets, author, states) {
+              const authorLogin = (author || "").toLowerCase();
+              const cleared = [];
+              const blocked = [];
+              for (const target of targets) {
+                // release-branches.yml is the authorization source, so a label
+                // naming a branch it does not list has nobody who could approve
+                // it. That differs from an entry that deliberately omits
+                // `manager`, and the difference is reachable: retiring a branch
+                // means dropping its entry while its label lives on.
+                if (!managers.has(target)) {
+                  blocked.push({ target, manager: "", state: "UNCONFIGURED" });
+                  continue;
+                }
+                const manager = managers.get(target);
+                if (!manager) {
+                  cleared.push({ target, note: "no release manager configured for this branch" });
+                  continue;
+                }
+                // GitHub does not let anyone approve their own PR, so a manager
+                // who wrote the fix counts as having signed off. Logins are
+                // case-insensitive while `manager` is typed by hand, so fold both.
+                if (manager.toLowerCase() === authorLogin) {
+                  cleared.push({ target, note: `@${manager} is the author of this PR` });
+                  continue;
+                }
+                const state = states ? states.get(manager.toLowerCase()) : "UNKNOWN";
+                if (state === "APPROVED") {
+                  cleared.push({ target, note: `approved by @${manager}` });
+                } else {
+                  blocked.push({ target, manager, state: state || "NONE" });
+                }
+              }
+              return { cleared, blocked };
+            }
+
+            // Say only what the state proves. A dismissal lands on DISMISSED
+            // whatever the review was — GitHub dismisses a blocking
+            // CHANGES_REQUESTED as readily as it clears a stale approval — so
+            // naming it an approval would put a guess in the manager's mouth.
+            function reason(e) {
+              if (e.state === "UNCONFIGURED") {
+                return "this branch is not listed in .github/release-branches.yml, " +
+                  "so no release manager governs it — drop the label, or add the " +
+                  "branch back to that file";
+              }
+              if (e.state === "DISMISSED") {
+                return `@${e.manager}'s review was dismissed, so no approval stands`;
+              }
+              if (e.state === "CHANGES_REQUESTED") {
+                return `@${e.manager} requested changes and has not approved since`;
+              }
+              if (e.state === "UNKNOWN") {
+                return `this PR's reviews could not be read, so @${e.manager}'s ` +
+                  `approval could not be confirmed`;
+              }
+              return `needs an approving review from @${e.manager}`;
+            }
+
+            let numbers;
+            try {
+              numbers = await pullRequestNumbers();
+            } catch (e) {
+              // Fail closed. Only reachable for a merge group whose commits
+              // cannot be mapped back to PRs, and a group whose approvals
+              // cannot be read is not a group this can vouch for — passing it
+              // would leave the queue ungated in exactly the window this job
+              // exists to cover. Ejecting the group is recoverable: its PRs
+              // re-queue, and each still holds its own passing check.
+              core.setFailed(
+                `Could not resolve the pull requests in this merge group ` +
+                `(${e.message}). Refusing to pass a check that could not be ` +
+                `computed.`
+              );
+              return;
+            }
+
+            const lines = [];
+            let failed = false;
+
+            for (const number of numbers) {
+              const { data: pr } = await github.rest.pulls.get({
+                owner, repo, pull_number: number,
+              });
+              // A PR already targeting a release branch is itself a backport and
+              // is not backported onward; `no-backport-needed` vetoes the lot,
+              // the same way it does in precheck and in the post-merge push.
+              const labels = (pr.labels || []).map((l) => l.name);
+              const targets =
+                pr.base.ref !== "main" || labels.includes("no-backport-needed")

Review Comment:
   Verified at `77d573c1a` — the contradiction is reported and it blocks: `intoMain && vetoed` maps every `release/*` label to a `VETOED` entry (`:264-269`), those land in `blocked` (`:281`), and `blocked.length > 0` sets `failed` (`:285`). A PR can no longer merge carrying both.
   
   On your question — keep it here, don't move it into `backport-auto-label.yml`. Auto-removing the label would make the veto silently rewrite the record this check exists to make truthful, and it would do so from the one workflow that runs `pull_request_target` with a write token, where an unattended label mutation is the most expensive kind of mistake. Reporting leaves the choice with the person who has the context for it, and either resolution clears the check. The residual is documentation, not code: `precheck.yml:327-331` still calls adding the veto mid-review the way to cancel a backport, which is now only half the action — raising that separately.



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ci: gate each backport on its release manager's approval [texera]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #8096:
URL: https://github.com/apache/texera/pull/8096#discussion_r3885934154


##########
.github/workflows/direct-backport-push.yml:
##########
@@ -270,15 +272,101 @@ jobs:
               ])
             );
 
+            // Whether a fix reaches a release branch is that branch's release
+            // manager's call, so a `release/*` label only *nominates* a target:
+            // the manager named in release-branches.yml must have approved the
+            // PR for anything to land on their branch.
+            //
+            // "Approved" is the manager's *latest* review state. COMMENTED
+            // reviews never change an approval, and a later CHANGES_REQUESTED
+            // or DISMISSED revokes an earlier one. Any dismissal lands on
+            // DISMISSED — a stale approval cleared by a push, or a blocking
+            // review dismissed by hand — so the state proves an approval is
+            // not standing, never what the dismissed review had been.
+            // listReviews returns reviews oldest-first (documented), so the
+            // last state recorded for a login is the one that counts.
+            async function managerReviewStates(pullRequest) {
+              const states = new Map();
+              try {
+                const reviews = await github.paginate(github.rest.pulls.listReviews, {
+                  owner,
+                  repo,
+                  pull_number: pullRequest.number,
+                  per_page: 100,
+                });
+                for (const review of reviews) {
+                  const login = review.user?.login;
+                  if (!login || review.state === "COMMENTED") continue;
+                  states.set(login.toLowerCase(), review.state);
+                }
+              } catch (e) {
+                // Without the review list we cannot prove an approval, and
+                // backporting unreviewed is the worse failure, so every gated
+                // target is held back. `null` (not an empty map) keeps that
+                // distinct from "read fine, nobody approved" — we must not
+                // report that a manager did not approve when we never looked.
+                core.warning(
+                  `listReviews for #${pullRequest.number} failed ` +
+                  `(${e.status ?? "?"}): ${e.message}. Treating every gated ` +
+                  `target as unapproved.`
+                );
+                return null;
+              }
+              return states;
+            }
+
+            // Split the labeled targets into the ones their release manager has
+            // signed off on and the ones still waiting. Managers gate their own
+            // branch and nothing else, so the approvals compose: with v1.2 and
+            // v1.3 both labeled, an approval from the v1.2 manager alone sends
+            // the fix to v1.2 and leaves v1.3 behind.
+            function splitByApproval(pullRequest, targets, states) {
+              const author = (pullRequest.user?.login || "").toLowerCase();
+              const approved = [];
+              const unapproved = [];
+              for (const target of targets) {
+                const manager = releaseManagers.get(target) || "";
+                if (!manager) {
+                  core.info(`${target}: no release manager configured; ungated.`);
+                  approved.push(target);

Review Comment:
   An unconfigured `release/*` label is currently treated the same as a configured target that intentionally omits `manager`, so it bypasses the new approval gate and can be pushed automatically. This also means a label left behind after an EOL branch is removed from `release-branches.yml` remains active, despite that file being the source of truth. Check `releaseManagers.has(target)` separately and reject/report unknown targets; only a present entry with an empty manager should be ungated.



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ci: block the merge until each release/* label has its manager's approval [texera]

Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on code in PR #8096:
URL: https://github.com/apache/texera/pull/8096#discussion_r3922324886


##########
.github/workflows/backport-approval-check.yml:
##########
@@ -0,0 +1,316 @@
+# 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.
+
+# Blocks the merge while a `release/*` label on the PR has not been approved by
+# that branch's release manager (.github/release-branches.yml).
+#
+# The point is that a merged PR's labels should be a truthful record. A label
+# only nominates a branch, so before this check a manager declined a backport by
+# staying silent — and the label stayed on, which read afterwards as "this
+# shipped in 1.2" when it had not. Here declining is an action: the manager
+# either approves, or removes their label. Since the merge waits for every
+# remaining label to be approved, the labels on a merged PR are exactly the
+# branches Direct Backport Push then sends the fix to.
+#
+# The author's job is to ask the manager for that call, not to make it for them.
+# Editing labels needs triage access, so outside contributors and Renovate or
+# Dependabot PRs cannot remove a label themselves — the failure report says so
+# and names who to ask.
+#
+# `Backport Approvals` is listed in .asf.yaml's required_status_checks, so this
+# job must produce a result on EVERY pull request, or a PR that never runs it
+# waits forever. That is why it is not conditioned on the title, the labels, or
+# the base branch: it always runs and reports success when there is nothing to
+# approve. Merge groups are re-evaluated rather than waved through, because a
+# queued PR's own checks are no longer consulted once it is queued; a group
+# whose PRs cannot be resolved fails closed rather than passing unchecked. Do
+# not rename the job — its display name is the required context.
+
+name: Backport Approval Check
+
+on:
+  pull_request:
+    types:
+      - opened
+      - reopened
+      - synchronize
+      - labeled
+      - unlabeled
+      # Retargeting arrives as `edited`, and the verdict depends on the base
+      # branch: a backport PR into release/* has nothing to approve, the same
+      # PR moved onto main does.
+      - edited
+  pull_request_review:
+    types:
+      - submitted
+      - dismissed
+  merge_group:
+
+# Read-only: this job never writes to the PR, and `pull_request_review` runs
+# with the base repository's token even for fork PRs.
+permissions:
+  contents: read
+  pull-requests: read
+
+concurrency:
+  group: backport-approvals-${{ github.event.pull_request.number || github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  backport-approvals:
+    # Do not rename — this display name is the required status check context
+    # referenced in .asf.yaml.
+    name: Backport Approvals
+    runs-on: ubuntu-latest
+    steps:
+      # The PR's own head (or the queued group's), so the config is the one that
+      # will govern this change once it merges. Checking out the base would not
+      # be a security boundary anyway: on `pull_request` the workflow definition
+      # itself comes from the PR. What bounds this is the event — a fork gets a
+      # read-only token and no secrets, and nothing here writes to the PR.
+      - name: Checkout
+        uses: actions/checkout@v7
+        with:
+          ref: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }}

Review Comment:
   Reopening the substance of this one, because my own suggestion was wrong: `base.sha` is not the current base tip. It is main's tip at the PR's **last synchronize**, so it is as stale as the head for any PR that has not been pushed to since #6941 landed on 2026-07-27.
   
   Measured on this repo — #6009 head 2026-07-11 / base 2026-07-10, #6436 head 2026-07-29 / base 2026-07-18, both `updated_at` today. Probing every open PR into `main`: **33 of 221 have a `base.sha` where `.github/scripts/release_branches.py` 404s**, so `:99` still exits 2 and the required check still goes red unclearably.
   
   It is not a prediction either — `backport-auto-label.yml:78` pins the same `base.sha` and has been failing this way in production for a month: run 31542186218 (2026-08-11) ends with `python3: can't open file '.../release_branches.py': [Errno 2]`, exit code 2. It survives only because that check is not required.
   
   Full trace and the fix I would take are on the new comment at line 93. Leaving this open as its parent.



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ci: block the merge until each release/* label has its manager's approval [texera]

Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on code in PR #8096:
URL: https://github.com/apache/texera/pull/8096#discussion_r3924205231


##########
.github/workflows/backport-approval-check.yml:
##########
@@ -0,0 +1,318 @@
+# 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.
+
+# Blocks the merge while a `release/*` label on the PR is not approved by that
+# branch's release manager (.github/release-branches.yml).
+#
+# A label only nominates a branch. Before this, a manager declined by staying
+# silent and the label stayed on, so a merged PR claimed a backport that never
+# happened. Declining is now an action — approve, or remove the label — and the
+# merge waits for every remaining label, so a merged PR's labels are the
+# branches it reached.
+#
+# `Backport Approvals` is a required check on the default branch (.asf.yaml), so
+# this must report on every PR into `main` or one that never runs it waits
+# forever: hence no condition on title, labels, or base. A PR into a release
+# branch is itself a backport and reports success. Merge groups are
+# re-evaluated rather than waved through, and one whose PRs cannot be resolved
+# fails closed. Do not rename the job — its name is the required context.
+
+name: Backport Approval Check
+
+on:
+  pull_request:
+    types:
+      - opened
+      - reopened
+      - synchronize
+      - labeled
+      - unlabeled
+      # Retargeting arrives as `edited`, and the verdict depends on the base
+      # branch: a backport PR into release/* has nothing to approve, the same
+      # PR moved onto main does.
+      - edited
+  pull_request_review:
+    types:
+      - submitted
+      - dismissed
+  merge_group:
+
+# Read-only: this job never writes to the PR, and `pull_request_review` runs
+# with the base repository's token even for fork PRs.
+permissions:
+  contents: read
+  pull-requests: read
+
+concurrency:
+  group: backport-approvals-${{ github.event.pull_request.number || github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  backport-approvals:
+    # Do not rename — this display name is the required status check context
+    # referenced in .asf.yaml.
+    name: Backport Approvals
+    runs-on: ubuntu-latest
+    steps:
+      # The default branch, not the PR's head or base. Neither predates #6941,
+      # which added release-branches.yml — and `base.sha` is main's tip at the
+      # PR's last synchronize rather than now, stale for 33 of the open PRs into
+      # main. Either would fail the step below with a file-not-found and turn
+      # this required check red unclearably; backport-auto-label.yml pinned
+      # `base.sha` and failed that way 20 times in production. Reading main also
+      # lets a PR retargeted onto a release branch, where the config is absent,
+      # reach the report instead of dying before it.
+      #
+      # Direct Backport Push reads main too, so both consumers judge a backport
+      # by the same config. A PR editing that config is judged by the pre-edit
+      # copy; those are `ci:`-typed and carry no `release/*` labels.

Review Comment:
   Two sentences here stopped being true this round, both from this PR's own commits.
   
   "Neither predates #6941" binds to "the PR's head or base" — the pair "Either" binds to three lines down — so as written it denies the hazard it exists to explain. The earlier wording named its subject.
   
   "Both consumers" was right while the labeler was the third, unfixed one. `875812cac` made it three, so the comment now tells the next reader the labeler does *not* share the config revision — the property you just established.
   
   ```suggestion
         # The default branch, not the PR's head or base. Both can predate #6941,
         # which added release-branches.yml — and `base.sha` is main's tip at the
         # PR's last synchronize rather than now, stale for 33 of the open PRs into
         # main. Either would fail the step below with a file-not-found and turn
         # this required check red unclearably; backport-auto-label.yml pinned
         # `base.sha` and failed that way 20 times in production. Reading main also
         # lets a PR retargeted onto a release branch, where the config is absent,
         # reach the report instead of dying before it.
         #
         # Backport Auto Label and Direct Backport Push read main too, so all three
         # consumers judge a backport by the same config. A PR editing that config
         # is judged by the pre-edit copy; those are `ci:`-typed and carry no
         # `release/*` labels.
   ```



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ci: block the merge until each release/* label has its manager's approval [texera]

Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on PR #8096:
URL: https://github.com/apache/texera/pull/8096#issuecomment-5542824615

   can we also only dispatch backport approval check job only if we have at least 1 release backport label? could be a follow up.


-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ci: block the merge until each release/* label has its manager's approval [texera]

Posted by "mengw15 (via GitHub)" <gi...@apache.org>.
mengw15 commented on code in PR #8096:
URL: https://github.com/apache/texera/pull/8096#discussion_r3894515908


##########
.github/workflows/backport-approval-check.yml:
##########
@@ -0,0 +1,292 @@
+# 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.
+
+# Blocks the merge while a `release/*` label on the PR has not been approved by
+# that branch's release manager (.github/release-branches.yml).
+#
+# The point is that a merged PR's labels should be a truthful record. A label
+# only nominates a branch, so before this check a manager declined a backport by
+# staying silent — and the label stayed on, which read afterwards as "this
+# shipped in 1.2" when it had not. Here declining is an action: the manager
+# either approves, or removes their label. Since the merge waits for every
+# remaining label to be approved, the labels on a merged PR are exactly the
+# branches Direct Backport Push then sends the fix to.
+#
+# The author's job is to ask the manager for that call, not to make it for them.
+# Editing labels needs triage access, so outside contributors and Renovate or
+# Dependabot PRs cannot remove a label themselves — the failure report says so
+# and names who to ask.
+#
+# `Backport Approvals` is listed in .asf.yaml's required_status_checks, so this
+# job must produce a result on EVERY pull request, or a PR that never runs it
+# waits forever. That is why it is not conditioned on the title, the labels, or
+# the base branch: it always runs and reports success when there is nothing to
+# approve. Merge groups are re-evaluated rather than waved through, because a
+# queued PR's own checks are no longer consulted. Do not rename the job — its
+# display name is the required context.
+
+name: Backport Approval Check
+
+on:
+  pull_request:
+    types:
+      - opened
+      - reopened
+      - synchronize
+      - labeled
+      - unlabeled
+      # Retargeting arrives as `edited`, and the verdict depends on the base
+      # branch: a backport PR into release/* has nothing to approve, the same
+      # PR moved onto main does.
+      - edited
+  pull_request_review:
+    types:
+      - submitted
+      - dismissed
+  merge_group:
+
+# Read-only: this job never writes to the PR, and `pull_request_review` runs
+# with the base repository's token even for fork PRs.
+permissions:
+  contents: read
+  pull-requests: read
+
+concurrency:
+  group: backport-approvals-${{ github.event.pull_request.number || github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  backport-approvals:
+    # Do not rename — this display name is the required status check context
+    # referenced in .asf.yaml.
+    name: Backport Approvals
+    runs-on: ubuntu-latest
+    steps:
+      # The PR's own head (or the queued group's), so the config is the one that
+      # will govern this change once it merges. Checking out the base would not
+      # be a security boundary anyway: on `pull_request` the workflow definition
+      # itself comes from the PR. What bounds this is the event — a fork gets a
+      # read-only token and no secrets, and nothing here writes to the PR.
+      - name: Checkout
+        uses: actions/checkout@v7
+        with:
+          ref: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }}
+          persist-credentials: false
+
+      - name: Read release branches
+        id: targets
+        run: |
+          entries=$(python3 .github/scripts/release_branches.py .github/release-branches.yml)
+          echo "entries=${entries}" >> "$GITHUB_OUTPUT"
+          echo "Release branch targets: ${entries}"
+
+      - name: Check release manager approvals
+        uses: actions/github-script@v9
+        env:
+          ENTRIES: ${{ steps.targets.outputs.entries }}
+        with:
+          script: |
+            const { owner, repo } = context.repo;
+            const managers = new Map(
+              JSON.parse(process.env.ENTRIES || "[]").map((e) => [
+                e.branch,
+                e.manager || "",
+              ])
+            );
+
+            // A merge group carries several PRs and its commits are the squash
+            // merges, so the number is parsed out of each subject — the same way
+            // precheck.yml resolves them.
+            async function pullRequestNumbers() {
+              if (context.eventName !== "merge_group") {
+                return [context.payload.pull_request.number];
+              }
+              const mg = context.payload.merge_group;
+              const { data: comparison } = await github.rest.repos.compareCommits({
+                owner, repo, base: mg.base_sha, head: mg.head_sha,
+              });
+              return comparison.commits.map((c) => {
+                const m = c.commit.message.split("\n", 1)[0].match(/\(#(\d+)\)\s*$/);
+                if (!m) throw new Error(`no PR number in the message of ${c.sha}`);
+                return Number(m[1]);
+              });
+            }
+
+            // Latest review state per login. COMMENTED never changes an approval;
+            // a later CHANGES_REQUESTED or DISMISSED revokes one. listReviews is
+            // documented to return reviews chronologically, so the last state
+            // recorded for a login is the one that counts. `null` means the list
+            // could not be read at all — kept distinct from an empty list, since
+            // "we did not look" must never be reported as "nobody approved".
+            async function reviewStates(number) {
+              try {
+                const reviews = await github.paginate(github.rest.pulls.listReviews, {
+                  owner, repo, pull_number: number, per_page: 100,
+                });
+                const states = new Map();
+                for (const review of reviews) {
+                  const login = review.user?.login;
+                  if (!login || review.state === "COMMENTED") continue;
+                  states.set(login.toLowerCase(), review.state);
+                }
+                return states;
+              } catch (e) {
+                core.warning(
+                  `listReviews for #${number} failed (${e.status ?? "?"}): ${e.message}`
+                );
+                return null;
+              }
+            }
+
+            // Managers gate their own branch and nothing else, so approvals
+            // compose: an approval from the v1.2 manager alone clears v1.2 and
+            // leaves v1.3 blocked.
+            function decide(targets, author, states) {
+              const authorLogin = (author || "").toLowerCase();
+              const cleared = [];
+              const blocked = [];
+              for (const target of targets) {
+                // release-branches.yml is the authorization source, so a label
+                // naming a branch it does not list has nobody who could approve
+                // it. That differs from an entry that deliberately omits
+                // `manager`, and the difference is reachable: retiring a branch
+                // means dropping its entry while its label lives on.
+                if (!managers.has(target)) {
+                  blocked.push({ target, manager: "", state: "UNCONFIGURED" });
+                  continue;
+                }
+                const manager = managers.get(target);
+                if (!manager) {
+                  cleared.push({ target, note: "no release manager configured for this branch" });
+                  continue;
+                }
+                // GitHub does not let anyone approve their own PR, so a manager
+                // who wrote the fix counts as having signed off. Logins are
+                // case-insensitive while `manager` is typed by hand, so fold both.
+                if (manager.toLowerCase() === authorLogin) {
+                  cleared.push({ target, note: `@${manager} is the author of this PR` });
+                  continue;
+                }
+                const state = states ? states.get(manager.toLowerCase()) : "UNKNOWN";
+                if (state === "APPROVED") {
+                  cleared.push({ target, note: `approved by @${manager}` });
+                } else {
+                  blocked.push({ target, manager, state: state || "NONE" });
+                }
+              }
+              return { cleared, blocked };
+            }
+
+            // Say only what the state proves. A dismissal lands on DISMISSED
+            // whatever the review was — GitHub dismisses a blocking
+            // CHANGES_REQUESTED as readily as it clears a stale approval — so
+            // naming it an approval would put a guess in the manager's mouth.
+            function reason(e) {
+              if (e.state === "UNCONFIGURED") {
+                return "this branch is not listed in .github/release-branches.yml, " +
+                  "so no release manager governs it — drop the label, or add the " +
+                  "branch back to that file";
+              }
+              if (e.state === "DISMISSED") {
+                return `@${e.manager}'s review was dismissed, so no approval stands`;
+              }
+              if (e.state === "CHANGES_REQUESTED") {
+                return `@${e.manager} requested changes and has not approved since`;
+              }
+              if (e.state === "UNKNOWN") {
+                return `this PR's reviews could not be read, so @${e.manager}'s ` +
+                  `approval could not be confirmed`;
+              }
+              return `needs an approving review from @${e.manager}`;
+            }
+
+            let numbers;
+            try {
+              numbers = await pullRequestNumbers();
+            } catch (e) {
+              // Only reachable for a merge group whose commits cannot be mapped
+              // back to PRs. Each was checked individually before queueing, so
+              // ejecting the queue over an infrastructure hiccup would cost more
+              // than the narrow window it would close.
+              core.warning(
+                `Could not resolve the pull requests in this merge group ` +
+                `(${e.message}); they were checked individually before queueing.`
+              );
+              return;

Review Comment:
   Agreed, and the asymmetry makes it clearer: `precheck.yml` parses the same subjects and degrades by running *more* builds, while this degraded by skipping the gate entirely — an authorization check that no-ops on error is not one. Fixed in `57a6fcdd8`: resolution failure now `core.setFailed`s. Ejecting a group is recoverable, since its PRs re-queue and each still holds its own passing check.



##########
.github/workflows/backport-approval-check.yml:
##########
@@ -0,0 +1,292 @@
+# 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.
+
+# Blocks the merge while a `release/*` label on the PR has not been approved by
+# that branch's release manager (.github/release-branches.yml).
+#
+# The point is that a merged PR's labels should be a truthful record. A label
+# only nominates a branch, so before this check a manager declined a backport by
+# staying silent — and the label stayed on, which read afterwards as "this
+# shipped in 1.2" when it had not. Here declining is an action: the manager
+# either approves, or removes their label. Since the merge waits for every
+# remaining label to be approved, the labels on a merged PR are exactly the
+# branches Direct Backport Push then sends the fix to.
+#
+# The author's job is to ask the manager for that call, not to make it for them.
+# Editing labels needs triage access, so outside contributors and Renovate or
+# Dependabot PRs cannot remove a label themselves — the failure report says so
+# and names who to ask.
+#
+# `Backport Approvals` is listed in .asf.yaml's required_status_checks, so this
+# job must produce a result on EVERY pull request, or a PR that never runs it
+# waits forever. That is why it is not conditioned on the title, the labels, or
+# the base branch: it always runs and reports success when there is nothing to
+# approve. Merge groups are re-evaluated rather than waved through, because a
+# queued PR's own checks are no longer consulted. Do not rename the job — its
+# display name is the required context.
+
+name: Backport Approval Check
+
+on:
+  pull_request:
+    types:
+      - opened
+      - reopened
+      - synchronize
+      - labeled
+      - unlabeled
+      # Retargeting arrives as `edited`, and the verdict depends on the base
+      # branch: a backport PR into release/* has nothing to approve, the same
+      # PR moved onto main does.
+      - edited
+  pull_request_review:
+    types:
+      - submitted
+      - dismissed
+  merge_group:
+
+# Read-only: this job never writes to the PR, and `pull_request_review` runs
+# with the base repository's token even for fork PRs.
+permissions:
+  contents: read
+  pull-requests: read
+
+concurrency:
+  group: backport-approvals-${{ github.event.pull_request.number || github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  backport-approvals:
+    # Do not rename — this display name is the required status check context
+    # referenced in .asf.yaml.
+    name: Backport Approvals
+    runs-on: ubuntu-latest
+    steps:
+      # The PR's own head (or the queued group's), so the config is the one that
+      # will govern this change once it merges. Checking out the base would not
+      # be a security boundary anyway: on `pull_request` the workflow definition
+      # itself comes from the PR. What bounds this is the event — a fork gets a
+      # read-only token and no secrets, and nothing here writes to the PR.
+      - name: Checkout
+        uses: actions/checkout@v7
+        with:
+          ref: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }}
+          persist-credentials: false
+
+      - name: Read release branches
+        id: targets
+        run: |
+          entries=$(python3 .github/scripts/release_branches.py .github/release-branches.yml)
+          echo "entries=${entries}" >> "$GITHUB_OUTPUT"
+          echo "Release branch targets: ${entries}"
+
+      - name: Check release manager approvals
+        uses: actions/github-script@v9
+        env:
+          ENTRIES: ${{ steps.targets.outputs.entries }}
+        with:
+          script: |
+            const { owner, repo } = context.repo;
+            const managers = new Map(
+              JSON.parse(process.env.ENTRIES || "[]").map((e) => [
+                e.branch,
+                e.manager || "",
+              ])
+            );
+
+            // A merge group carries several PRs and its commits are the squash
+            // merges, so the number is parsed out of each subject — the same way
+            // precheck.yml resolves them.
+            async function pullRequestNumbers() {
+              if (context.eventName !== "merge_group") {
+                return [context.payload.pull_request.number];
+              }
+              const mg = context.payload.merge_group;
+              const { data: comparison } = await github.rest.repos.compareCommits({
+                owner, repo, base: mg.base_sha, head: mg.head_sha,
+              });
+              return comparison.commits.map((c) => {
+                const m = c.commit.message.split("\n", 1)[0].match(/\(#(\d+)\)\s*$/);
+                if (!m) throw new Error(`no PR number in the message of ${c.sha}`);
+                return Number(m[1]);
+              });

Review Comment:
   The brittleness is fair, but both alternatives are weaker here. The `merge_group` payload's `head_ref` (`gh-readonly-queue/main/pr-N-<sha>`) names only one PR of a multi-PR group, and `GET /commits/{sha}/pulls` is the association index that `direct-backport-push.yml` already documents as lagging for tens of seconds after a merge — worse for commits this new. The subject format is enforced by `.asf.yaml`'s squash + `PR_TITLE_AND_DESC`, and both `precheck.yml` and `direct-backport-push.yml` already rely on it, so deviating would introduce a third, less reliable convention. I did take the second half: an unresolved association is now a hard block rather than an ignorable condition.



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ci: block the merge until each release/* label has its manager's approval [texera]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #8096:
URL: https://github.com/apache/texera/pull/8096#discussion_r3892705393


##########
.github/workflows/backport-approval-check.yml:
##########
@@ -0,0 +1,195 @@
+# 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.
+
+# Blocks the merge while a `release/*` label on the PR has not been approved by
+# that branch's release manager (.github/release-branches.yml).
+#
+# The point is not extra ceremony, it is that a merged PR's labels should be a
+# truthful record. A label only nominates a branch, so before this check a
+# manager declined a backport by staying silent — and the label stayed on, which
+# read afterwards as "this shipped in 1.2" when it had not. Here a decline is an
+# action: the manager either approves, or removes their label. Since the merge
+# waits for every remaining label to be approved, the label set on a merged PR
+# equals the set of branches it was backported to, by construction.
+#
+# The author's job is to ask the manager for that call, not to make it for them.
+# Editing labels needs triage access, so outside contributors and Renovate or
+# Dependabot PRs cannot remove a label themselves — the failure report says so
+# and names who to ask.
+#
+# `Backport Approvals` is listed in .asf.yaml's required_status_checks, so this
+# job must produce a result on EVERY pull request, or a PR that never runs it
+# waits forever. That is why it is not conditioned on the title, the labels, or
+# the base branch: it always runs and reports success when there is nothing to
+# approve, and merge groups pass straight through (the PRs in them were already
+# checked). Do not rename the job — its display name is the required context.
+#
+# The decision itself lives in .github/scripts/backport-gate.js, shared with
+# Direct Backport Push so the pre-merge and post-merge answers cannot drift, and
+# covered by .github/scripts/test_backport_gate.sh.
+
+name: Backport Approval Check
+
+on:
+  pull_request:
+    types:
+      - opened
+      - reopened
+      - synchronize
+      - labeled
+      - unlabeled
+  pull_request_review:
+    types:
+      - submitted
+      - dismissed
+  merge_group:
+
+# Read-only: this job never writes to the PR, and `pull_request_review` runs
+# with the base repository's token even for fork PRs.
+permissions:
+  contents: read
+  pull-requests: read
+
+concurrency:
+  group: backport-approvals-${{ github.event.pull_request.number || github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  backport-approvals:
+    # Do not rename — this display name is the required status check context
+    # referenced in .asf.yaml.
+    name: Backport Approvals
+    runs-on: ubuntu-latest
+    steps:
+      - name: Skip for merge groups
+        if: ${{ github.event_name == 'merge_group' }}
+        run: |
+          echo "Backport approvals are checked on the pull requests themselves,"
+          echo "before they enter the merge queue."

Review Comment:
   This unconditional success leaves the exact race that the post-merge recheck is intended to catch. If a manager's approval is dismissed after the PR check goes green but while the PR is in the queue, this job still publishes a successful required context for the merge group; the PR can merge with the label intact, then `direct-backport-push.yml:275-279` skips that target. The merged label therefore no longer identifies a branch that received the backport, contrary to this PR's core guarantee. Resolve the PRs in the merge group and evaluate their current labels/reviews before allowing the group to merge.



##########
.github/workflows/backport-approval-check.yml:
##########
@@ -0,0 +1,195 @@
+# 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.
+
+# Blocks the merge while a `release/*` label on the PR has not been approved by
+# that branch's release manager (.github/release-branches.yml).
+#
+# The point is not extra ceremony, it is that a merged PR's labels should be a
+# truthful record. A label only nominates a branch, so before this check a
+# manager declined a backport by staying silent — and the label stayed on, which
+# read afterwards as "this shipped in 1.2" when it had not. Here a decline is an
+# action: the manager either approves, or removes their label. Since the merge
+# waits for every remaining label to be approved, the label set on a merged PR
+# equals the set of branches it was backported to, by construction.
+#
+# The author's job is to ask the manager for that call, not to make it for them.
+# Editing labels needs triage access, so outside contributors and Renovate or
+# Dependabot PRs cannot remove a label themselves — the failure report says so
+# and names who to ask.
+#
+# `Backport Approvals` is listed in .asf.yaml's required_status_checks, so this
+# job must produce a result on EVERY pull request, or a PR that never runs it
+# waits forever. That is why it is not conditioned on the title, the labels, or
+# the base branch: it always runs and reports success when there is nothing to
+# approve, and merge groups pass straight through (the PRs in them were already
+# checked). Do not rename the job — its display name is the required context.
+#
+# The decision itself lives in .github/scripts/backport-gate.js, shared with
+# Direct Backport Push so the pre-merge and post-merge answers cannot drift, and
+# covered by .github/scripts/test_backport_gate.sh.
+
+name: Backport Approval Check
+
+on:
+  pull_request:
+    types:
+      - opened
+      - reopened
+      - synchronize

Review Comment:
   Changing a PR's base branch emits an `edited` action, but this workflow does not subscribe to it even though the decision depends on `pr.base.ref`. A PR moved between a release branch and `main` without a new commit will not recompute this required check, potentially retaining a success calculated while approvals were not required or waiting forever for a check on the new merge state. Add `edited` to the activity types.



##########
.github/scripts/backport-gate.js:
##########
@@ -0,0 +1,221 @@
+// 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.
+
+// Decides which `release/*` labels on a pull request are cleared to backport.
+//
+// A label only nominates a branch; the release manager configured for it in
+// .github/release-branches.yml has to have approved the PR for the fix to land
+// there. Two workflows ask that same question and must never drift apart, so
+// the rule lives here rather than inline in either of them:
+//
+//   - Backport Approvals (.github/workflows/backport-approval-check.yml) asks
+//     it before the merge and is a required check, so a PR cannot merge while
+//     one of its labels is unapproved. That is what makes the label set on a
+//     merged PR equal to the set of branches it was backported to: declining a
+//     backport is removing the label, not staying silent.
+//   - Direct Backport Push (.github/workflows/direct-backport-push.yml) asks it
+//     again after the merge, immediately before pushing, and pushes only what
+//     is cleared. The pre-merge check cannot cover an approval dismissed in the
+//     window between it going green and the merge landing.
+//
+// Usage (JSON on stdin):
+//   backport-gate.js            -> decision as JSON on stdout, always exit 0
+//   backport-gate.js --report   -> human-readable report, exit 1 if any target
+//                                  is held back (this is the required check)
+//
+// Input:
+//   {
+//     "entries":  [{"branch": "release/v1.2", "manager": "xuang7", ...}],
+//     "targets":  ["release/v1.2", "release/v1.3"],
+//     "author":   "some-contributor",
+//     "reviews":  [{"user": {"login": "xuang7"}, "state": "APPROVED"}] | null,
+//   }
+//
+// `reviews` is the PR's review list oldest-first, exactly as the REST API
+// returns it. `null` means the list could not be read at all, which is kept
+// distinct from an empty list: "we did not look" must never be reported as
+// "nobody approved".
+
+"use strict";
+
+// A dismissal lands on DISMISSED whatever the review was — a stale approval
+// cleared by a push, or a blocking review dismissed by hand — so the state
+// proves an approval is not standing, never what the dismissed review had been.
+const HOLD_REASONS = {
+  UNCONFIGURED: (e) =>
+    `\`${e.target}\` is not listed in .github/release-branches.yml, so no ` +
+    `release manager governs it — drop the label, or add the branch back to ` +
+    `that file`,
+  DISMISSED: (e) =>
+    `@${e.manager}'s review was dismissed, so no approval stands`,
+  CHANGES_REQUESTED: (e) =>
+    `@${e.manager} requested changes and has not approved since`,
+  UNKNOWN: (e) =>
+    `this PR's reviews could not be read, so @${e.manager}'s approval could ` +
+    `not be confirmed`,
+  NONE: (e) => `needs an approving review from @${e.manager}`,
+};
+
+function holdReason(entry) {
+  const render = HOLD_REASONS[entry.state] || HOLD_REASONS.NONE;
+  return render(entry);
+}
+
+// Latest review state per login. COMMENTED reviews never change an approval,
+// and a later CHANGES_REQUESTED or DISMISSED revokes an earlier one. The REST
+// API documents that reviews come back in chronological order, so the last
+// state recorded for a login is the one that counts. `null` in, `null` out —
+// see the note on `reviews` above.
+function reviewStates(reviews) {
+  if (reviews === null || reviews === undefined) return null;
+  const states = new Map();
+  for (const review of reviews) {
+    const login = review && review.user && review.user.login;
+    if (!login || review.state === "COMMENTED") continue;
+    states.set(login.toLowerCase(), review.state);
+  }
+  return states;
+}
+
+function managerIndex(entries) {
+  return new Map(
+    (entries || []).map((entry) => [entry.branch, entry.manager || ""])
+  );
+}
+
+// Split the labeled targets into the ones their release manager has signed off
+// on and the ones still held back. Managers gate their own branch and nothing
+// else, so approvals compose: with v1.2 and v1.3 both labeled, an approval from
+// the v1.2 manager alone clears v1.2 and leaves v1.3 held back.
+// Every held-back target carries the sentence explaining it, so that the
+// required check and the post-merge skip comment quote the same words instead
+// of each re-deriving them from the state.
+function held(entry) {
+  return { ...entry, reason: holdReason(entry) };
+}
+
+function splitByApproval({ entries, targets, author, reviews }) {
+  const managers = managerIndex(entries);
+  const states = reviewStates(reviews);
+  const authorLogin = (author || "").toLowerCase();
+  const approved = [];
+  const unapproved = [];
+
+  for (const target of targets || []) {
+    // release-branches.yml is the authorization source, so a label naming a
+    // branch it does not list has nobody who could approve the backport. That
+    // is not the same as an entry that deliberately omits `manager`, and the
+    // difference is reachable: retiring a branch means dropping its entry
+    // entirely while its `release/*` label lives on.
+    if (!managers.has(target)) {
+      unapproved.push(held({ target, manager: "", state: "UNCONFIGURED" }));
+      continue;
+    }
+    const manager = managers.get(target);
+    if (!manager) {
+      approved.push({ target, manager: "", state: "UNGATED" });
+      continue;
+    }
+    // GitHub does not let anyone approve their own PR, so a manager who wrote
+    // the fix counts as having signed off on it. Logins are case-insensitive
+    // while `manager` is typed by hand into the config, so fold both.
+    if (manager.toLowerCase() === authorLogin) {
+      approved.push({ target, manager, state: "AUTHORED" });
+      continue;
+    }
+    const state = states ? states.get(manager.toLowerCase()) : "UNKNOWN";
+    if (state === "APPROVED") {
+      approved.push({ target, manager, state: "APPROVED" });
+    } else {
+      unapproved.push(held({ target, manager, state: state || "NONE" }));
+    }
+  }
+
+  return { approved, unapproved, ok: unapproved.length === 0 };
+}
+
+// What the required check prints. It is the whole explanation an author gets,
+// and the author may be an outside contributor or a bot that cannot edit
+// labels at all (that needs triage access), so it has to name both ways out
+// and say who to ask when neither is available to them.
+function renderReport(decision, targets) {
+  const lines = [];
+  if (!targets || targets.length === 0) {
+    lines.push("No `release/*` labels on this PR — nothing to approve.");
+    return lines.join("\n");
+  }
+
+  const approvedNote = {
+    APPROVED: (e) => `approved by @${e.manager}`,
+    AUTHORED: (e) => `@${e.manager} is the author of this PR`,
+    UNGATED: () => "no release manager configured for this branch",
+  };
+  for (const entry of decision.approved) {
+    const note = (approvedNote[entry.state] || approvedNote.UNGATED)(entry);
+    lines.push(`  OK    ${entry.target} — ${note}`);
+  }
+  for (const entry of decision.unapproved) {
+    lines.push(`  BLOCK ${entry.target} — ${entry.reason}`);
+  }
+
+  if (decision.ok) {
+    lines.unshift(
+      `All ${decision.approved.length} backport target(s) approved.`,
+      ""
+    );
+    return lines.join("\n");
+  }
+
+  lines.unshift(
+    `${decision.unapproved.length} of ${targets.length} backport target(s) ` +
+      `not approved.`,
+    ""
+  );
+  lines.push(
+    "",
+    "Every `release/*` label on this PR must be approved by that branch's",
+    "release manager before it can merge, so that the labels on a merged PR",
+    "are exactly the branches it was backported to.",
+    "",
+    "Each BLOCK above is the named manager's call, and either answer clears it:",
+    "  - approve this PR, to send the fix to their branch; or",
+    "  - remove the label, to decline the backport to their branch.",

Review Comment:
   The `UNCONFIGURED` case has no named manager, yet this footer says every blocked target is a named manager's call and can be cleared by approval. That contradicts the target-specific message above, where the only resolutions are removing the label or restoring the config entry. Limit this guidance to blocks that actually name a manager.



##########
.github/scripts/test_backport_gate.sh:
##########
@@ -0,0 +1,190 @@
+#!/usr/bin/env 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.
+
+# Regression tests for backport-gate.js -- the rule deciding which release/*
+# labels are cleared to backport. It is an authorization check consulted both
+# before the merge (the required Backport Approvals check) and after it (Direct
+# Backport Push), so a silent change of behaviour here would either block every
+# merge or let an unapproved fix onto a release branch.
+#
+# Discovered and run automatically by the `infra` job in build.yml, which
+# executes every .github/scripts/test_*.sh -- no workflow edit needed.
+
+set -uo pipefail
+
+command -v node >/dev/null || { echo "node is required to run these tests" >&2; exit 1; }
+
+script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+gate="$script_dir/backport-gate.js"
+rc=0
+
+pass()   { echo "ok:   $1"; }
+failed() { echo "FAIL: $1"; rc=1; }
+
+# Two active branches with distinct managers, plus the retired v1.0 that is
+# deliberately absent so "label with no config entry" stays covered.
+entries='[{"branch":"release/v1.2","manager":"xuang7","active":true},
+          {"branch":"release/v1.3","manager":"mengw15","active":true},
+          {"branch":"release/v1.1","manager":"","active":false}]'
+
+# Runs the gate and flattens its decision to "ok|approved|held" so a case reads
+# as one comparable line. Held targets carry the state that explains them,
+# which is what the report turns into prose.
+decide() {
+  node "$gate" 2>/dev/null | node -e '
+    let s = "";
+    process.stdin.on("data", (d) => (s += d)).on("end", () => {
+      const d = JSON.parse(s);
+      const approved = d.approved.map((e) => e.target).join(",");
+      const held = d.unapproved.map((e) => `${e.target}:${e.state}`).join(",");
+      process.stdout.write(`${d.ok ? "ok" : "blocked"}|${approved}|${held}`);
+    });'
+}
+
+check() { # <description> <input-json> <expected>
+  local desc="$1" input="$2" want="$3" got
+  got="$(printf '%s' "$input" | decide)"
+  if [[ "$got" == "$want" ]]; then pass "$desc"; else
+    failed "$desc"
+    echo "        want: $want"
+    echo "        got:  $got"
+  fi
+}
+
+review() { printf '{"user":{"login":"%s"},"state":"%s"}' "$1" "$2"; }
+
+input() { # <author> <targets-json> <reviews-json-or-null>
+  printf '{"entries":%s,"author":"%s","targets":%s,"reviews":%s}' \
+    "$entries" "$1" "$2" "$3"
+}
+
+both='["release/v1.2","release/v1.3"]'
+
+# --- the three outcomes the flow is built around -----------------------------
+check "both managers approve -> both cleared" \
+  "$(input contributor "$both" "[$(review xuang7 APPROVED),$(review mengw15 APPROVED)]")" \
+  "ok|release/v1.2,release/v1.3|"
+
+check "only the v1.3 manager approves -> v1.3 only" \
+  "$(input contributor "$both" "[$(review mengw15 APPROVED)]")" \
+  "blocked|release/v1.3|release/v1.2:NONE"
+
+check "neither approves -> nothing cleared" \
+  "$(input contributor "$both" '[]')" \
+  "blocked||release/v1.2:NONE,release/v1.3:NONE"
+
+# --- how an approval is won, kept and lost -----------------------------------
+check "a later CHANGES_REQUESTED revokes an approval" \
+  "$(input contributor '["release/v1.2"]' "[$(review xuang7 APPROVED),$(review xuang7 CHANGES_REQUESTED)]")" \
+  "blocked||release/v1.2:CHANGES_REQUESTED"
+
+check "a dismissal revokes an approval" \
+  "$(input contributor '["release/v1.2"]' "[$(review xuang7 APPROVED),$(review xuang7 DISMISSED)]")" \
+  "blocked||release/v1.2:DISMISSED"
+
+check "a later COMMENTED review keeps the approval" \
+  "$(input contributor '["release/v1.2"]' "[$(review xuang7 APPROVED),$(review xuang7 COMMENTED)]")" \
+  "ok|release/v1.2|"
+
+check "re-approving after changes requested restores it" \
+  "$(input contributor '["release/v1.2"]' "[$(review xuang7 CHANGES_REQUESTED),$(review xuang7 APPROVED)]")" \
+  "ok|release/v1.2|"
+
+check "someone else's approval does not count" \
+  "$(input contributor '["release/v1.2"]' "[$(review yicong-huang APPROVED)]")" \
+  "blocked||release/v1.2:NONE"
+
+check "logins compare case-insensitively" \
+  "$(input contributor '["release/v1.2"]' "[$(review XuAnG7 APPROVED)]")" \
+  "ok|release/v1.2|"
+
+# --- cases that must not deadlock a PR ---------------------------------------
+check "a manager who authored the PR counts as approving" \
+  "$(input XuAng7 '["release/v1.2"]' '[]')" \
+  "ok|release/v1.2|"
+
+check "an entry that omits its manager stays ungated" \
+  "$(input contributor '["release/v1.1"]' '[]')" \
+  "ok|release/v1.1|"
+
+check "no release labels at all -> nothing to approve" \
+  "$(input contributor '[]' '[]')" \
+  "ok||"
+
+# --- fail closed, and never claim more than the state proves -----------------
+check "a label with no config entry is held, not waved through" \
+  "$(input contributor '["release/v1.0"]' "[$(review xuang7 APPROVED)]")" \
+  "blocked||release/v1.0:UNCONFIGURED"
+
+check "an unreadable review list holds every gated target" \
+  "$(input contributor "$both" 'null')" \
+  "blocked||release/v1.2:UNKNOWN,release/v1.3:UNKNOWN"
+
+# --- the required check's verdict and its wording ----------------------------
+report() { printf '%s' "$1" | node "$gate" --report 2>/dev/null; }
+
+if report "$(input contributor "$both" "[$(review xuang7 APPROVED),$(review mengw15 APPROVED)]")" >/dev/null; then
+  pass "--report exits 0 when every target is approved"
+else
+  failed "--report should exit 0 when every target is approved"
+fi
+
+if report "$(input contributor "$both" "[$(review mengw15 APPROVED)]")" >/dev/null; then
+  failed "--report should exit non-zero while a target is unapproved"
+else
+  pass "--report exits non-zero while a target is unapproved"
+fi
+
+if report "$(input contributor '[]' '[]')" >/dev/null; then
+  pass "--report exits 0 on a PR with no release labels"
+else
+  failed "--report must exit 0 on a PR with no release labels (it is a required check)"
+fi
+
+# The report is the whole explanation an author gets, so it has to name both
+# ways out and say the call belongs to the manager.
+out="$(report "$(input contributor "$both" "[$(review mengw15 APPROVED)]")")"
+for phrase in "approve this PR" "remove the label" "triage access" "@xuang7"; do
+  if [[ "$out" == *"$phrase"* ]]; then
+    pass "report mentions \"$phrase\""
+  else
+    failed "report should mention \"$phrase\""
+  fi
+done
+
+# A dismissal lands on DISMISSED whatever the review had been, so the report
+# must not tell readers an approval existed.
+out="$(report "$(input contributor '["release/v1.2"]' "[$(review xuang7 APPROVED),$(review xuang7 DISMISSED)]")")"
+if [[ "$out" == *"approved"* && "$out" != *"was dismissed"* ]]; then
+  failed "a dismissed review must not be reported as a standing approval"
+else
+  pass "a dismissed review is reported without claiming an approval existed"
+fi

Review Comment:
   This assertion does not catch the wording regression it describes: the old incorrect phrase “approval was dismissed” contains both `approved` and `was dismissed`, so the condition passes it (as does the report's unavoidable “not approved” text). Assert that “approval was dismissed” is absent and that the intended “review was dismissed” wording is present.



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ci: block the merge until each release/* label has its manager's approval [texera]

Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on code in PR #8096:
URL: https://github.com/apache/texera/pull/8096#discussion_r3921544766


##########
.github/workflows/backport-auto-label.yml:
##########
@@ -205,6 +220,15 @@ jobs:
               for (const entry of entries) {
                 const label = entry.branch;
                 const manager = entry.manager;
+                // Say who has to sign off, so the label is not mistaken for the
+                // decision. A manager who wrote the fix needs no approval —
+                // GitHub does not let anyone approve their own PR.
+                const gate =
+                  manager && !managerIsAuthor(manager)
+                    ? ` @${manager} decides: approving sends the fix here, ` +
+                      `removing this label declines it. The merge waits on one ` +
+                      `or the other.`
+                    : "";
 
                 // Only actively-supporting branches are analyzed / auto-labeled.
                 // An inactive branch stays a valid manual target (label it by

Review Comment:
   This is the mirror of `release-branches.yml:36-41`, which you corrected in this same commit. That copy now adds "but its manager must still approve before the PR can merge, and nothing asks them to"; this one still says only that the apply-check and post-merge backport run.
   
   It matters more here, because this is the workflow the claim describes. `release_branches.py:87` returns inactive entries, so `backport-approval-check.yml:104-110` loads `release/v1.1` with manager `bobbai00` and `:168-189` blocks it. Meanwhile `:237-240` below `continue`s on `!entry.active` before the `reviewRequests.push` at `:301`.
   
   So a maintainer who reads this and hand-labels an inactive branch gets a red required check, waiting on an approval nobody was asked for.



##########
AGENTS.md:
##########
@@ -258,5 +258,9 @@ diff -> pr-labeler -> labels on PR -> required-checks maps labels to stacks -> C
   suspect breaks the frontend)? **Add the relevant label manually**.
 - Empty stack union (docs-only / dev-only / `dependencies` / `feature` /
   `fix` / `refactor` / `release/*` only) skips every build stack on purpose.
-- `release/*` labels select backport targets; removing one cancels that
-  backport.
+- `release/*` labels nominate backport targets. A nominated target is
+  backported only once that branch's release manager — listed in
+  [`.github/release-branches.yml`](.github/release-branches.yml) — approves the
+  PR, and the required `Backport Approvals` check blocks the merge until every
+  label on the PR is approved. A manager declines by removing their label, so

Review Comment:
   "every label on the PR" drops the `release/*` qualifier. The bullet just above (`:259-260`) enumerates `dependencies`, `feature`, `fix`, `refactor` and `release/*`, so the unqualified phrasing reads as covering all of them. `CONTRIBUTING.md:141`, rewritten in the same PR, says "every `release/*` label on the PR".
   
   ```suggestion
     PR, and the required `Backport Approvals` check blocks the merge until every
     `release/*` label on the PR is approved. A manager declines by removing their
     label, so
   ```



##########
.github/workflows/backport-approval-check.yml:
##########
@@ -0,0 +1,316 @@
+# 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.
+
+# Blocks the merge while a `release/*` label on the PR has not been approved by
+# that branch's release manager (.github/release-branches.yml).
+#
+# The point is that a merged PR's labels should be a truthful record. A label
+# only nominates a branch, so before this check a manager declined a backport by
+# staying silent — and the label stayed on, which read afterwards as "this
+# shipped in 1.2" when it had not. Here declining is an action: the manager
+# either approves, or removes their label. Since the merge waits for every
+# remaining label to be approved, the labels on a merged PR are exactly the
+# branches Direct Backport Push then sends the fix to.
+#
+# The author's job is to ask the manager for that call, not to make it for them.
+# Editing labels needs triage access, so outside contributors and Renovate or
+# Dependabot PRs cannot remove a label themselves — the failure report says so
+# and names who to ask.
+#
+# `Backport Approvals` is listed in .asf.yaml's required_status_checks, so this
+# job must produce a result on EVERY pull request, or a PR that never runs it
+# waits forever. That is why it is not conditioned on the title, the labels, or
+# the base branch: it always runs and reports success when there is nothing to
+# approve. Merge groups are re-evaluated rather than waved through, because a
+# queued PR's own checks are no longer consulted once it is queued; a group
+# whose PRs cannot be resolved fails closed rather than passing unchecked. Do
+# not rename the job — its display name is the required context.
+
+name: Backport Approval Check
+
+on:
+  pull_request:
+    types:
+      - opened
+      - reopened
+      - synchronize
+      - labeled
+      - unlabeled
+      # Retargeting arrives as `edited`, and the verdict depends on the base
+      # branch: a backport PR into release/* has nothing to approve, the same
+      # PR moved onto main does.
+      - edited
+  pull_request_review:
+    types:
+      - submitted
+      - dismissed
+  merge_group:
+
+# Read-only: this job never writes to the PR, and `pull_request_review` runs
+# with the base repository's token even for fork PRs.
+permissions:
+  contents: read
+  pull-requests: read
+
+concurrency:
+  group: backport-approvals-${{ github.event.pull_request.number || github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  backport-approvals:
+    # Do not rename — this display name is the required status check context
+    # referenced in .asf.yaml.
+    name: Backport Approvals
+    runs-on: ubuntu-latest
+    steps:
+      # The PR's own head (or the queued group's), so the config is the one that
+      # will govern this change once it merges. Checking out the base would not
+      # be a security boundary anyway: on `pull_request` the workflow definition
+      # itself comes from the PR. What bounds this is the event — a fork gets a
+      # read-only token and no secrets, and nothing here writes to the PR.
+      - name: Checkout
+        uses: actions/checkout@v7
+        with:
+          ref: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }}
+          persist-credentials: false
+
+      - name: Read release branches
+        id: targets
+        run: |
+          entries=$(python3 .github/scripts/release_branches.py .github/release-branches.yml)
+          echo "entries=${entries}" >> "$GITHUB_OUTPUT"
+          echo "Release branch targets: ${entries}"
+
+      - name: Check release manager approvals
+        uses: actions/github-script@v9
+        env:
+          ENTRIES: ${{ steps.targets.outputs.entries }}
+        with:
+          script: |
+            const { owner, repo } = context.repo;
+            const managers = new Map(
+              JSON.parse(process.env.ENTRIES || "[]").map((e) => [
+                e.branch,
+                e.manager || "",
+              ])
+            );
+
+            // A merge group carries several PRs and its commits are the squash
+            // merges, so the number is parsed out of each subject — the same way
+            // precheck.yml resolves them.
+            async function pullRequestNumbers() {
+              if (context.eventName !== "merge_group") {
+                return [context.payload.pull_request.number];
+              }
+              const mg = context.payload.merge_group;
+              const { data: comparison } = await github.rest.repos.compareCommits({
+                owner, repo, base: mg.base_sha, head: mg.head_sha,
+              });
+              return comparison.commits.map((c) => {
+                const m = c.commit.message.split("\n", 1)[0].match(/\(#(\d+)\)\s*$/);
+                if (!m) throw new Error(`no PR number in the message of ${c.sha}`);
+                return Number(m[1]);
+              });
+            }
+
+            // Latest review state per login. COMMENTED never changes an approval;
+            // a later CHANGES_REQUESTED or DISMISSED revokes one. listReviews is
+            // documented to return reviews chronologically, so the last state
+            // recorded for a login is the one that counts. `null` means the list
+            // could not be read at all — kept distinct from an empty list, since
+            // "we did not look" must never be reported as "nobody approved".
+            async function reviewStates(number) {
+              try {
+                const reviews = await github.paginate(github.rest.pulls.listReviews, {
+                  owner, repo, pull_number: number, per_page: 100,
+                });
+                const states = new Map();
+                for (const review of reviews) {
+                  const login = review.user?.login;
+                  if (!login || review.state === "COMMENTED") continue;
+                  states.set(login.toLowerCase(), review.state);
+                }
+                return states;
+              } catch (e) {
+                core.warning(
+                  `listReviews for #${number} failed (${e.status ?? "?"}): ${e.message}`
+                );
+                return null;
+              }
+            }
+
+            // Managers gate their own branch and nothing else, so approvals
+            // compose: an approval from the v1.2 manager alone clears v1.2 and
+            // leaves v1.3 blocked.
+            function decide(targets, author, states) {
+              const authorLogin = (author || "").toLowerCase();
+              const cleared = [];
+              const blocked = [];
+              for (const target of targets) {
+                // release-branches.yml is the authorization source, so a label
+                // naming a branch it does not list has nobody who could approve
+                // it. That differs from an entry that deliberately omits
+                // `manager`, and the difference is reachable: retiring a branch
+                // means dropping its entry while its label lives on.
+                if (!managers.has(target)) {
+                  blocked.push({ target, manager: "", state: "UNCONFIGURED" });
+                  continue;
+                }
+                const manager = managers.get(target);
+                if (!manager) {
+                  cleared.push({ target, note: "no release manager configured for this branch" });
+                  continue;
+                }
+                // GitHub does not let anyone approve their own PR, so a manager
+                // who wrote the fix counts as having signed off. Logins are
+                // case-insensitive while `manager` is typed by hand, so fold both.
+                if (manager.toLowerCase() === authorLogin) {
+                  cleared.push({ target, note: `@${manager} is the author of this PR` });
+                  continue;
+                }
+                const state = states ? states.get(manager.toLowerCase()) : "UNKNOWN";
+                if (state === "APPROVED") {
+                  cleared.push({ target, note: `approved by @${manager}` });
+                } else {
+                  blocked.push({ target, manager, state: state || "NONE" });
+                }
+              }
+              return { cleared, blocked };
+            }
+
+            // Say only what the state proves. A dismissal lands on DISMISSED
+            // whatever the review was — GitHub dismisses a blocking
+            // CHANGES_REQUESTED as readily as it clears a stale approval — so
+            // naming it an approval would put a guess in the manager's mouth.
+            function reason(e) {
+              if (e.state === "VETOED") {
+                return "`no-backport-needed` says this fix reaches no release " +
+                  "branch, so this label contradicts it and would be left on a " +
+                  "merged PR promising a backport nobody performs — remove the " +
+                  "label, or remove `no-backport-needed`";
+              }
+              if (e.state === "UNCONFIGURED") {
+                return "this branch is not listed in .github/release-branches.yml, " +
+                  "so no release manager governs it — drop the label, or add the " +
+                  "branch back to that file";
+              }
+              if (e.state === "DISMISSED") {
+                return `@${e.manager}'s review was dismissed, so no approval stands`;
+              }
+              if (e.state === "CHANGES_REQUESTED") {
+                return `@${e.manager} requested changes and has not approved since`;
+              }
+              if (e.state === "UNKNOWN") {
+                return `this PR's reviews could not be read, so @${e.manager}'s ` +
+                  `approval could not be confirmed`;
+              }
+              return `needs an approving review from @${e.manager}`;
+            }
+
+            let numbers;
+            try {
+              numbers = await pullRequestNumbers();
+            } catch (e) {
+              // Fail closed. Only reachable for a merge group whose commits
+              // cannot be mapped back to PRs, and a group whose approvals
+              // cannot be read is not a group this can vouch for — passing it
+              // would leave the queue ungated in exactly the window this job
+              // exists to cover. Ejecting the group is recoverable: its PRs
+              // re-queue, and each still holds its own passing check.
+              core.setFailed(
+                `Could not resolve the pull requests in this merge group ` +
+                `(${e.message}). Refusing to pass a check that could not be ` +
+                `computed.`
+              );
+              return;
+            }
+
+            const lines = [];
+            let failed = false;
+
+            for (const number of numbers) {
+              const { data: pr } = await github.rest.pulls.get({
+                owner, repo, pull_number: number,
+              });
+              const labels = (pr.labels || []).map((l) => l.name);
+              const releaseLabels = [...new Set(
+                labels.filter((n) => /^release\/.+$/.test(n))
+              )].sort();
+              // A PR already targeting a release branch is itself a backport and
+              // is not backported onward, so there is nothing here to approve.
+              const intoMain = pr.base.ref === "main";
+              // `no-backport-needed` says the fix reaches no release branch, but
+              // nothing removes the labels it overrides — and precheck documents
+              // adding it mid-review, by which point the auto-labeler has already
+              // applied them. Merging in that state leaves a label promising a
+              // backport the push will skip: the false record this check exists
+              // to prevent. So the contradiction is reported rather than settled
+              // silently in the veto's favour.
+              const vetoed = labels.includes("no-backport-needed");
+              const targets = intoMain && !vetoed ? releaseLabels : [];
+              const contradictions =
+                intoMain && vetoed
+                  ? releaseLabels.map((target) => ({
+                      target, manager: "", state: "VETOED",
+                    }))
+                  : [];
+
+              if (numbers.length > 1) lines.push(`### PR #${number}`, "");
+              if (targets.length === 0 && contradictions.length === 0) {
+                lines.push("No `release/*` labels — nothing to approve.", "");

Review Comment:
   Now that the veto case correctly blocks, this line covers two conditions, and the residual one is `pr.base.ref !== "main"` (`:254`). A PR based on a release branch that does carry `release/*` labels is told it has none. Worth its own message.



##########
.github/workflows/backport-approval-check.yml:
##########
@@ -0,0 +1,316 @@
+# 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.
+
+# Blocks the merge while a `release/*` label on the PR has not been approved by
+# that branch's release manager (.github/release-branches.yml).
+#
+# The point is that a merged PR's labels should be a truthful record. A label
+# only nominates a branch, so before this check a manager declined a backport by
+# staying silent — and the label stayed on, which read afterwards as "this
+# shipped in 1.2" when it had not. Here declining is an action: the manager
+# either approves, or removes their label. Since the merge waits for every
+# remaining label to be approved, the labels on a merged PR are exactly the
+# branches Direct Backport Push then sends the fix to.
+#
+# The author's job is to ask the manager for that call, not to make it for them.
+# Editing labels needs triage access, so outside contributors and Renovate or
+# Dependabot PRs cannot remove a label themselves — the failure report says so
+# and names who to ask.
+#
+# `Backport Approvals` is listed in .asf.yaml's required_status_checks, so this
+# job must produce a result on EVERY pull request, or a PR that never runs it
+# waits forever. That is why it is not conditioned on the title, the labels, or
+# the base branch: it always runs and reports success when there is nothing to
+# approve. Merge groups are re-evaluated rather than waved through, because a
+# queued PR's own checks are no longer consulted once it is queued; a group
+# whose PRs cannot be resolved fails closed rather than passing unchecked. Do
+# not rename the job — its display name is the required context.
+
+name: Backport Approval Check
+
+on:
+  pull_request:
+    types:
+      - opened
+      - reopened
+      - synchronize
+      - labeled
+      - unlabeled
+      # Retargeting arrives as `edited`, and the verdict depends on the base
+      # branch: a backport PR into release/* has nothing to approve, the same
+      # PR moved onto main does.
+      - edited
+  pull_request_review:
+    types:
+      - submitted
+      - dismissed
+  merge_group:
+
+# Read-only: this job never writes to the PR, and `pull_request_review` runs
+# with the base repository's token even for fork PRs.
+permissions:
+  contents: read
+  pull-requests: read
+
+concurrency:
+  group: backport-approvals-${{ github.event.pull_request.number || github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  backport-approvals:
+    # Do not rename — this display name is the required status check context
+    # referenced in .asf.yaml.
+    name: Backport Approvals
+    runs-on: ubuntu-latest
+    steps:
+      # The PR's own head (or the queued group's), so the config is the one that
+      # will govern this change once it merges. Checking out the base would not
+      # be a security boundary anyway: on `pull_request` the workflow definition
+      # itself comes from the PR. What bounds this is the event — a fork gets a
+      # read-only token and no secrets, and nothing here writes to the PR.
+      - name: Checkout
+        uses: actions/checkout@v7
+        with:
+          ref: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }}
+          persist-credentials: false
+
+      - name: Read release branches
+        id: targets
+        run: |
+          entries=$(python3 .github/scripts/release_branches.py .github/release-branches.yml)
+          echo "entries=${entries}" >> "$GITHUB_OUTPUT"
+          echo "Release branch targets: ${entries}"
+
+      - name: Check release manager approvals
+        uses: actions/github-script@v9
+        env:
+          ENTRIES: ${{ steps.targets.outputs.entries }}
+        with:
+          script: |
+            const { owner, repo } = context.repo;
+            const managers = new Map(
+              JSON.parse(process.env.ENTRIES || "[]").map((e) => [
+                e.branch,
+                e.manager || "",
+              ])
+            );
+
+            // A merge group carries several PRs and its commits are the squash
+            // merges, so the number is parsed out of each subject — the same way
+            // precheck.yml resolves them.
+            async function pullRequestNumbers() {
+              if (context.eventName !== "merge_group") {
+                return [context.payload.pull_request.number];
+              }
+              const mg = context.payload.merge_group;
+              const { data: comparison } = await github.rest.repos.compareCommits({
+                owner, repo, base: mg.base_sha, head: mg.head_sha,
+              });
+              return comparison.commits.map((c) => {
+                const m = c.commit.message.split("\n", 1)[0].match(/\(#(\d+)\)\s*$/);
+                if (!m) throw new Error(`no PR number in the message of ${c.sha}`);
+                return Number(m[1]);
+              });
+            }
+
+            // Latest review state per login. COMMENTED never changes an approval;
+            // a later CHANGES_REQUESTED or DISMISSED revokes one. listReviews is
+            // documented to return reviews chronologically, so the last state
+            // recorded for a login is the one that counts. `null` means the list
+            // could not be read at all — kept distinct from an empty list, since
+            // "we did not look" must never be reported as "nobody approved".
+            async function reviewStates(number) {
+              try {
+                const reviews = await github.paginate(github.rest.pulls.listReviews, {
+                  owner, repo, pull_number: number, per_page: 100,
+                });
+                const states = new Map();
+                for (const review of reviews) {
+                  const login = review.user?.login;
+                  if (!login || review.state === "COMMENTED") continue;
+                  states.set(login.toLowerCase(), review.state);
+                }
+                return states;
+              } catch (e) {
+                core.warning(
+                  `listReviews for #${number} failed (${e.status ?? "?"}): ${e.message}`
+                );
+                return null;
+              }
+            }
+
+            // Managers gate their own branch and nothing else, so approvals
+            // compose: an approval from the v1.2 manager alone clears v1.2 and
+            // leaves v1.3 blocked.
+            function decide(targets, author, states) {

Review Comment:
   `decide`, `reason` and `reviewStates` live inside this `github-script` string, where nothing can exercise them. The description says the eight cases were driven through locally, so that coverage ended with the session.
   
   Three concepts are also re-declared: the label→target derivation at `:249-251` (also `precheck.yml:336-339`), the branch→manager Map at `:104-110` (also `direct-backport-push.yml:266-271`), and the `manager == author` fold at `:181` (also `backport-auto-label.yml:140`). Your own new comment there says the two must agree or the check clears a branch the report is still holding — with nothing enforcing it.
   
   This PR had the shape earlier: `backport-gate.js` with `test_backport_gate.sh`, dropped when the logic was inlined. `build.yml:1291-1307` already runs every `test_*.sh` under `.github/scripts/`. Advisory — every copy agrees today.



##########
.github/workflows/backport-approval-check.yml:
##########
@@ -0,0 +1,316 @@
+# 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.
+
+# Blocks the merge while a `release/*` label on the PR has not been approved by
+# that branch's release manager (.github/release-branches.yml).
+#
+# The point is that a merged PR's labels should be a truthful record. A label
+# only nominates a branch, so before this check a manager declined a backport by
+# staying silent — and the label stayed on, which read afterwards as "this
+# shipped in 1.2" when it had not. Here declining is an action: the manager
+# either approves, or removes their label. Since the merge waits for every
+# remaining label to be approved, the labels on a merged PR are exactly the
+# branches Direct Backport Push then sends the fix to.
+#
+# The author's job is to ask the manager for that call, not to make it for them.
+# Editing labels needs triage access, so outside contributors and Renovate or
+# Dependabot PRs cannot remove a label themselves — the failure report says so
+# and names who to ask.
+#
+# `Backport Approvals` is listed in .asf.yaml's required_status_checks, so this
+# job must produce a result on EVERY pull request, or a PR that never runs it
+# waits forever. That is why it is not conditioned on the title, the labels, or
+# the base branch: it always runs and reports success when there is nothing to
+# approve. Merge groups are re-evaluated rather than waved through, because a
+# queued PR's own checks are no longer consulted once it is queued; a group
+# whose PRs cannot be resolved fails closed rather than passing unchecked. Do
+# not rename the job — its display name is the required context.
+
+name: Backport Approval Check
+
+on:
+  pull_request:
+    types:
+      - opened
+      - reopened
+      - synchronize
+      - labeled
+      - unlabeled
+      # Retargeting arrives as `edited`, and the verdict depends on the base
+      # branch: a backport PR into release/* has nothing to approve, the same
+      # PR moved onto main does.
+      - edited
+  pull_request_review:
+    types:
+      - submitted
+      - dismissed
+  merge_group:
+
+# Read-only: this job never writes to the PR, and `pull_request_review` runs
+# with the base repository's token even for fork PRs.
+permissions:
+  contents: read
+  pull-requests: read
+
+concurrency:
+  group: backport-approvals-${{ github.event.pull_request.number || github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  backport-approvals:
+    # Do not rename — this display name is the required status check context
+    # referenced in .asf.yaml.
+    name: Backport Approvals
+    runs-on: ubuntu-latest
+    steps:
+      # The PR's own head (or the queued group's), so the config is the one that
+      # will govern this change once it merges. Checking out the base would not
+      # be a security boundary anyway: on `pull_request` the workflow definition
+      # itself comes from the PR. What bounds this is the event — a fork gets a
+      # read-only token and no secrets, and nothing here writes to the PR.
+      - name: Checkout
+        uses: actions/checkout@v7
+        with:
+          ref: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }}
+          persist-credentials: false
+
+      - name: Read release branches
+        id: targets
+        run: |
+          entries=$(python3 .github/scripts/release_branches.py .github/release-branches.yml)
+          echo "entries=${entries}" >> "$GITHUB_OUTPUT"
+          echo "Release branch targets: ${entries}"
+
+      - name: Check release manager approvals
+        uses: actions/github-script@v9
+        env:
+          ENTRIES: ${{ steps.targets.outputs.entries }}
+        with:
+          script: |
+            const { owner, repo } = context.repo;
+            const managers = new Map(
+              JSON.parse(process.env.ENTRIES || "[]").map((e) => [
+                e.branch,
+                e.manager || "",
+              ])
+            );
+
+            // A merge group carries several PRs and its commits are the squash
+            // merges, so the number is parsed out of each subject — the same way
+            // precheck.yml resolves them.
+            async function pullRequestNumbers() {
+              if (context.eventName !== "merge_group") {
+                return [context.payload.pull_request.number];
+              }
+              const mg = context.payload.merge_group;
+              const { data: comparison } = await github.rest.repos.compareCommits({
+                owner, repo, base: mg.base_sha, head: mg.head_sha,
+              });
+              return comparison.commits.map((c) => {

Review Comment:
   No `length === 0` check here. If `comparison.commits` is empty, `numbers` is `[]` and the loop at `:244` never runs, so `failed` stays `false` and the job publishes a green `Backport Approvals` for a group whose approvals were never read.
   
   `precheck.yml:145-147` — the code this mirrors — guards exactly that, and the asymmetry runs the wrong way: precheck degrades by running more builds, this one by waving the group through. It is also the residue of r3894366331; the `core.setFailed` at `:234-239` catches the throwing branch, not the empty-array one. The `throw` below already routes there, so one line closes it.
   
   ```suggestion
                 if (comparison.commits.length === 0) {
                   throw new Error(`no commits between ${mg.base_sha} and ${mg.head_sha}`);
                 }
                 return comparison.commits.map((c) => {
   ```
   
   Advisory, not must-fix: `min_entries_to_merge: 2` means a real group always carries commits, so I cannot name a trigger. But silent-and-green is the worst direction for an authorization check.



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ci: block the merge until each release/* label has its manager's approval [texera]

Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on code in PR #8096:
URL: https://github.com/apache/texera/pull/8096#discussion_r3921646516


##########
.github/workflows/backport-approval-check.yml:
##########
@@ -0,0 +1,316 @@
+# 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.
+
+# Blocks the merge while a `release/*` label on the PR has not been approved by
+# that branch's release manager (.github/release-branches.yml).
+#
+# The point is that a merged PR's labels should be a truthful record. A label
+# only nominates a branch, so before this check a manager declined a backport by
+# staying silent — and the label stayed on, which read afterwards as "this
+# shipped in 1.2" when it had not. Here declining is an action: the manager
+# either approves, or removes their label. Since the merge waits for every
+# remaining label to be approved, the labels on a merged PR are exactly the
+# branches Direct Backport Push then sends the fix to.
+#
+# The author's job is to ask the manager for that call, not to make it for them.
+# Editing labels needs triage access, so outside contributors and Renovate or
+# Dependabot PRs cannot remove a label themselves — the failure report says so
+# and names who to ask.
+#
+# `Backport Approvals` is listed in .asf.yaml's required_status_checks, so this
+# job must produce a result on EVERY pull request, or a PR that never runs it
+# waits forever. That is why it is not conditioned on the title, the labels, or
+# the base branch: it always runs and reports success when there is nothing to
+# approve. Merge groups are re-evaluated rather than waved through, because a
+# queued PR's own checks are no longer consulted once it is queued; a group
+# whose PRs cannot be resolved fails closed rather than passing unchecked. Do
+# not rename the job — its display name is the required context.
+
+name: Backport Approval Check
+
+on:
+  pull_request:
+    types:
+      - opened
+      - reopened
+      - synchronize
+      - labeled
+      - unlabeled
+      # Retargeting arrives as `edited`, and the verdict depends on the base
+      # branch: a backport PR into release/* has nothing to approve, the same
+      # PR moved onto main does.
+      - edited
+  pull_request_review:
+    types:
+      - submitted
+      - dismissed
+  merge_group:
+
+# Read-only: this job never writes to the PR, and `pull_request_review` runs
+# with the base repository's token even for fork PRs.
+permissions:
+  contents: read
+  pull-requests: read
+
+concurrency:
+  group: backport-approvals-${{ github.event.pull_request.number || github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  backport-approvals:
+    # Do not rename — this display name is the required status check context
+    # referenced in .asf.yaml.
+    name: Backport Approvals
+    runs-on: ubuntu-latest
+    steps:
+      # The PR's own head (or the queued group's), so the config is the one that
+      # will govern this change once it merges. Checking out the base would not
+      # be a security boundary anyway: on `pull_request` the workflow definition
+      # itself comes from the PR. What bounds this is the event — a fork gets a
+      # read-only token and no secrets, and nothing here writes to the PR.
+      - name: Checkout
+        uses: actions/checkout@v7
+        with:
+          ref: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }}

Review Comment:
   This pins the PR head, and `:93` runs `release_branches.py` against that tree — so the gate reads its authorization config from a revision that can be arbitrarily old.
   
   `backport-auto-label.yml:79`, which creates the labels this gate judges, pins `base.sha` instead, under a comment saying the config must come from the base repo. `direct-backport-push.yml` reads main. Two of the three consumers agree; this one does not.
   
   Neither file exists on a head predating `31f1e7bf8` (#6941), nor on one branched from `release/v1.1` or `v1.2`. `run:` runs under `bash -eo pipefail`, so the missing file exits the step 2 and the required check goes red with a file-not-found instead of your report. **37 of the 222 open PRs into `main` are in that state** (list in the summary block), and none can clear it by approving or unlabeling.
   
   ```suggestion
             ref: ${{ github.event.pull_request.base.sha || github.event.merge_group.head_sha }}
   ```
   
   The tradeoff: a PR that itself edits `release-branches.yml` would then be judged by the pre-edit config. That looks negligible here, since such PRs are `ci:`-typed and carry no `release/*` labels. `refs/pull/{n}/merge` keeps both but does not exist for a conflicting PR.



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ci: block the merge until each release/* label has its manager's approval [texera]

Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang merged PR #8096:
URL: https://github.com/apache/texera/pull/8096


-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ci: gate each backport on its release manager's approval [texera]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #8096:
URL: https://github.com/apache/texera/pull/8096#issuecomment-5460870819

   <!-- texera-reviewer-suggestion -->
   ### Automated Reviewer Suggestions
   
   Based on the `git blame` history of the changed files, we recommend the following reviewers:
   
   - **Contributors with relevant context:** `@Yicong-Huang`
     You can notify them by mentioning `@Yicong-Huang` in a comment.
   


-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ci: block the merge until each release/* label has its manager's approval [texera]

Posted by "mengw15 (via GitHub)" <gi...@apache.org>.
mengw15 commented on code in PR #8096:
URL: https://github.com/apache/texera/pull/8096#discussion_r3921720869


##########
.github/workflows/backport-approval-check.yml:
##########
@@ -0,0 +1,316 @@
+# 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.
+
+# Blocks the merge while a `release/*` label on the PR has not been approved by
+# that branch's release manager (.github/release-branches.yml).
+#
+# The point is that a merged PR's labels should be a truthful record. A label
+# only nominates a branch, so before this check a manager declined a backport by
+# staying silent — and the label stayed on, which read afterwards as "this
+# shipped in 1.2" when it had not. Here declining is an action: the manager
+# either approves, or removes their label. Since the merge waits for every
+# remaining label to be approved, the labels on a merged PR are exactly the
+# branches Direct Backport Push then sends the fix to.
+#
+# The author's job is to ask the manager for that call, not to make it for them.
+# Editing labels needs triage access, so outside contributors and Renovate or
+# Dependabot PRs cannot remove a label themselves — the failure report says so
+# and names who to ask.
+#
+# `Backport Approvals` is listed in .asf.yaml's required_status_checks, so this
+# job must produce a result on EVERY pull request, or a PR that never runs it
+# waits forever. That is why it is not conditioned on the title, the labels, or
+# the base branch: it always runs and reports success when there is nothing to
+# approve. Merge groups are re-evaluated rather than waved through, because a
+# queued PR's own checks are no longer consulted once it is queued; a group
+# whose PRs cannot be resolved fails closed rather than passing unchecked. Do
+# not rename the job — its display name is the required context.
+
+name: Backport Approval Check
+
+on:
+  pull_request:
+    types:
+      - opened
+      - reopened
+      - synchronize
+      - labeled
+      - unlabeled
+      # Retargeting arrives as `edited`, and the verdict depends on the base
+      # branch: a backport PR into release/* has nothing to approve, the same
+      # PR moved onto main does.
+      - edited
+  pull_request_review:
+    types:
+      - submitted
+      - dismissed
+  merge_group:
+
+# Read-only: this job never writes to the PR, and `pull_request_review` runs
+# with the base repository's token even for fork PRs.
+permissions:
+  contents: read
+  pull-requests: read
+
+concurrency:
+  group: backport-approvals-${{ github.event.pull_request.number || github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  backport-approvals:
+    # Do not rename — this display name is the required status check context
+    # referenced in .asf.yaml.
+    name: Backport Approvals
+    runs-on: ubuntu-latest
+    steps:
+      # The PR's own head (or the queued group's), so the config is the one that
+      # will govern this change once it merges. Checking out the base would not
+      # be a security boundary anyway: on `pull_request` the workflow definition
+      # itself comes from the PR. What bounds this is the event — a fork gets a
+      # read-only token and no secrets, and nothing here writes to the PR.
+      - name: Checkout
+        uses: actions/checkout@v7
+        with:
+          ref: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }}

Review Comment:
   Confirmed and fixed in `1273f493e` — this was mine to get wrong, and I had the right answer before: I moved this off `base.sha` last round arguing that a base checkout is not a security boundary (true, since on `pull_request` the workflow itself comes from the PR) and that reading the merged config would match what Direct Backport Push sees post-merge. I never priced the head being older than the config. Spot-checked #7293, #6915, #4295 and #5382: both files 404 at head, and the step dies before any JS runs. Back on `base.sha`, which also puts this in agreement with the two other consumers rather than being the odd one out. The pre-edit-config trade-off is priced in the comment.



##########
.github/workflows/backport-auto-label.yml:
##########
@@ -205,6 +220,15 @@ jobs:
               for (const entry of entries) {
                 const label = entry.branch;
                 const manager = entry.manager;
+                // Say who has to sign off, so the label is not mistaken for the
+                // decision. A manager who wrote the fix needs no approval —
+                // GitHub does not let anyone approve their own PR.
+                const gate =
+                  manager && !managerIsAuthor(manager)
+                    ? ` @${manager} decides: approving sends the fix here, ` +
+                      `removing this label declines it. The merge waits on one ` +
+                      `or the other.`
+                    : "";
 
                 // Only actively-supporting branches are analyzed / auto-labeled.
                 // An inactive branch stays a valid manual target (label it by

Review Comment:
   Right — I corrected the source-of-truth copy and left its mirror, in the workflow the claim is actually about. Fixed in `1273f493e`; both now say the manager must still approve and that the `continue` below means no review is requested, so whoever hand-labels an inactive branch should ping them.



##########
.github/workflows/backport-approval-check.yml:
##########
@@ -0,0 +1,316 @@
+# 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.
+
+# Blocks the merge while a `release/*` label on the PR has not been approved by
+# that branch's release manager (.github/release-branches.yml).
+#
+# The point is that a merged PR's labels should be a truthful record. A label
+# only nominates a branch, so before this check a manager declined a backport by
+# staying silent — and the label stayed on, which read afterwards as "this
+# shipped in 1.2" when it had not. Here declining is an action: the manager
+# either approves, or removes their label. Since the merge waits for every
+# remaining label to be approved, the labels on a merged PR are exactly the
+# branches Direct Backport Push then sends the fix to.
+#
+# The author's job is to ask the manager for that call, not to make it for them.
+# Editing labels needs triage access, so outside contributors and Renovate or
+# Dependabot PRs cannot remove a label themselves — the failure report says so
+# and names who to ask.
+#
+# `Backport Approvals` is listed in .asf.yaml's required_status_checks, so this
+# job must produce a result on EVERY pull request, or a PR that never runs it
+# waits forever. That is why it is not conditioned on the title, the labels, or
+# the base branch: it always runs and reports success when there is nothing to
+# approve. Merge groups are re-evaluated rather than waved through, because a
+# queued PR's own checks are no longer consulted once it is queued; a group
+# whose PRs cannot be resolved fails closed rather than passing unchecked. Do
+# not rename the job — its display name is the required context.
+
+name: Backport Approval Check
+
+on:
+  pull_request:
+    types:
+      - opened
+      - reopened
+      - synchronize
+      - labeled
+      - unlabeled
+      # Retargeting arrives as `edited`, and the verdict depends on the base
+      # branch: a backport PR into release/* has nothing to approve, the same
+      # PR moved onto main does.
+      - edited
+  pull_request_review:
+    types:
+      - submitted
+      - dismissed
+  merge_group:
+
+# Read-only: this job never writes to the PR, and `pull_request_review` runs
+# with the base repository's token even for fork PRs.
+permissions:
+  contents: read
+  pull-requests: read
+
+concurrency:
+  group: backport-approvals-${{ github.event.pull_request.number || github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  backport-approvals:
+    # Do not rename — this display name is the required status check context
+    # referenced in .asf.yaml.
+    name: Backport Approvals
+    runs-on: ubuntu-latest
+    steps:
+      # The PR's own head (or the queued group's), so the config is the one that
+      # will govern this change once it merges. Checking out the base would not
+      # be a security boundary anyway: on `pull_request` the workflow definition
+      # itself comes from the PR. What bounds this is the event — a fork gets a
+      # read-only token and no secrets, and nothing here writes to the PR.
+      - name: Checkout
+        uses: actions/checkout@v7
+        with:
+          ref: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }}
+          persist-credentials: false
+
+      - name: Read release branches
+        id: targets
+        run: |
+          entries=$(python3 .github/scripts/release_branches.py .github/release-branches.yml)
+          echo "entries=${entries}" >> "$GITHUB_OUTPUT"
+          echo "Release branch targets: ${entries}"
+
+      - name: Check release manager approvals
+        uses: actions/github-script@v9
+        env:
+          ENTRIES: ${{ steps.targets.outputs.entries }}
+        with:
+          script: |
+            const { owner, repo } = context.repo;
+            const managers = new Map(
+              JSON.parse(process.env.ENTRIES || "[]").map((e) => [
+                e.branch,
+                e.manager || "",
+              ])
+            );
+
+            // A merge group carries several PRs and its commits are the squash
+            // merges, so the number is parsed out of each subject — the same way
+            // precheck.yml resolves them.
+            async function pullRequestNumbers() {
+              if (context.eventName !== "merge_group") {
+                return [context.payload.pull_request.number];
+              }
+              const mg = context.payload.merge_group;
+              const { data: comparison } = await github.rest.repos.compareCommits({
+                owner, repo, base: mg.base_sha, head: mg.head_sha,
+              });
+              return comparison.commits.map((c) => {

Review Comment:
   Taken as suggested in `1273f493e`. The asymmetry is the argument — precheck degrades by building more, this degraded by waving a group through — and the `core.setFailed` I added last round only covered the throwing branch, not the empty one. Agreed there is no known trigger with `min_entries_to_merge: 2`; failing closed costs nothing either way.



##########
.github/workflows/backport-approval-check.yml:
##########
@@ -0,0 +1,316 @@
+# 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.
+
+# Blocks the merge while a `release/*` label on the PR has not been approved by
+# that branch's release manager (.github/release-branches.yml).
+#
+# The point is that a merged PR's labels should be a truthful record. A label
+# only nominates a branch, so before this check a manager declined a backport by
+# staying silent — and the label stayed on, which read afterwards as "this
+# shipped in 1.2" when it had not. Here declining is an action: the manager
+# either approves, or removes their label. Since the merge waits for every
+# remaining label to be approved, the labels on a merged PR are exactly the
+# branches Direct Backport Push then sends the fix to.
+#
+# The author's job is to ask the manager for that call, not to make it for them.
+# Editing labels needs triage access, so outside contributors and Renovate or
+# Dependabot PRs cannot remove a label themselves — the failure report says so
+# and names who to ask.
+#
+# `Backport Approvals` is listed in .asf.yaml's required_status_checks, so this
+# job must produce a result on EVERY pull request, or a PR that never runs it
+# waits forever. That is why it is not conditioned on the title, the labels, or
+# the base branch: it always runs and reports success when there is nothing to
+# approve. Merge groups are re-evaluated rather than waved through, because a
+# queued PR's own checks are no longer consulted once it is queued; a group
+# whose PRs cannot be resolved fails closed rather than passing unchecked. Do
+# not rename the job — its display name is the required context.
+
+name: Backport Approval Check
+
+on:
+  pull_request:
+    types:
+      - opened
+      - reopened
+      - synchronize
+      - labeled
+      - unlabeled
+      # Retargeting arrives as `edited`, and the verdict depends on the base
+      # branch: a backport PR into release/* has nothing to approve, the same
+      # PR moved onto main does.
+      - edited
+  pull_request_review:
+    types:
+      - submitted
+      - dismissed
+  merge_group:
+
+# Read-only: this job never writes to the PR, and `pull_request_review` runs
+# with the base repository's token even for fork PRs.
+permissions:
+  contents: read
+  pull-requests: read
+
+concurrency:
+  group: backport-approvals-${{ github.event.pull_request.number || github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  backport-approvals:
+    # Do not rename — this display name is the required status check context
+    # referenced in .asf.yaml.
+    name: Backport Approvals
+    runs-on: ubuntu-latest
+    steps:
+      # The PR's own head (or the queued group's), so the config is the one that
+      # will govern this change once it merges. Checking out the base would not
+      # be a security boundary anyway: on `pull_request` the workflow definition
+      # itself comes from the PR. What bounds this is the event — a fork gets a
+      # read-only token and no secrets, and nothing here writes to the PR.
+      - name: Checkout
+        uses: actions/checkout@v7
+        with:
+          ref: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }}
+          persist-credentials: false
+
+      - name: Read release branches
+        id: targets
+        run: |
+          entries=$(python3 .github/scripts/release_branches.py .github/release-branches.yml)
+          echo "entries=${entries}" >> "$GITHUB_OUTPUT"
+          echo "Release branch targets: ${entries}"
+
+      - name: Check release manager approvals
+        uses: actions/github-script@v9
+        env:
+          ENTRIES: ${{ steps.targets.outputs.entries }}
+        with:
+          script: |
+            const { owner, repo } = context.repo;
+            const managers = new Map(
+              JSON.parse(process.env.ENTRIES || "[]").map((e) => [
+                e.branch,
+                e.manager || "",
+              ])
+            );
+
+            // A merge group carries several PRs and its commits are the squash
+            // merges, so the number is parsed out of each subject — the same way
+            // precheck.yml resolves them.
+            async function pullRequestNumbers() {
+              if (context.eventName !== "merge_group") {
+                return [context.payload.pull_request.number];
+              }
+              const mg = context.payload.merge_group;
+              const { data: comparison } = await github.rest.repos.compareCommits({
+                owner, repo, base: mg.base_sha, head: mg.head_sha,
+              });
+              return comparison.commits.map((c) => {
+                const m = c.commit.message.split("\n", 1)[0].match(/\(#(\d+)\)\s*$/);
+                if (!m) throw new Error(`no PR number in the message of ${c.sha}`);
+                return Number(m[1]);
+              });
+            }
+
+            // Latest review state per login. COMMENTED never changes an approval;
+            // a later CHANGES_REQUESTED or DISMISSED revokes one. listReviews is
+            // documented to return reviews chronologically, so the last state
+            // recorded for a login is the one that counts. `null` means the list
+            // could not be read at all — kept distinct from an empty list, since
+            // "we did not look" must never be reported as "nobody approved".
+            async function reviewStates(number) {
+              try {
+                const reviews = await github.paginate(github.rest.pulls.listReviews, {
+                  owner, repo, pull_number: number, per_page: 100,
+                });
+                const states = new Map();
+                for (const review of reviews) {
+                  const login = review.user?.login;
+                  if (!login || review.state === "COMMENTED") continue;
+                  states.set(login.toLowerCase(), review.state);
+                }
+                return states;
+              } catch (e) {
+                core.warning(
+                  `listReviews for #${number} failed (${e.status ?? "?"}): ${e.message}`
+                );
+                return null;
+              }
+            }
+
+            // Managers gate their own branch and nothing else, so approvals
+            // compose: an approval from the v1.2 manager alone clears v1.2 and
+            // leaves v1.3 blocked.
+            function decide(targets, author, states) {
+              const authorLogin = (author || "").toLowerCase();
+              const cleared = [];
+              const blocked = [];
+              for (const target of targets) {
+                // release-branches.yml is the authorization source, so a label
+                // naming a branch it does not list has nobody who could approve
+                // it. That differs from an entry that deliberately omits
+                // `manager`, and the difference is reachable: retiring a branch
+                // means dropping its entry while its label lives on.
+                if (!managers.has(target)) {
+                  blocked.push({ target, manager: "", state: "UNCONFIGURED" });
+                  continue;
+                }
+                const manager = managers.get(target);
+                if (!manager) {
+                  cleared.push({ target, note: "no release manager configured for this branch" });
+                  continue;
+                }
+                // GitHub does not let anyone approve their own PR, so a manager
+                // who wrote the fix counts as having signed off. Logins are
+                // case-insensitive while `manager` is typed by hand, so fold both.
+                if (manager.toLowerCase() === authorLogin) {
+                  cleared.push({ target, note: `@${manager} is the author of this PR` });
+                  continue;
+                }
+                const state = states ? states.get(manager.toLowerCase()) : "UNKNOWN";
+                if (state === "APPROVED") {
+                  cleared.push({ target, note: `approved by @${manager}` });
+                } else {
+                  blocked.push({ target, manager, state: state || "NONE" });
+                }
+              }
+              return { cleared, blocked };
+            }
+
+            // Say only what the state proves. A dismissal lands on DISMISSED
+            // whatever the review was — GitHub dismisses a blocking
+            // CHANGES_REQUESTED as readily as it clears a stale approval — so
+            // naming it an approval would put a guess in the manager's mouth.
+            function reason(e) {
+              if (e.state === "VETOED") {
+                return "`no-backport-needed` says this fix reaches no release " +
+                  "branch, so this label contradicts it and would be left on a " +
+                  "merged PR promising a backport nobody performs — remove the " +
+                  "label, or remove `no-backport-needed`";
+              }
+              if (e.state === "UNCONFIGURED") {
+                return "this branch is not listed in .github/release-branches.yml, " +
+                  "so no release manager governs it — drop the label, or add the " +
+                  "branch back to that file";
+              }
+              if (e.state === "DISMISSED") {
+                return `@${e.manager}'s review was dismissed, so no approval stands`;
+              }
+              if (e.state === "CHANGES_REQUESTED") {
+                return `@${e.manager} requested changes and has not approved since`;
+              }
+              if (e.state === "UNKNOWN") {
+                return `this PR's reviews could not be read, so @${e.manager}'s ` +
+                  `approval could not be confirmed`;
+              }
+              return `needs an approving review from @${e.manager}`;
+            }
+
+            let numbers;
+            try {
+              numbers = await pullRequestNumbers();
+            } catch (e) {
+              // Fail closed. Only reachable for a merge group whose commits
+              // cannot be mapped back to PRs, and a group whose approvals
+              // cannot be read is not a group this can vouch for — passing it
+              // would leave the queue ungated in exactly the window this job
+              // exists to cover. Ejecting the group is recoverable: its PRs
+              // re-queue, and each still holds its own passing check.
+              core.setFailed(
+                `Could not resolve the pull requests in this merge group ` +
+                `(${e.message}). Refusing to pass a check that could not be ` +
+                `computed.`
+              );
+              return;
+            }
+
+            const lines = [];
+            let failed = false;
+
+            for (const number of numbers) {
+              const { data: pr } = await github.rest.pulls.get({
+                owner, repo, pull_number: number,
+              });
+              const labels = (pr.labels || []).map((l) => l.name);
+              const releaseLabels = [...new Set(
+                labels.filter((n) => /^release\/.+$/.test(n))
+              )].sort();
+              // A PR already targeting a release branch is itself a backport and
+              // is not backported onward, so there is nothing here to approve.
+              const intoMain = pr.base.ref === "main";
+              // `no-backport-needed` says the fix reaches no release branch, but
+              // nothing removes the labels it overrides — and precheck documents
+              // adding it mid-review, by which point the auto-labeler has already
+              // applied them. Merging in that state leaves a label promising a
+              // backport the push will skip: the false record this check exists
+              // to prevent. So the contradiction is reported rather than settled
+              // silently in the veto's favour.
+              const vetoed = labels.includes("no-backport-needed");
+              const targets = intoMain && !vetoed ? releaseLabels : [];
+              const contradictions =
+                intoMain && vetoed
+                  ? releaseLabels.map((target) => ({
+                      target, manager: "", state: "VETOED",
+                    }))
+                  : [];
+
+              if (numbers.length > 1) lines.push(`### PR #${number}`, "");
+              if (targets.length === 0 && contradictions.length === 0) {
+                lines.push("No `release/*` labels — nothing to approve.", "");

Review Comment:
   Fixed in `1273f493e` — it now distinguishes the two, and says a PR based on a release branch is itself a backport and is not backported onward.



##########
AGENTS.md:
##########
@@ -258,5 +258,9 @@ diff -> pr-labeler -> labels on PR -> required-checks maps labels to stacks -> C
   suspect breaks the frontend)? **Add the relevant label manually**.
 - Empty stack union (docs-only / dev-only / `dependencies` / `feature` /
   `fix` / `refactor` / `release/*` only) skips every build stack on purpose.
-- `release/*` labels select backport targets; removing one cancels that
-  backport.
+- `release/*` labels nominate backport targets. A nominated target is
+  backported only once that branch's release manager — listed in
+  [`.github/release-branches.yml`](.github/release-branches.yml) — approves the
+  PR, and the required `Backport Approvals` check blocks the merge until every
+  label on the PR is approved. A manager declines by removing their label, so

Review Comment:
   Taken as suggested in `1273f493e`.



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ci: block the merge until each release/* label has its manager's approval [texera]

Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on code in PR #8096:
URL: https://github.com/apache/texera/pull/8096#discussion_r3923287218


##########
.github/workflows/backport-approval-check.yml:
##########
@@ -0,0 +1,340 @@
+# 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.
+
+# Blocks the merge while a `release/*` label on the PR has not been approved by
+# that branch's release manager (.github/release-branches.yml).
+#
+# The point is that a merged PR's labels should be a truthful record. A label
+# only nominates a branch, so before this check a manager declined a backport by
+# staying silent — and the label stayed on, which read afterwards as "this
+# shipped in 1.2" when it had not. Here declining is an action: the manager
+# either approves, or removes their label. Since the merge waits for every
+# remaining label to be approved, the labels on a merged PR are exactly the
+# branches Direct Backport Push then sends the fix to.
+#
+# The author's job is to ask the manager for that call, not to make it for them.
+# Editing labels needs triage access, so outside contributors and Renovate or
+# Dependabot PRs cannot remove a label themselves — the failure report says so
+# and names who to ask.
+#
+# `Backport Approvals` is a required status check on the default branch
+# (.asf.yaml), so this job must produce a result on every pull request into
+# `main`, or a PR that never runs it waits forever. That is why it is not
+# conditioned on the title or the labels. It is not conditioned on the base
+# branch either, for a different reason: a PR already targeting a release
+# branch is itself a backport, so the check reports success there.
+# Merge groups are re-evaluated rather than waved through, because a
+# queued PR's own checks are no longer consulted once it is queued; a group
+# whose PRs cannot be resolved fails closed rather than passing unchecked. Do
+# not rename the job — its display name is the required context.
+
+name: Backport Approval Check
+
+on:
+  pull_request:
+    types:
+      - opened
+      - reopened
+      - synchronize
+      - labeled
+      - unlabeled
+      # Retargeting arrives as `edited`, and the verdict depends on the base
+      # branch: a backport PR into release/* has nothing to approve, the same
+      # PR moved onto main does.
+      - edited
+  pull_request_review:
+    types:
+      - submitted
+      - dismissed
+  merge_group:
+
+# Read-only: this job never writes to the PR, and `pull_request_review` runs
+# with the base repository's token even for fork PRs.
+permissions:
+  contents: read
+  pull-requests: read
+
+concurrency:
+  group: backport-approvals-${{ github.event.pull_request.number || github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  backport-approvals:
+    # Do not rename — this display name is the required status check context
+    # referenced in .asf.yaml.
+    name: Backport Approvals
+    runs-on: ubuntu-latest
+    steps:
+      # The default branch, not anything the pull request points at. Neither
+      # release-branches.yml nor its parser existed before #6941, and both the
+      # head and `base.sha` can predate it: `base.sha` is main's tip at the PR's
+      # last synchronize, not now, which is stale for 33 of the open PRs into
+      # main. Either would fail the `run:` step below with a file-not-found and
+      # turn this required check red with nothing the author could do about it —
+      # backport-auto-label.yml pins `base.sha` and has been failing exactly that

Review Comment:
   This sentence is right, and it is also the finding. `backport-auto-label.yml:78` still reads `base.sha` and runs the same parser at `:84` — twelve failed runs, 2026-07-28 to 2026-08-11.
   
   It matters more after this PR than before it. A labeler that dies applies no `release/*` label, so this check reports "nothing to approve" and passes. The fix is then silently never backported — the same false record the check exists to prevent, arriving through the labeler instead.
   
   The repair is the one-liner you just applied here. `:71-74` pins the base because `pull_request_target` has write permissions; main's tip is trusted too, and `:68` already gates the job on `base.ref == 'main'`:
   
   ```yaml
             ref: ${{ github.event.repository.default_branch }}
   ```
   
   That line is outside a diff hunk, which is why this is anchored here.



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ci: block the merge until each release/* label has its manager's approval [texera]

Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on code in PR #8096:
URL: https://github.com/apache/texera/pull/8096#discussion_r3923263571


##########
.github/workflows/backport-approval-check.yml:
##########
@@ -0,0 +1,316 @@
+# 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.
+
+# Blocks the merge while a `release/*` label on the PR has not been approved by
+# that branch's release manager (.github/release-branches.yml).
+#
+# The point is that a merged PR's labels should be a truthful record. A label
+# only nominates a branch, so before this check a manager declined a backport by
+# staying silent — and the label stayed on, which read afterwards as "this
+# shipped in 1.2" when it had not. Here declining is an action: the manager
+# either approves, or removes their label. Since the merge waits for every
+# remaining label to be approved, the labels on a merged PR are exactly the
+# branches Direct Backport Push then sends the fix to.
+#
+# The author's job is to ask the manager for that call, not to make it for them.
+# Editing labels needs triage access, so outside contributors and Renovate or
+# Dependabot PRs cannot remove a label themselves — the failure report says so
+# and names who to ask.
+#
+# `Backport Approvals` is listed in .asf.yaml's required_status_checks, so this
+# job must produce a result on EVERY pull request, or a PR that never runs it
+# waits forever. That is why it is not conditioned on the title, the labels, or
+# the base branch: it always runs and reports success when there is nothing to
+# approve. Merge groups are re-evaluated rather than waved through, because a
+# queued PR's own checks are no longer consulted once it is queued; a group
+# whose PRs cannot be resolved fails closed rather than passing unchecked. Do
+# not rename the job — its display name is the required context.
+
+name: Backport Approval Check
+
+on:
+  pull_request:
+    types:
+      - opened
+      - reopened
+      - synchronize
+      - labeled
+      - unlabeled
+      # Retargeting arrives as `edited`, and the verdict depends on the base
+      # branch: a backport PR into release/* has nothing to approve, the same
+      # PR moved onto main does.
+      - edited
+  pull_request_review:
+    types:
+      - submitted
+      - dismissed
+  merge_group:
+
+# Read-only: this job never writes to the PR, and `pull_request_review` runs
+# with the base repository's token even for fork PRs.
+permissions:
+  contents: read
+  pull-requests: read
+
+concurrency:
+  group: backport-approvals-${{ github.event.pull_request.number || github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  backport-approvals:
+    # Do not rename — this display name is the required status check context
+    # referenced in .asf.yaml.
+    name: Backport Approvals
+    runs-on: ubuntu-latest
+    steps:
+      # The PR's own head (or the queued group's), so the config is the one that
+      # will govern this change once it merges. Checking out the base would not
+      # be a security boundary anyway: on `pull_request` the workflow definition
+      # itself comes from the PR. What bounds this is the event — a fork gets a
+      # read-only token and no secrets, and nothing here writes to the PR.
+      - name: Checkout
+        uses: actions/checkout@v7
+        with:
+          ref: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }}

Review Comment:
   Verified fixed in `4bdfa6638`: `:99` now reads `ref: ${{ github.event.repository.default_branch }}`, so the config comes from a ref that does not derive from the pull request at all. Both reachability paths this thread and its child covered are closed — the stale `base.sha` and the `release/v1.1`/`v1.2` base. Closing as the parent.



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ci: block the merge until each release/* label has its manager's approval [texera]

Posted by "mengw15 (via GitHub)" <gi...@apache.org>.
mengw15 commented on PR #8096:
URL: https://github.com/apache/texera/pull/8096#issuecomment-5519792461

   Thanks — all four must-fix items are addressed in `77d573c1a`, each verified before fixing rather than taken on the description. Replies are on the two inline threads; the other three summary items:
   
   **Simplifications — `direct-backport-push.yml:41-42`**: no longer applicable. That file was dropped from this PR before your review: gating post-merge as well was considered and removed, because in the one window it could still cover — an approval dismissed after the merge group went green — refusing the push leaves the PR merged with a `release/v1.2` label and nothing on v1.2, which is the misleading record this change exists to remove. The diff is six files now and `skipped_entries` does not appear in it.
   
   **Conventions — no linked proof run**: added to the description. https://github.com/apache/texera/actions/runs/33594961258 is `Backport Approvals` passing on this PR, reporting "No `release/*` labels — nothing to approve" — which is also the case that must never block, since the context is required on every PR. The harness that sliced JS out of the YAML is gone with the shared script; `pulls.listReviews` pagination does still first run in production, and the description says so.
   
   **Conventions — the `declined` and files-absent `skipped` rows**: fixed. Both now say the branch's release manager has to approve before the PR can merge, rather than implying the label alone causes the backport. The `actively-supporting` paragraph also now says that no review is requested for an inactive branch, so whoever adds its label by hand should ping the manager themselves — otherwise the merge blocks on someone who was never told.
   
   One loose end I could not act on: the summary opens with "4 must-fix · 3 advisory · **2 polish**" and closes with "Polish: 2 quick touch-ups (see the summary)", but the four sections list exactly the seven must-fix and advisory items and no polish ones. If those two were meant to be there, could you paste them?


-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ci: block the merge until each release/* label has its manager's approval [texera]

Posted by "mengw15 (via GitHub)" <gi...@apache.org>.
mengw15 commented on code in PR #8096:
URL: https://github.com/apache/texera/pull/8096#discussion_r3924320815


##########
.github/workflows/backport-approval-check.yml:
##########
@@ -0,0 +1,318 @@
+# 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.
+
+# Blocks the merge while a `release/*` label on the PR is not approved by that
+# branch's release manager (.github/release-branches.yml).
+#
+# A label only nominates a branch. Before this, a manager declined by staying
+# silent and the label stayed on, so a merged PR claimed a backport that never
+# happened. Declining is now an action — approve, or remove the label — and the
+# merge waits for every remaining label, so a merged PR's labels are the
+# branches it reached.
+#
+# `Backport Approvals` is a required check on the default branch (.asf.yaml), so
+# this must report on every PR into `main` or one that never runs it waits
+# forever: hence no condition on title, labels, or base. A PR into a release
+# branch is itself a backport and reports success. Merge groups are
+# re-evaluated rather than waved through, and one whose PRs cannot be resolved
+# fails closed. Do not rename the job — its name is the required context.
+
+name: Backport Approval Check
+
+on:
+  pull_request:
+    types:
+      - opened
+      - reopened
+      - synchronize
+      - labeled
+      - unlabeled
+      # Retargeting arrives as `edited`, and the verdict depends on the base
+      # branch: a backport PR into release/* has nothing to approve, the same
+      # PR moved onto main does.
+      - edited
+  pull_request_review:
+    types:
+      - submitted
+      - dismissed
+  merge_group:
+
+# Read-only: this job never writes to the PR, and `pull_request_review` runs
+# with the base repository's token even for fork PRs.
+permissions:
+  contents: read
+  pull-requests: read
+
+concurrency:
+  group: backport-approvals-${{ github.event.pull_request.number || github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  backport-approvals:
+    # Do not rename — this display name is the required status check context
+    # referenced in .asf.yaml.
+    name: Backport Approvals
+    runs-on: ubuntu-latest
+    steps:
+      # The default branch, not the PR's head or base. Neither predates #6941,
+      # which added release-branches.yml — and `base.sha` is main's tip at the
+      # PR's last synchronize rather than now, stale for 33 of the open PRs into
+      # main. Either would fail the step below with a file-not-found and turn
+      # this required check red unclearably; backport-auto-label.yml pinned
+      # `base.sha` and failed that way 20 times in production. Reading main also
+      # lets a PR retargeted onto a release branch, where the config is absent,
+      # reach the report instead of dying before it.
+      #
+      # Direct Backport Push reads main too, so both consumers judge a backport
+      # by the same config. A PR editing that config is judged by the pre-edit
+      # copy; those are `ci:`-typed and carry no `release/*` labels.

Review Comment:
   Applied verbatim in f4a8a9f76 — both sentences were mine, from last round's tightening. The labeler repair is now in the description too.



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ci: block the merge until each release/* label has its manager's approval [texera]

Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on code in PR #8096:
URL: https://github.com/apache/texera/pull/8096#discussion_r3922361837


##########
.github/workflows/backport-approval-check.yml:
##########
@@ -0,0 +1,334 @@
+# 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.
+
+# Blocks the merge while a `release/*` label on the PR has not been approved by
+# that branch's release manager (.github/release-branches.yml).
+#
+# The point is that a merged PR's labels should be a truthful record. A label
+# only nominates a branch, so before this check a manager declined a backport by
+# staying silent — and the label stayed on, which read afterwards as "this
+# shipped in 1.2" when it had not. Here declining is an action: the manager
+# either approves, or removes their label. Since the merge waits for every
+# remaining label to be approved, the labels on a merged PR are exactly the
+# branches Direct Backport Push then sends the fix to.
+#
+# The author's job is to ask the manager for that call, not to make it for them.
+# Editing labels needs triage access, so outside contributors and Renovate or
+# Dependabot PRs cannot remove a label themselves — the failure report says so
+# and names who to ask.
+#
+# `Backport Approvals` is listed in .asf.yaml's required_status_checks, so this
+# job must produce a result on EVERY pull request, or a PR that never runs it
+# waits forever. That is why it is not conditioned on the title, the labels, or
+# the base branch: it always runs and reports success when there is nothing to
+# approve. Merge groups are re-evaluated rather than waved through, because a
+# queued PR's own checks are no longer consulted once it is queued; a group
+# whose PRs cannot be resolved fails closed rather than passing unchecked. Do
+# not rename the job — its display name is the required context.
+
+name: Backport Approval Check
+
+on:
+  pull_request:
+    types:
+      - opened
+      - reopened
+      - synchronize
+      - labeled
+      - unlabeled
+      # Retargeting arrives as `edited`, and the verdict depends on the base
+      # branch: a backport PR into release/* has nothing to approve, the same
+      # PR moved onto main does.
+      - edited
+  pull_request_review:
+    types:
+      - submitted
+      - dismissed
+  merge_group:
+
+# Read-only: this job never writes to the PR, and `pull_request_review` runs
+# with the base repository's token even for fork PRs.
+permissions:
+  contents: read
+  pull-requests: read
+
+concurrency:
+  group: backport-approvals-${{ github.event.pull_request.number || github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  backport-approvals:
+    # Do not rename — this display name is the required status check context
+    # referenced in .asf.yaml.
+    name: Backport Approvals
+    runs-on: ubuntu-latest
+    steps:
+      # The base, not the PR head: the head can be arbitrarily old, and neither
+      # release-branches.yml nor its parser existed before #6941 — a head from
+      # before that (37 of the open PRs into main as of writing) would fail the
+      # `run:` step below with a file-not-found and turn this required check red
+      # with no way for the author to clear it. The base also keeps this reading
+      # the same config as the two other consumers: backport-auto-label.yml pins
+      # `base.sha`, and Direct Backport Push reads main after the merge.
+      #
+      # The trade-off is that a PR editing release-branches.yml is judged by the
+      # pre-edit config. Those are `ci:`-typed and carry no `release/*` labels,
+      # so there is nothing for the stale config to misjudge.
+      - name: Checkout
+        uses: actions/checkout@v7
+        with:
+          ref: ${{ github.event.pull_request.base.sha || github.event.merge_group.head_sha }}

Review Comment:
   `base.sha` is main's tip at this PR's **last synchronize**, not now. For any PR nobody has pushed to since #6941 landed, it predates `release_branches.py`, so `:99` exits 2 under `bash -eo pipefail`. That is 33 of the 221 open PRs into `main`. On each, the first label or review event turns this required check red with a file-not-found that no approval or unlabel can clear. `backport-auto-label.yml:78` pins the same ref and already fails this way in run 31542186218.
   
   Reading the default branch also closes a second hole. The config 404s on `release/v1.1` and `release/v1.2`, so a retarget onto one of them dies at `:99` before your `:288` message can print. `direct-backport-push.yml:42-45` already reads main this way.
   
   ```suggestion
             ref: ${{ github.event.repository.default_branch }}
   ```



##########
.github/workflows/backport-approval-check.yml:
##########
@@ -0,0 +1,334 @@
+# 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.
+
+# Blocks the merge while a `release/*` label on the PR has not been approved by
+# that branch's release manager (.github/release-branches.yml).
+#
+# The point is that a merged PR's labels should be a truthful record. A label
+# only nominates a branch, so before this check a manager declined a backport by
+# staying silent — and the label stayed on, which read afterwards as "this
+# shipped in 1.2" when it had not. Here declining is an action: the manager
+# either approves, or removes their label. Since the merge waits for every
+# remaining label to be approved, the labels on a merged PR are exactly the
+# branches Direct Backport Push then sends the fix to.
+#
+# The author's job is to ask the manager for that call, not to make it for them.
+# Editing labels needs triage access, so outside contributors and Renovate or
+# Dependabot PRs cannot remove a label themselves — the failure report says so
+# and names who to ask.
+#
+# `Backport Approvals` is listed in .asf.yaml's required_status_checks, so this
+# job must produce a result on EVERY pull request, or a PR that never runs it
+# waits forever. That is why it is not conditioned on the title, the labels, or
+# the base branch: it always runs and reports success when there is nothing to
+# approve. Merge groups are re-evaluated rather than waved through, because a

Review Comment:
   The instruction is right but its stated reason no longer is. Since the context moved into the `~DEFAULT_BRANCH`-only ruleset (`.asf.yaml:122-125`), a PR into `release/*` is not waiting on it. The real reason not to condition on the base is different: there is nothing to approve there.
   
   ```suggestion
   # `Backport Approvals` is a required status check on the default branch
   # (.asf.yaml), so this job must produce a result on every pull request into
   # `main`, or a PR that never runs it waits forever. That is why it is not
   # conditioned on the title or the labels. It is not conditioned on the base
   # branch either, for a different reason: a PR already targeting a release
   # branch is itself a backport, so the check reports success there.
   # Merge groups are re-evaluated rather than waved through, because a
   ```



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ci: block the merge until each release/* label has its manager's approval [texera]

Posted by "mengw15 (via GitHub)" <gi...@apache.org>.
mengw15 commented on code in PR #8096:
URL: https://github.com/apache/texera/pull/8096#discussion_r3922386051


##########
.github/workflows/backport-approval-check.yml:
##########
@@ -0,0 +1,334 @@
+# 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.
+
+# Blocks the merge while a `release/*` label on the PR has not been approved by
+# that branch's release manager (.github/release-branches.yml).
+#
+# The point is that a merged PR's labels should be a truthful record. A label
+# only nominates a branch, so before this check a manager declined a backport by
+# staying silent — and the label stayed on, which read afterwards as "this
+# shipped in 1.2" when it had not. Here declining is an action: the manager
+# either approves, or removes their label. Since the merge waits for every
+# remaining label to be approved, the labels on a merged PR are exactly the
+# branches Direct Backport Push then sends the fix to.
+#
+# The author's job is to ask the manager for that call, not to make it for them.
+# Editing labels needs triage access, so outside contributors and Renovate or
+# Dependabot PRs cannot remove a label themselves — the failure report says so
+# and names who to ask.
+#
+# `Backport Approvals` is listed in .asf.yaml's required_status_checks, so this
+# job must produce a result on EVERY pull request, or a PR that never runs it
+# waits forever. That is why it is not conditioned on the title, the labels, or
+# the base branch: it always runs and reports success when there is nothing to
+# approve. Merge groups are re-evaluated rather than waved through, because a
+# queued PR's own checks are no longer consulted once it is queued; a group
+# whose PRs cannot be resolved fails closed rather than passing unchecked. Do
+# not rename the job — its display name is the required context.
+
+name: Backport Approval Check
+
+on:
+  pull_request:
+    types:
+      - opened
+      - reopened
+      - synchronize
+      - labeled
+      - unlabeled
+      # Retargeting arrives as `edited`, and the verdict depends on the base
+      # branch: a backport PR into release/* has nothing to approve, the same
+      # PR moved onto main does.
+      - edited
+  pull_request_review:
+    types:
+      - submitted
+      - dismissed
+  merge_group:
+
+# Read-only: this job never writes to the PR, and `pull_request_review` runs
+# with the base repository's token even for fork PRs.
+permissions:
+  contents: read
+  pull-requests: read
+
+concurrency:
+  group: backport-approvals-${{ github.event.pull_request.number || github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  backport-approvals:
+    # Do not rename — this display name is the required status check context
+    # referenced in .asf.yaml.
+    name: Backport Approvals
+    runs-on: ubuntu-latest
+    steps:
+      # The base, not the PR head: the head can be arbitrarily old, and neither
+      # release-branches.yml nor its parser existed before #6941 — a head from
+      # before that (37 of the open PRs into main as of writing) would fail the
+      # `run:` step below with a file-not-found and turn this required check red
+      # with no way for the author to clear it. The base also keeps this reading
+      # the same config as the two other consumers: backport-auto-label.yml pins
+      # `base.sha`, and Direct Backport Push reads main after the merge.
+      #
+      # The trade-off is that a PR editing release-branches.yml is judged by the
+      # pre-edit config. Those are `ci:`-typed and carry no `release/*` labels,
+      # so there is nothing for the stale config to misjudge.
+      - name: Checkout
+        uses: actions/checkout@v7
+        with:
+          ref: ${{ github.event.pull_request.base.sha || github.event.merge_group.head_sha }}

Review Comment:
   Verified before taking it, and it holds: #6009 has a `base.sha` dated 2026-07-10, #6436 2026-07-18, #6915 2026-07-26 — all 404 on `release_branches.py`, all still active. Fixed in `4bdfa6638` with your suggestion.
   
   Worth naming what this pattern was: I moved off the base last round on a security argument, you moved me back on a staleness argument, and both of us were reasoning about which revision was *trustworthy* rather than which one *exists*. The default branch is the only ref that is always both, and Direct Backport Push was already reading it — the answer was sitting in the sibling the whole time.



##########
.github/workflows/backport-approval-check.yml:
##########
@@ -0,0 +1,334 @@
+# 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.
+
+# Blocks the merge while a `release/*` label on the PR has not been approved by
+# that branch's release manager (.github/release-branches.yml).
+#
+# The point is that a merged PR's labels should be a truthful record. A label
+# only nominates a branch, so before this check a manager declined a backport by
+# staying silent — and the label stayed on, which read afterwards as "this
+# shipped in 1.2" when it had not. Here declining is an action: the manager
+# either approves, or removes their label. Since the merge waits for every
+# remaining label to be approved, the labels on a merged PR are exactly the
+# branches Direct Backport Push then sends the fix to.
+#
+# The author's job is to ask the manager for that call, not to make it for them.
+# Editing labels needs triage access, so outside contributors and Renovate or
+# Dependabot PRs cannot remove a label themselves — the failure report says so
+# and names who to ask.
+#
+# `Backport Approvals` is listed in .asf.yaml's required_status_checks, so this
+# job must produce a result on EVERY pull request, or a PR that never runs it
+# waits forever. That is why it is not conditioned on the title, the labels, or
+# the base branch: it always runs and reports success when there is nothing to
+# approve. Merge groups are re-evaluated rather than waved through, because a

Review Comment:
   Taken as suggested in `4bdfa6638` — the reason had gone stale with the ruleset move.



##########
.github/workflows/backport-approval-check.yml:
##########
@@ -0,0 +1,316 @@
+# 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.
+
+# Blocks the merge while a `release/*` label on the PR has not been approved by
+# that branch's release manager (.github/release-branches.yml).
+#
+# The point is that a merged PR's labels should be a truthful record. A label
+# only nominates a branch, so before this check a manager declined a backport by
+# staying silent — and the label stayed on, which read afterwards as "this
+# shipped in 1.2" when it had not. Here declining is an action: the manager
+# either approves, or removes their label. Since the merge waits for every
+# remaining label to be approved, the labels on a merged PR are exactly the
+# branches Direct Backport Push then sends the fix to.
+#
+# The author's job is to ask the manager for that call, not to make it for them.
+# Editing labels needs triage access, so outside contributors and Renovate or
+# Dependabot PRs cannot remove a label themselves — the failure report says so
+# and names who to ask.
+#
+# `Backport Approvals` is listed in .asf.yaml's required_status_checks, so this
+# job must produce a result on EVERY pull request, or a PR that never runs it
+# waits forever. That is why it is not conditioned on the title, the labels, or
+# the base branch: it always runs and reports success when there is nothing to
+# approve. Merge groups are re-evaluated rather than waved through, because a
+# queued PR's own checks are no longer consulted once it is queued; a group
+# whose PRs cannot be resolved fails closed rather than passing unchecked. Do
+# not rename the job — its display name is the required context.
+
+name: Backport Approval Check
+
+on:
+  pull_request:
+    types:
+      - opened
+      - reopened
+      - synchronize
+      - labeled
+      - unlabeled
+      # Retargeting arrives as `edited`, and the verdict depends on the base
+      # branch: a backport PR into release/* has nothing to approve, the same
+      # PR moved onto main does.
+      - edited
+  pull_request_review:
+    types:
+      - submitted
+      - dismissed
+  merge_group:
+
+# Read-only: this job never writes to the PR, and `pull_request_review` runs
+# with the base repository's token even for fork PRs.
+permissions:
+  contents: read
+  pull-requests: read
+
+concurrency:
+  group: backport-approvals-${{ github.event.pull_request.number || github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  backport-approvals:
+    # Do not rename — this display name is the required status check context
+    # referenced in .asf.yaml.
+    name: Backport Approvals
+    runs-on: ubuntu-latest
+    steps:
+      # The PR's own head (or the queued group's), so the config is the one that
+      # will govern this change once it merges. Checking out the base would not
+      # be a security boundary anyway: on `pull_request` the workflow definition
+      # itself comes from the PR. What bounds this is the event — a fork gets a
+      # read-only token and no secrets, and nothing here writes to the PR.
+      - name: Checkout
+        uses: actions/checkout@v7
+        with:
+          ref: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }}
+          persist-credentials: false
+
+      - name: Read release branches
+        id: targets
+        run: |
+          entries=$(python3 .github/scripts/release_branches.py .github/release-branches.yml)
+          echo "entries=${entries}" >> "$GITHUB_OUTPUT"
+          echo "Release branch targets: ${entries}"
+
+      - name: Check release manager approvals
+        uses: actions/github-script@v9
+        env:
+          ENTRIES: ${{ steps.targets.outputs.entries }}
+        with:
+          script: |
+            const { owner, repo } = context.repo;
+            const managers = new Map(
+              JSON.parse(process.env.ENTRIES || "[]").map((e) => [
+                e.branch,
+                e.manager || "",
+              ])
+            );
+
+            // A merge group carries several PRs and its commits are the squash
+            // merges, so the number is parsed out of each subject — the same way
+            // precheck.yml resolves them.
+            async function pullRequestNumbers() {
+              if (context.eventName !== "merge_group") {
+                return [context.payload.pull_request.number];
+              }
+              const mg = context.payload.merge_group;
+              const { data: comparison } = await github.rest.repos.compareCommits({
+                owner, repo, base: mg.base_sha, head: mg.head_sha,
+              });
+              return comparison.commits.map((c) => {
+                const m = c.commit.message.split("\n", 1)[0].match(/\(#(\d+)\)\s*$/);
+                if (!m) throw new Error(`no PR number in the message of ${c.sha}`);
+                return Number(m[1]);
+              });
+            }
+
+            // Latest review state per login. COMMENTED never changes an approval;
+            // a later CHANGES_REQUESTED or DISMISSED revokes one. listReviews is
+            // documented to return reviews chronologically, so the last state
+            // recorded for a login is the one that counts. `null` means the list
+            // could not be read at all — kept distinct from an empty list, since
+            // "we did not look" must never be reported as "nobody approved".
+            async function reviewStates(number) {
+              try {
+                const reviews = await github.paginate(github.rest.pulls.listReviews, {
+                  owner, repo, pull_number: number, per_page: 100,
+                });
+                const states = new Map();
+                for (const review of reviews) {
+                  const login = review.user?.login;
+                  if (!login || review.state === "COMMENTED") continue;
+                  states.set(login.toLowerCase(), review.state);
+                }
+                return states;
+              } catch (e) {
+                core.warning(
+                  `listReviews for #${number} failed (${e.status ?? "?"}): ${e.message}`
+                );
+                return null;
+              }
+            }
+
+            // Managers gate their own branch and nothing else, so approvals
+            // compose: an approval from the v1.2 manager alone clears v1.2 and
+            // leaves v1.3 blocked.
+            function decide(targets, author, states) {

Review Comment:
   Appreciated. The blocked path is linked in the description alongside the cleared and no-label ones, so the three states are all evidenced rather than asserted.



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ci: block the merge until each release/* label has its manager's approval [texera]

Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on code in PR #8096:
URL: https://github.com/apache/texera/pull/8096#discussion_r3922321992


##########
.github/workflows/backport-approval-check.yml:
##########
@@ -0,0 +1,316 @@
+# 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.
+
+# Blocks the merge while a `release/*` label on the PR has not been approved by
+# that branch's release manager (.github/release-branches.yml).
+#
+# The point is that a merged PR's labels should be a truthful record. A label
+# only nominates a branch, so before this check a manager declined a backport by
+# staying silent — and the label stayed on, which read afterwards as "this
+# shipped in 1.2" when it had not. Here declining is an action: the manager
+# either approves, or removes their label. Since the merge waits for every
+# remaining label to be approved, the labels on a merged PR are exactly the
+# branches Direct Backport Push then sends the fix to.
+#
+# The author's job is to ask the manager for that call, not to make it for them.
+# Editing labels needs triage access, so outside contributors and Renovate or
+# Dependabot PRs cannot remove a label themselves — the failure report says so
+# and names who to ask.
+#
+# `Backport Approvals` is listed in .asf.yaml's required_status_checks, so this
+# job must produce a result on EVERY pull request, or a PR that never runs it
+# waits forever. That is why it is not conditioned on the title, the labels, or
+# the base branch: it always runs and reports success when there is nothing to
+# approve. Merge groups are re-evaluated rather than waved through, because a
+# queued PR's own checks are no longer consulted once it is queued; a group
+# whose PRs cannot be resolved fails closed rather than passing unchecked. Do
+# not rename the job — its display name is the required context.
+
+name: Backport Approval Check
+
+on:
+  pull_request:
+    types:
+      - opened
+      - reopened
+      - synchronize
+      - labeled
+      - unlabeled
+      # Retargeting arrives as `edited`, and the verdict depends on the base
+      # branch: a backport PR into release/* has nothing to approve, the same
+      # PR moved onto main does.
+      - edited
+  pull_request_review:
+    types:
+      - submitted
+      - dismissed
+  merge_group:
+
+# Read-only: this job never writes to the PR, and `pull_request_review` runs
+# with the base repository's token even for fork PRs.
+permissions:
+  contents: read
+  pull-requests: read
+
+concurrency:
+  group: backport-approvals-${{ github.event.pull_request.number || github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  backport-approvals:
+    # Do not rename — this display name is the required status check context
+    # referenced in .asf.yaml.
+    name: Backport Approvals
+    runs-on: ubuntu-latest
+    steps:
+      # The PR's own head (or the queued group's), so the config is the one that
+      # will govern this change once it merges. Checking out the base would not
+      # be a security boundary anyway: on `pull_request` the workflow definition
+      # itself comes from the PR. What bounds this is the event — a fork gets a
+      # read-only token and no secrets, and nothing here writes to the PR.
+      - name: Checkout
+        uses: actions/checkout@v7
+        with:
+          ref: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }}
+          persist-credentials: false
+
+      - name: Read release branches
+        id: targets
+        run: |
+          entries=$(python3 .github/scripts/release_branches.py .github/release-branches.yml)
+          echo "entries=${entries}" >> "$GITHUB_OUTPUT"
+          echo "Release branch targets: ${entries}"
+
+      - name: Check release manager approvals
+        uses: actions/github-script@v9
+        env:
+          ENTRIES: ${{ steps.targets.outputs.entries }}
+        with:
+          script: |
+            const { owner, repo } = context.repo;
+            const managers = new Map(
+              JSON.parse(process.env.ENTRIES || "[]").map((e) => [
+                e.branch,
+                e.manager || "",
+              ])
+            );
+
+            // A merge group carries several PRs and its commits are the squash
+            // merges, so the number is parsed out of each subject — the same way
+            // precheck.yml resolves them.
+            async function pullRequestNumbers() {
+              if (context.eventName !== "merge_group") {
+                return [context.payload.pull_request.number];
+              }
+              const mg = context.payload.merge_group;
+              const { data: comparison } = await github.rest.repos.compareCommits({
+                owner, repo, base: mg.base_sha, head: mg.head_sha,
+              });
+              return comparison.commits.map((c) => {
+                const m = c.commit.message.split("\n", 1)[0].match(/\(#(\d+)\)\s*$/);
+                if (!m) throw new Error(`no PR number in the message of ${c.sha}`);
+                return Number(m[1]);
+              });
+            }
+
+            // Latest review state per login. COMMENTED never changes an approval;
+            // a later CHANGES_REQUESTED or DISMISSED revokes one. listReviews is
+            // documented to return reviews chronologically, so the last state
+            // recorded for a login is the one that counts. `null` means the list
+            // could not be read at all — kept distinct from an empty list, since
+            // "we did not look" must never be reported as "nobody approved".
+            async function reviewStates(number) {
+              try {
+                const reviews = await github.paginate(github.rest.pulls.listReviews, {
+                  owner, repo, pull_number: number, per_page: 100,
+                });
+                const states = new Map();
+                for (const review of reviews) {
+                  const login = review.user?.login;
+                  if (!login || review.state === "COMMENTED") continue;
+                  states.set(login.toLowerCase(), review.state);
+                }
+                return states;
+              } catch (e) {
+                core.warning(
+                  `listReviews for #${number} failed (${e.status ?? "?"}): ${e.message}`
+                );
+                return null;
+              }
+            }
+
+            // Managers gate their own branch and nothing else, so approvals
+            // compose: an approval from the v1.2 manager alone clears v1.2 and
+            // leaves v1.3 blocked.
+            function decide(targets, author, states) {

Review Comment:
   Keeping it inline is the right call here, and your reasoning is better than my finding was: the benefit really is testability alone, since the other three halves live in files this PR does not touch. Not pursuing it — a four-file consolidation deserves its own change. Thanks for executing the blocked path rather than arguing it; that closes the coverage gap I actually cared about.



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ci: gate each backport on its release manager's approval [texera]

Posted by "mengw15 (via GitHub)" <gi...@apache.org>.
mengw15 commented on code in PR #8096:
URL: https://github.com/apache/texera/pull/8096#discussion_r3885926115


##########
.github/workflows/backport-auto-label.yml:
##########
@@ -205,6 +210,13 @@ jobs:
               for (const entry of entries) {
                 const label = entry.branch;
                 const manager = entry.manager;
+                // Say who has to sign off, so the label is not mistaken for the
+                // decision. A manager who wrote the fix needs no approval —
+                // GitHub does not let anyone approve their own PR.
+                const gate =
+                  manager && manager !== author

Review Comment:
   Fixed in `f7dbbe3dc` — both comparisons, and the suppressed one on line 287, now fold the logins before comparing, matching the gate in direct-backport-push.



##########
.github/workflows/direct-backport-push.yml:
##########
@@ -333,10 +440,81 @@ jobs:
 
             core.info(`Push entries: ${JSON.stringify(pushEntries)}`);
             core.info(`PR entries: ${JSON.stringify(prEntries)}`);
+            core.info(`Skipped entries: ${JSON.stringify(skippedEntries)}`);
             core.setOutput("push_entries", JSON.stringify(pushEntries));
             core.setOutput("pr_entries", JSON.stringify(prEntries));
             core.setOutput("has_push", pushEntries.length > 0 ? "true" : "false");
             core.setOutput("has_pr", prEntries.length > 0 ? "true" : "false");
+            core.setOutput("skipped_entries", JSON.stringify(skippedEntries));
+            core.setOutput("has_skipped", skippedEntries.length > 0 ? "true" : "false");
+
+      # A target held back for want of its release manager's approval leaves no
+      # other trace — no cherry-pick, no draft backport PR, no check — so say so
+      # on the PR itself. One comment per PR, naming the manager whose approval
+      # would have carried the fix across, so a merge that outran the review is
+      # visible instead of silent.
+      - name: Report approval-gated targets
+        if: ${{ steps.discover.outputs.has_skipped == 'true' }}
+        uses: actions/github-script@v9
+        env:
+          SKIPPED: ${{ steps.discover.outputs.skipped_entries }}
+        with:
+          script: |
+            const skipped = JSON.parse(process.env.SKIPPED || "[]");
+            const { owner, repo } = context.repo;
+            const runUrl =
+              `${context.serverUrl}/${owner}/${repo}/actions/runs/${context.runId}`;
+
+            const byPr = new Map();
+            for (const entry of skipped) {
+              const list = byPr.get(entry.pr_number) || [];
+              list.push(entry);
+              byPr.set(entry.pr_number, list);
+            }
+
+            for (const [prNumber, entries] of byPr) {
+              // Why a target was held back decides what the manager does
+              // about it, so name the actual reason instead of a flat "not
+              // approved" — which reads as "you never looked at it" even when
+              // they approved and the approval was later dismissed.
+              const reason = (e) => {
+                if (e.state === "DISMISSED") {
+                  return `@${e.manager} approved, but that approval was dismissed before the merge`;

Review Comment:
   Agreed — `DISMISSED` doesn't record what the review was, and dismissal isn't restricted to approvals. Reworded to "…'s review was dismissed before the merge, so no approval stands", so the comment states only what the state establishes.



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org