Skip to content

Commit aff0214

Browse files
authored
upstreaming: promptly acknowledge command comments (#4997)
1 parent 81986b4 commit aff0214

4 files changed

Lines changed: 60 additions & 5 deletions

File tree

‎.github/workflows/upstreaming-controller.yml‎

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,44 @@ on:
3838
types: [completed]
3939
workflow_dispatch:
4040

41-
concurrency:
42-
group: python-wheels-upstreaming-controller
43-
cancel-in-progress: false
44-
4541
permissions:
4642
contents: read
4743
issues: read
4844

4945
jobs:
46+
# Fast receipt only. This job has no needs and no concurrency group, so a
47+
# queued reconciliation run cannot delay acknowledgement. Command parsing,
48+
# authority checks, rejection feedback and state changes remain in reconcile.
49+
acknowledge-command:
50+
if: github.event_name == 'issue_comment' && github.event.issue.pull_request == null
51+
runs-on: ubuntu-latest
52+
timeout-minutes: 2
53+
permissions:
54+
contents: read
55+
steps:
56+
- uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
57+
id: control-token
58+
with:
59+
client-id: ${{ vars.RISEPROJECT_APP_CLIENT_ID }}
60+
private-key: ${{ secrets.RISEPROJECT_APP_PRIVATE_KEY }}
61+
owner: riseproject-dev
62+
repositories: python-wheels
63+
permission-issues: write
64+
- name: Acknowledge a visible upstreaming command
65+
env:
66+
GH_TOKEN: ${{ steps.control-token.outputs.token }}
67+
COMMENT_ID: ${{ github.event.comment.id }}
68+
COMMENT_BODY: ${{ github.event.comment.body }}
69+
run: |
70+
set -euo pipefail
71+
first=$(printf '%s\n' "$COMMENT_BODY" | awk 'NF { print; exit }')
72+
[[ "$first" == /upstreaming\ * ]] || exit 0
73+
reactions=$(gh api "/repos/$GITHUB_REPOSITORY/issues/comments/$COMMENT_ID/reactions?per_page=100")
74+
jq -e 'any(.[]; .content == "+1" and .user.login == "riseproject-dev[bot]")' \
75+
<<<"$reactions" >/dev/null || \
76+
gh api -X POST "/repos/$GITHUB_REPOSITORY/issues/comments/$COMMENT_ID/reactions" \
77+
-f content='+1' >/dev/null
78+
5079
# Cheap filter: unsupported events, missing labels and comments that are
5180
# not commands never reach the tick.
5281
filter:
@@ -102,6 +131,9 @@ jobs:
102131
needs: filter
103132
runs-on: ubuntu-latest
104133
timeout-minutes: 15
134+
concurrency:
135+
group: python-wheels-upstreaming-controller
136+
cancel-in-progress: false
105137
environment: upstreaming-state
106138
permissions:
107139
contents: read

‎SESSIONLOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@
2626
- Replaced the rejected workflow-glob approach with complete dossier path coverage and natural-language review scope extension: human-relay-backed repairs may add exact changed paths, which trusted publication verifies and persists without requiring command syntax.
2727
- Added an exact-path repair compatibility flag for live contributions whose dossiers predate mandatory path coverage; new dossiers are marked coverage-complete and cannot use the legacy allowance.
2828
- Added trusted post-publication review acknowledgements: every addressed feedback item gets a short App-authored response, inline review threads are resolved after replying, and marker/readback checks make retries idempotent.
29+
- Added a fast ungrouped controller job that idempotently reacts `+1` to visible `/upstreaming` tracking-issue comments while leaving all parsing, authorization and command effects in serialized reconciliation.

‎upstreaming/README.md‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,12 @@ commands** section with the current revision/head prefilled. Entries are never
239239
edited, so user commands and pipeline history remain interleaved chronologically.
240240
A rejected command receives a separate App-authored reply that quotes the exact
241241
command, pings its author, explains the rejection and shows a corrected form when
242-
one is known.
242+
one is known. A separate controller job promptly adds a `+1` reaction when the
243+
first nonblank line of a new or edited tracking-issue comment starts with
244+
`/upstreaming `. This receipt job has no concurrency group, so queued
245+
reconciliation does not delay acknowledgement. The reaction does not parse,
246+
authorize or apply the command; the serialized controller remains the only
247+
command handler.
243248

244249
Post a command as its own comment on the request issue. The issue says which
245250
contribution it applies to, so `contribution=` is optional (if given, it must

‎upstreaming/tests/test_workflow_contracts.py‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,23 @@ def test_controller_chains_every_pipeline_completion_and_has_schedule_fallback(s
176176
self.assertIn("created", triggers["issue_comment"]["types"])
177177
self.assertIn("github.event_name == 'workflow_run'", controller["jobs"]["filter"]["if"])
178178

179+
def test_command_acknowledgement_is_fast_idempotent_and_not_serialized(self):
180+
controller = yaml.safe_load((WF / "upstreaming-controller.yml").read_text())
181+
self.assertNotIn("concurrency", controller)
182+
ack = controller["jobs"]["acknowledge-command"]
183+
self.assertNotIn("needs", ack)
184+
self.assertNotIn("concurrency", ack)
185+
self.assertEqual(ack["if"],
186+
"github.event_name == 'issue_comment' && github.event.issue.pull_request == null")
187+
script = ack["steps"][-1]["run"]
188+
self.assertIn("awk 'NF { print; exit }'", script)
189+
self.assertIn("reactions?per_page=100", script)
190+
self.assertIn('riseproject-dev[bot]', script)
191+
self.assertIn("-f content='+1'", script)
192+
reconcile = controller["jobs"]["reconcile"]
193+
self.assertEqual(reconcile["concurrency"]["group"], "python-wheels-upstreaming-controller")
194+
self.assertFalse(reconcile["concurrency"]["cancel-in-progress"])
195+
179196
def test_worker_forbids_unrelated_fork_ci_debug_changes(self):
180197
worker = source("upstreaming-worker")
181198
self.assertNotIn("github", worker["tools"])

0 commit comments

Comments
 (0)