From 2eaccf4554c4d36517eb26746d460787e5f49f5e Mon Sep 17 00:00:00 2001 From: Koji Wakayama Date: Sat, 5 Dec 2026 21:03:57 +0100 Subject: [PATCH 1/5] ci: hold on merge-first notes and dependencies after punctuation or line breaks --- .github/workflows/pull-request-auto-merge.yml | 12 +++++++++--- .../ci/pull-request-auto-merge-workflow.test.ts | 6 ++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pull-request-auto-merge.yml b/.github/workflows/pull-request-auto-merge.yml index c420de94ca..2aa720a0a8 100644 --- a/.github/workflows/pull-request-auto-merge.yml +++ b/.github/workflows/pull-request-auto-merge.yml @@ -84,11 +84,17 @@ jobs: # veryfront-api#45", a /pull/ link). Ordinary prose such as "depends on # zod" or "waits for the worker" is not one. ref='(pr |pull request )?(https://github\.com/)?(([a-z0-9_.-]+/)?[a-z0-9_.-]+)?(#|/pull/)[0-9]+' - hold="(do not|don.t) (merge|queue)|merge order|required pair|on hold|hold (until|off|for now)|^[[:space:]]*hold[.!:]?[[:space:]]*$" + hold="(do not|don.t) (merge|queue)|merge order|required pair|on hold|hold (until|off|for now)|merge[sd]? first|^[[:space:]]*hold[.!:]?[[:space:]]*$" dependency="(merged?|merges|lands?|landed) (after|before|with)|blocked (by|on)|depends on|dependent on|wait(s|ing)? (for|on|until)" + # Punctuation, Markdown or a line break may sit between the phrase and + # the reference ("Depends on: #12", "Blocked by [#12](...)"). + sep='[[:space:]:*_([>-]*' + body="$(jq -r '.body // ""' "$RUNNER_TEMP/pr.json")" held_by_body=false - if jq -r '.body // ""' "$RUNNER_TEMP/pr.json" \ - | grep -qiE "($hold)|($dependency) $ref"; then + # Here-strings, not pipes: under pipefail an early grep -q exit could + # fail the writer and skip a hold. + if grep -qiE "$hold" <<< "$body" \ + || grep -qiE "($dependency)$sep$ref" <<< "${body//[$'\r\n']/ }"; then held_by_body=true fi diff --git a/tests/integration/ci/pull-request-auto-merge-workflow.test.ts b/tests/integration/ci/pull-request-auto-merge-workflow.test.ts index be4bada296..587e930325 100644 --- a/tests/integration/ci/pull-request-auto-merge-workflow.test.ts +++ b/tests/integration/ci/pull-request-auto-merge-workflow.test.ts @@ -179,6 +179,12 @@ describe("pull request auto-merge workflow", () => { ["a do-not-merge note in the description", { body: "Do not merge yet." }], ["a cross-repository dependency", { body: "Depends on veryfront/veryfront-api#8005." }], ["a dependency on a sibling repository", { body: "Merges after veryfront-api#8005." }], + ["a dependency after a colon", { body: "Depends on: #42" }], + ["a markdown link dependency", { + body: "Depends on [#123](https://github.com/veryfront/veryfront-api/pull/123)", + }], + ["a wrapped dependency", { body: "This depends on\r\n#123 landing." }], + ["a merge-first note", { body: "This must merge first." }], [ "a dependency given as a link", { body: "Blocked by https://github.com/veryfront/veryfront-api/pull/8005" }, From 37c26ef85eafd4a0c8c78c20e7730559979428bf Mon Sep 17 00:00:00 2001 From: Koji Wakayama Date: Sat, 5 Dec 2026 21:31:58 +0100 Subject: [PATCH 2/5] ci: hold on imperative hold sentences and dependencies in inline code or after a dash --- .github/workflows/pull-request-auto-merge.yml | 10 ++++++---- .../ci/pull-request-auto-merge-workflow.test.ts | 13 ++++++++++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pull-request-auto-merge.yml b/.github/workflows/pull-request-auto-merge.yml index 2aa720a0a8..b2d6214512 100644 --- a/.github/workflows/pull-request-auto-merge.yml +++ b/.github/workflows/pull-request-auto-merge.yml @@ -84,11 +84,13 @@ jobs: # veryfront-api#45", a /pull/ link). Ordinary prose such as "depends on # zod" or "waits for the worker" is not one. ref='(pr |pull request )?(https://github\.com/)?(([a-z0-9_.-]+/)?[a-z0-9_.-]+)?(#|/pull/)[0-9]+' - hold="(do not|don.t) (merge|queue)|merge order|required pair|on hold|hold (until|off|for now)|merge[sd]? first|^[[:space:]]*hold[.!:]?[[:space:]]*$" + hold="(do not|don.t) (merge|queue)|merge order|required pair|on hold|please hold|hold (until|off|for|it|this|the (pr|pull request|change))\b|merge[sd]? first|^[[:space:]]*hold[.!:]?[[:space:]]*$" dependency="(merged?|merges|lands?|landed) (after|before|with)|blocked (by|on)|depends on|dependent on|wait(s|ing)? (for|on|until)" - # Punctuation, Markdown or a line break may sit between the phrase and - # the reference ("Depends on: #12", "Blocked by [#12](...)"). - sep='[[:space:]:*_([>-]*' + # Punctuation, Markdown, a dash or a line break may sit between the + # phrase and the reference ("Depends on: #12", "Blocked by [#12](...)", + # "Depends on `#12`", "Merges after — #12"). Each byte of an en or em + # dash is in the set, so it matches in a UTF-8 or a C locale. + sep='[[:space:]:*_([>"`–—-]*' body="$(jq -r '.body // ""' "$RUNNER_TEMP/pr.json")" held_by_body=false # Here-strings, not pipes: under pipefail an early grep -q exit could diff --git a/tests/integration/ci/pull-request-auto-merge-workflow.test.ts b/tests/integration/ci/pull-request-auto-merge-workflow.test.ts index 587e930325..e600206dda 100644 --- a/tests/integration/ci/pull-request-auto-merge-workflow.test.ts +++ b/tests/integration/ci/pull-request-auto-merge-workflow.test.ts @@ -29,7 +29,7 @@ interface PullRequestFixture { state?: string; isDraft?: boolean; baseRefName?: string; - labels?: string[]; + labels?: readonly string[]; body?: string; armed?: boolean; inMergeQueue?: boolean; @@ -190,6 +190,15 @@ describe("pull request auto-merge workflow", () => { { body: "Blocked by https://github.com/veryfront/veryfront-api/pull/8005" }, ], ["a wait on a pull request", { body: "Waits for PR #42 to land." }], + ["a hold for the release", { body: "Hold for the release." }], + ["a request to hold this pull request", { body: "Please hold this PR until Friday." }], + ["a please-hold note", { body: "Ready, but please hold." }], + ["a hold-it note", { body: "Hold it until the API ships." }], + ["an inline-code dependency", { body: "Depends on `#123`" }], + ["an inline-code cross-repository dependency", { body: "Blocked by `veryfront-api#45`." }], + ["an em dash dependency", { body: "Depends on — #123" }], + ["an en dash dependency", { body: "Merges after – veryfront-api#45" }], + ["a quoted dependency", { body: 'Waits for "#123" to deploy.' }], ] as const ) { it(`holds and dequeues a pull request with ${reason}`, async () => { @@ -206,6 +215,8 @@ describe("pull request auto-merge workflow", () => { "The adapter waits for the worker before it replies.", "Holds: drafts stay out of the queue.", "Hold the lock while the cache refreshes.", + "The queue holds the job until it finishes.", + "Keep a hold on the handle for the request.", "Fixes #123 and lands the retry after the timeout change.", ] ) { From abb789b509d82f1817138293871071960026c23c Mon Sep 17 00:00:00 2001 From: Koji Wakayama Date: Sat, 5 Dec 2026 22:09:58 +0100 Subject: [PATCH 3/5] ci: read Markdown as spaces, hold on the word hold and bounded merge orders, keep merge-first on a word boundary --- .github/workflows/pull-request-auto-merge.yml | 44 +++++++++++++------ .../pull-request-auto-merge-workflow.test.ts | 24 +++++++++- 2 files changed, 52 insertions(+), 16 deletions(-) diff --git a/.github/workflows/pull-request-auto-merge.yml b/.github/workflows/pull-request-auto-merge.yml index b2d6214512..e53e1a2875 100644 --- a/.github/workflows/pull-request-auto-merge.yml +++ b/.github/workflows/pull-request-auto-merge.yml @@ -79,24 +79,40 @@ jobs: draft="$(jq -r .isDraft "$RUNNER_TEMP/pr.json")" blocked="$(jq -r '[.labels[].name] | index("blocked") != null' "$RUNNER_TEMP/pr.json")" armed="$(jq -r '.autoMergeRequest != null' "$RUNNER_TEMP/pr.json")" - # A hold is an explicit instruction, or a merge order or dependency that - # names another pull request ("depends on #123", "merges after - # veryfront-api#45", a /pull/ link). Ordinary prose such as "depends on - # zod" or "waits for the worker" is not one. - ref='(pr |pull request )?(https://github\.com/)?(([a-z0-9_.-]+/)?[a-z0-9_.-]+)?(#|/pull/)[0-9]+' - hold="(do not|don.t) (merge|queue)|merge order|required pair|on hold|please hold|hold (until|off|for|it|this|the (pr|pull request|change))\b|merge[sd]? first|^[[:space:]]*hold[.!:]?[[:space:]]*$" - dependency="(merged?|merges|lands?|landed) (after|before|with)|blocked (by|on)|depends on|dependent on|wait(s|ing)? (for|on|until)" - # Punctuation, Markdown, a dash or a line break may sit between the - # phrase and the reference ("Depends on: #12", "Blocked by [#12](...)", - # "Depends on `#12`", "Merges after — #12"). Each byte of an en or em - # dash is in the set, so it matches in a UTF-8 or a C locale. - sep='[[:space:]:*_([>"`–—-]*' + # A hold is the word "hold" or an explicit instruction, or a merge order + # or dependency that names another pull request ("depends on #123", + # "merge after veryfront-api#45", "blocked by PR 123", a /pull/ link). + # Ordinary prose such as "depends on zod", "waits for the worker" or "the + # reducer merges after each step" is not one. + ref='((pr|pull[[:space:]-]?request)[[:space:]:]*#?[0-9]+|(https://github\.com/)?(([a-z0-9_.-]+/)?[a-z0-9_.-]+)?(#|/pull/)[0-9]+)' + hold="\bhold\b|(do not|don.t) (merge|queue)|merge order|required pair|\bmerge[sd]? first" + # A merge order is an instruction: a present-tense verb or "be/get + # merged", up to two words ("merge right after", "merge this PR after"), + # then the order and directly the pull request. Past tense ("was merged + # with #12") is history. + order="(\b(merge|merges|merging|land|lands|landing)\b|\b(be|get|gets|getting|being) (merged|landed)\b)([[:space:]]+[^[:space:]]+){0,2}[[:space:]]+(after|before|with)|\bafter" + dependency="blocked (by|on)|depends on|dependent on|wait(s|ing)? (for|on|until)" + # A colon, a dash or a line break may sit between a phrase and the + # reference ("Depends on: #12", "Merges after — #12"); a dependency may + # also describe it in up to three words ("blocked by the upstream PR + # #12"). Each byte of an en or em dash is in the set, so it matches in a + # UTF-8 or a C locale. + sep='[[:space:]:_–—-]*' + described="$sep([^[:space:]]+[[:space:]]+){0,3}" + named="($order)$sep$ref|($dependency)$described$ref" body="$(jq -r '.body // ""' "$RUNNER_TEMP/pr.json")" + # Markdown decoration (emphasis, inline code, quotes, , link + # brackets) reads as spaces, so "**Hold.**", "- Hold." and "Depends on + # `#12`" read as written. A link is read twice: by its label, for + # "[#12](...)", and by its target, for "Depends on [API PR](.../pull/12)". + plain="$(sed -E 's/[][*`"<>()~|]/ /g' <<< "$body")" + targets="$(sed -E 's/\[[^]]*\]\(([^)]*)\)/\1/g; s/[][*`"<>()~|]/ /g' <<< "$body")" held_by_body=false # Here-strings, not pipes: under pipefail an early grep -q exit could # fail the writer and skip a hold. - if grep -qiE "$hold" <<< "$body" \ - || grep -qiE "($dependency)$sep$ref" <<< "${body//[$'\r\n']/ }"; then + if grep -qiE "$hold" <<< "$plain" \ + || grep -qiE "$named" <<< "${plain//[$'\r\n']/ }" \ + || grep -qiE "$named" <<< "${targets//[$'\r\n']/ }"; then held_by_body=true fi diff --git a/tests/integration/ci/pull-request-auto-merge-workflow.test.ts b/tests/integration/ci/pull-request-auto-merge-workflow.test.ts index e600206dda..f663291fe1 100644 --- a/tests/integration/ci/pull-request-auto-merge-workflow.test.ts +++ b/tests/integration/ci/pull-request-auto-merge-workflow.test.ts @@ -199,6 +199,21 @@ describe("pull request auto-merge workflow", () => { ["an em dash dependency", { body: "Depends on — #123" }], ["an en dash dependency", { body: "Merges after – veryfront-api#45" }], ["a quoted dependency", { body: 'Waits for "#123" to deploy.' }], + ["a list-item hold", { body: "Notes:\n- Hold.\n" }], + ["a bold hold", { body: "**Hold.**" }], + ["a heading hold", { body: "## Hold\n\nAdds a flag." }], + ["a hold on the lock", { body: "Hold the lock on this one." }], + ["an autolink dependency", { + body: "Depends on ", + }], + ["a described link dependency", { + body: "Depends on [API PR](https://github.com/veryfront/veryfront-api/pull/123)", + }], + ["a labelled bare number", { body: "Depends on PR 123" }], + ["a described dependency", { body: "Blocked by upstream PR #45." }], + ["a merge order with words between", { body: "Merge this PR after veryfront-api#45." }], + ["a bare after-number order", { body: "Ship after #123." }], + ["a get-merged order", { body: "This should get merged after #123." }], ] as const ) { it(`holds and dequeues a pull request with ${reason}`, async () => { @@ -214,9 +229,14 @@ describe("pull request auto-merge workflow", () => { "This component depends on zod for parsing.", "The adapter waits for the worker before it replies.", "Holds: drafts stay out of the queue.", - "Hold the lock while the cache refreshes.", "The queue holds the job until it finishes.", - "Keep a hold on the handle for the request.", + "This behavior emerges first in staging.", + "The sanitizer must withhold it until validation.", + "Increase the timeout threshold for batch imports.", + "The upstream fix was merged with #123.", + "See [the design](https://github.com/veryfront/veryfront-api/pull/7) for context.", + "Raises the PR 123 timeout limit.", + "The reducer merges the lists after sorting them; fixes #123.", "Fixes #123 and lands the retry after the timeout change.", ] ) { From e06cd7160d3473da4e86e533bb0a3423ddbfb7a7 Mon Sep 17 00:00:00 2001 From: Koji Wakayama Date: Sat, 5 Dec 2026 22:16:53 +0100 Subject: [PATCH 4/5] ci: hold on merge orders that describe a labelled pull request --- .github/workflows/pull-request-auto-merge.yml | 7 ++++++- .../ci/pull-request-auto-merge-workflow.test.ts | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pull-request-auto-merge.yml b/.github/workflows/pull-request-auto-merge.yml index e53e1a2875..16a4840c67 100644 --- a/.github/workflows/pull-request-auto-merge.yml +++ b/.github/workflows/pull-request-auto-merge.yml @@ -99,7 +99,12 @@ jobs: # UTF-8 or a C locale. sep='[[:space:]:_–—-]*' described="$sep([^[:space:]]+[[:space:]]+){0,3}" - named="($order)$sep$ref|($dependency)$described$ref" + # A merge order may also describe the pull request in up to two words + # when it is labelled as one ("merge after the upstream PR #12"), so a + # plain clause after the order ("merges the lists after sorting them; + # fixes #12") is not read as one. + labelled='((the|an?)[[:space:]]+)?([^[:space:]]+[[:space:]]+){0,2}(pr|pull[[:space:]-]?request)[[:space:]:]*#?[0-9]+' + named="($order)$sep$ref|($order)$sep$labelled|($dependency)$described$ref" body="$(jq -r '.body // ""' "$RUNNER_TEMP/pr.json")" # Markdown decoration (emphasis, inline code, quotes, , link # brackets) reads as spaces, so "**Hold.**", "- Hold." and "Depends on diff --git a/tests/integration/ci/pull-request-auto-merge-workflow.test.ts b/tests/integration/ci/pull-request-auto-merge-workflow.test.ts index f663291fe1..b9cab4bebc 100644 --- a/tests/integration/ci/pull-request-auto-merge-workflow.test.ts +++ b/tests/integration/ci/pull-request-auto-merge-workflow.test.ts @@ -214,6 +214,12 @@ describe("pull request auto-merge workflow", () => { ["a merge order with words between", { body: "Merge this PR after veryfront-api#45." }], ["a bare after-number order", { body: "Ship after #123." }], ["a get-merged order", { body: "This should get merged after #123." }], + ["a merge order with a described pull request", { + body: "Must be merged after the upstream PR #123.", + }], + ["a land-before order with a described pull request", { + body: "Land before the API PR #123.", + }], ] as const ) { it(`holds and dequeues a pull request with ${reason}`, async () => { @@ -232,6 +238,7 @@ describe("pull request auto-merge workflow", () => { "The queue holds the job until it finishes.", "This behavior emerges first in staging.", "The sanitizer must withhold it until validation.", + "This merges after the cache warms; see pull request 12.", "Increase the timeout threshold for batch imports.", "The upstream fix was merged with #123.", "See [the design](https://github.com/veryfront/veryfront-api/pull/7) for context.", From 7b46e597b71c3b8ac51c1b85e0b22e53178e44b0 Mon Sep 17 00:00:00 2001 From: Koji Wakayama Date: Sat, 5 Dec 2026 23:02:53 +0100 Subject: [PATCH 5/5] ci: hold auto-merge on draft and labels only, never the description --- .github/workflows/pull-request-auto-merge.yml | 54 ++--------- AGENTS.md | 8 +- .../pull-request-auto-merge-workflow.test.ts | 94 +++++-------------- 3 files changed, 33 insertions(+), 123 deletions(-) diff --git a/.github/workflows/pull-request-auto-merge.yml b/.github/workflows/pull-request-auto-merge.yml index 16a4840c67..3095aa60c7 100644 --- a/.github/workflows/pull-request-auto-merge.yml +++ b/.github/workflows/pull-request-auto-merge.yml @@ -7,9 +7,10 @@ name: Pull request auto-merge # checks again on the merge-group commit. # # A pull request is held (auto-merge off, and out of the queue) while it is a -# draft, carries the `blocked` label, or its description states a merge order or -# hold. Keep a pull request that must merge after another one in draft until its -# pair has landed. +# draft or carries the `blocked` label. The description is not read: only GitHub +# state holds a pull request, so an edit can neither hold nor release one. Keep +# a pull request that must merge after another one in draft, or label it +# `blocked`, until its pair has landed. # # Only pull requests whose branch lives in this repository are handled: only # people with write access can push one. Fork pull requests are never armed and @@ -23,7 +24,7 @@ name: Pull request auto-merge on: pull_request_target: - types: [opened, reopened, ready_for_review, converted_to_draft, labeled, unlabeled, edited] + types: [opened, reopened, ready_for_review, converted_to_draft, labeled, unlabeled] permissions: {} @@ -73,54 +74,12 @@ jobs: # Read the pull request now, not from the event: a later edit or label # may already have changed it. gh pr view "$PR" --repo "$GITHUB_REPOSITORY" \ - --json state,isDraft,baseRefName,labels,body,autoMergeRequest > "$RUNNER_TEMP/pr.json" + --json state,isDraft,baseRefName,labels,autoMergeRequest > "$RUNNER_TEMP/pr.json" state="$(jq -r .state "$RUNNER_TEMP/pr.json")" base="$(jq -r .baseRefName "$RUNNER_TEMP/pr.json")" draft="$(jq -r .isDraft "$RUNNER_TEMP/pr.json")" blocked="$(jq -r '[.labels[].name] | index("blocked") != null' "$RUNNER_TEMP/pr.json")" armed="$(jq -r '.autoMergeRequest != null' "$RUNNER_TEMP/pr.json")" - # A hold is the word "hold" or an explicit instruction, or a merge order - # or dependency that names another pull request ("depends on #123", - # "merge after veryfront-api#45", "blocked by PR 123", a /pull/ link). - # Ordinary prose such as "depends on zod", "waits for the worker" or "the - # reducer merges after each step" is not one. - ref='((pr|pull[[:space:]-]?request)[[:space:]:]*#?[0-9]+|(https://github\.com/)?(([a-z0-9_.-]+/)?[a-z0-9_.-]+)?(#|/pull/)[0-9]+)' - hold="\bhold\b|(do not|don.t) (merge|queue)|merge order|required pair|\bmerge[sd]? first" - # A merge order is an instruction: a present-tense verb or "be/get - # merged", up to two words ("merge right after", "merge this PR after"), - # then the order and directly the pull request. Past tense ("was merged - # with #12") is history. - order="(\b(merge|merges|merging|land|lands|landing)\b|\b(be|get|gets|getting|being) (merged|landed)\b)([[:space:]]+[^[:space:]]+){0,2}[[:space:]]+(after|before|with)|\bafter" - dependency="blocked (by|on)|depends on|dependent on|wait(s|ing)? (for|on|until)" - # A colon, a dash or a line break may sit between a phrase and the - # reference ("Depends on: #12", "Merges after — #12"); a dependency may - # also describe it in up to three words ("blocked by the upstream PR - # #12"). Each byte of an en or em dash is in the set, so it matches in a - # UTF-8 or a C locale. - sep='[[:space:]:_–—-]*' - described="$sep([^[:space:]]+[[:space:]]+){0,3}" - # A merge order may also describe the pull request in up to two words - # when it is labelled as one ("merge after the upstream PR #12"), so a - # plain clause after the order ("merges the lists after sorting them; - # fixes #12") is not read as one. - labelled='((the|an?)[[:space:]]+)?([^[:space:]]+[[:space:]]+){0,2}(pr|pull[[:space:]-]?request)[[:space:]:]*#?[0-9]+' - named="($order)$sep$ref|($order)$sep$labelled|($dependency)$described$ref" - body="$(jq -r '.body // ""' "$RUNNER_TEMP/pr.json")" - # Markdown decoration (emphasis, inline code, quotes, , link - # brackets) reads as spaces, so "**Hold.**", "- Hold." and "Depends on - # `#12`" read as written. A link is read twice: by its label, for - # "[#12](...)", and by its target, for "Depends on [API PR](.../pull/12)". - plain="$(sed -E 's/[][*`"<>()~|]/ /g' <<< "$body")" - targets="$(sed -E 's/\[[^]]*\]\(([^)]*)\)/\1/g; s/[][*`"<>()~|]/ /g' <<< "$body")" - held_by_body=false - # Here-strings, not pipes: under pipefail an early grep -q exit could - # fail the writer and skip a hold. - if grep -qiE "$hold" <<< "$plain" \ - || grep -qiE "$named" <<< "${plain//[$'\r\n']/ }" \ - || grep -qiE "$named" <<< "${targets//[$'\r\n']/ }"; then - held_by_body=true - fi - if [ "$state" != OPEN ] || [ "$base" != main ]; then echo "Pull request #$PR is $state against $base; nothing to do." exit 0 @@ -129,7 +88,6 @@ jobs: reason="" [ "$draft" = true ] && reason="it is a draft" [ "$blocked" = true ] && reason="it has the blocked label" - [ "$held_by_body" = true ] && reason="its description states a merge order or hold" if [ -n "$reason" ]; then if [ "$armed" = true ]; then diff --git a/AGENTS.md b/AGENTS.md index 2831effcb2..f71123ccac 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -278,10 +278,10 @@ the required checks on the generated `merge_group` commit. pull request checks pass. Do not mutate the pull request branch while it is queued. - A ready pull request from a branch in this repository, opened by a person, arms auto-merge by itself (`pull-request-auto-merge.yml`): it joins the queue once the required checks, the automated review - and thread resolution pass. To hold one, keep it draft, add the `blocked` label, or state the hold - in its description: "on hold", "do not merge", or a merge order naming the other pull request - ("merges after #123", "depends on owner/repo#45"). Fork and bot pull requests are never armed; - queue them by hand. + and thread resolution pass. To hold one, keep it draft or add the `blocked` label; the description + is never read, so a note there holds nothing. A pull request that must merge after another stays + draft or `blocked` until its pair has landed. Fork and bot pull requests are never armed; queue + them by hand. ## Architecture map diff --git a/tests/integration/ci/pull-request-auto-merge-workflow.test.ts b/tests/integration/ci/pull-request-auto-merge-workflow.test.ts index b9cab4bebc..3d4f0a6376 100644 --- a/tests/integration/ci/pull-request-auto-merge-workflow.test.ts +++ b/tests/integration/ci/pull-request-auto-merge-workflow.test.ts @@ -172,54 +172,7 @@ describe("pull request auto-merge workflow", () => { const [reason, pr] of [ ["a draft", { isDraft: true }], ["the blocked label", { labels: ["blocked"] }], - ["a merge order in the description", { body: "Merges after #123." }], - ["a hold in the description", { body: "Please hold until the release." }], - ["a bare hold line in the description", { body: "Adds a flag.\n\nHold.\n" }], - ["an on-hold note in the description", { body: "On hold for the launch." }], - ["a do-not-merge note in the description", { body: "Do not merge yet." }], - ["a cross-repository dependency", { body: "Depends on veryfront/veryfront-api#8005." }], - ["a dependency on a sibling repository", { body: "Merges after veryfront-api#8005." }], - ["a dependency after a colon", { body: "Depends on: #42" }], - ["a markdown link dependency", { - body: "Depends on [#123](https://github.com/veryfront/veryfront-api/pull/123)", - }], - ["a wrapped dependency", { body: "This depends on\r\n#123 landing." }], - ["a merge-first note", { body: "This must merge first." }], - [ - "a dependency given as a link", - { body: "Blocked by https://github.com/veryfront/veryfront-api/pull/8005" }, - ], - ["a wait on a pull request", { body: "Waits for PR #42 to land." }], - ["a hold for the release", { body: "Hold for the release." }], - ["a request to hold this pull request", { body: "Please hold this PR until Friday." }], - ["a please-hold note", { body: "Ready, but please hold." }], - ["a hold-it note", { body: "Hold it until the API ships." }], - ["an inline-code dependency", { body: "Depends on `#123`" }], - ["an inline-code cross-repository dependency", { body: "Blocked by `veryfront-api#45`." }], - ["an em dash dependency", { body: "Depends on — #123" }], - ["an en dash dependency", { body: "Merges after – veryfront-api#45" }], - ["a quoted dependency", { body: 'Waits for "#123" to deploy.' }], - ["a list-item hold", { body: "Notes:\n- Hold.\n" }], - ["a bold hold", { body: "**Hold.**" }], - ["a heading hold", { body: "## Hold\n\nAdds a flag." }], - ["a hold on the lock", { body: "Hold the lock on this one." }], - ["an autolink dependency", { - body: "Depends on ", - }], - ["a described link dependency", { - body: "Depends on [API PR](https://github.com/veryfront/veryfront-api/pull/123)", - }], - ["a labelled bare number", { body: "Depends on PR 123" }], - ["a described dependency", { body: "Blocked by upstream PR #45." }], - ["a merge order with words between", { body: "Merge this PR after veryfront-api#45." }], - ["a bare after-number order", { body: "Ship after #123." }], - ["a get-merged order", { body: "This should get merged after #123." }], - ["a merge order with a described pull request", { - body: "Must be merged after the upstream PR #123.", - }], - ["a land-before order with a described pull request", { - body: "Land before the API PR #123.", - }], + ["the blocked label among others", { labels: ["ci", "blocked"] }], ] as const ) { it(`holds and dequeues a pull request with ${reason}`, async () => { @@ -230,29 +183,28 @@ describe("pull request auto-merge workflow", () => { }); } - for ( - const body of [ - "This component depends on zod for parsing.", - "The adapter waits for the worker before it replies.", - "Holds: drafts stay out of the queue.", - "The queue holds the job until it finishes.", - "This behavior emerges first in staging.", - "The sanitizer must withhold it until validation.", - "This merges after the cache warms; see pull request 12.", - "Increase the timeout threshold for batch imports.", - "The upstream fix was merged with #123.", - "See [the design](https://github.com/veryfront/veryfront-api/pull/7) for context.", - "Raises the PR 123 timeout limit.", - "The reducer merges the lists after sorting them; fixes #123.", - "Fixes #123 and lands the retry after the timeout change.", - ] - ) { - it(`arms a pull request whose description only says: ${body}`, async () => { - const outcome = await runScript({ pr: { body } }); - assertEquals(outcome.code, 0); - assertEquals(merges(outcome.calls), [`pr merge 7 --repo ${REPOSITORY} --auto`]); - }); - } + it("neither holds nor releases on the description", async () => { + // Only GitHub state holds: an edit to the text can neither hold nor release. + const body = "Do not merge. Hold.\n\nDepends on #123 and merges after veryfront/other#9."; + const unarmed = await runScript({ pr: { body } }); + assertEquals(unarmed.code, 0); + assertEquals(merges(unarmed.calls), [`pr merge 7 --repo ${REPOSITORY} --auto`]); + const armed = await runScript({ pr: { body, armed: true, inMergeQueue: true } }); + assertEquals(armed.code, 0); + assertEquals(merges(armed.calls), []); + assertEquals(dequeues(armed.calls), []); + }); + + it("does not wake on or read the description", async () => { + const workflow = await loadWorkflow(); + const trigger = (workflow.on as YamlRecord).pull_request_target as YamlRecord; + assert(!(trigger.types as string[]).includes("edited"), "edits do not wake the workflow"); + const steps = await loadSteps(); + assert( + steps.every((step) => !/\bbody\b/.test(String(step.run ?? ""))), + "no step reads the body", + ); + }); it("holds a bot pull request too", async () => { const outcome = await runScript({