Skip to content

Commit cb60f74

Browse files
test(ci): extend the backport label contract to both spellings
The concurrency-group key and prepare's `if:` gate now name four labels rather than two, and release-freeze-contract.bats pinned the pair on both sides — as a literal and as an exact count. Every namespaced name appended to the workflow therefore reported as a widening, which is the right default: the count exists because the literal is a substring check and an appended exclusion satisfies it unchanged. Here the appended names are not a widening. `kind/backport` and `kind/backport-previous` are genuine backport requests, so they belong on the same side of the concurrency split as the legacy pair, and the gate has to admit them or the rename stops the bot firing. Both counts go to four and both literals name all four operands, so a half-finished rename still reports. Marked TRANSITIONAL at each site, matching the comment in backport.yaml: when dosubot's PR labelling is switched off and the legacy arms are dropped, these go back to the pair in the same pass. Assisted-By: Claude <[email protected]> Signed-off-by: Myasnikov Daniil <[email protected]>
1 parent a0c297a commit cb60f74

1 file changed

Lines changed: 29 additions & 14 deletions

File tree

‎hack/release-freeze-contract.bats‎

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ closed-merged=true"
437437
# holding the run they have to queue behind, and one request could then evict
438438
# the other.
439439
#
440-
# Pinned as the literal pair, not as a count of `label.name != '`. That count
440+
# Pinned as the literal names, not as a count of `label.name != '`. That count
441441
# measures the operator and says nothing about the operands, so renaming one
442442
# name here and not in `prepare` — the half-finished rename — left it at two
443443
# and stayed green, while a real `backport-previous` event took the `-label`
@@ -449,16 +449,25 @@ closed-merged=true"
449449
# EVERY event takes the suffix. A constant suffix is exactly as vacuous as no
450450
# split at all. Every operand here was pinned before this line existed; the
451451
# operator joining them was not.
452-
printf '%s\n' "$line" | grep -qF "github.event.action == 'labeled' && github.event.label.name != 'backport' && github.event.label.name != 'backport-previous'"
453-
454-
# And exactly two of them. The literal above is a substring check, so appending
455-
# a third exclusion satisfies it unchanged — and a third exclusion is not
452+
#
453+
# TRANSITIONAL: four names, not the original pair, because backport.yaml
454+
# accepts both spellings while the org-level dosubot still applies the legacy
455+
# ones. The namespaced names are genuine backport requests, so they belong on
456+
# this side of the split exactly as the legacy ones do — routing them aside
457+
# would hand a `kind/backport` event its own group and let it cherry-pick
458+
# alongside the merge run, which is the failure the pin above describes. When
459+
# dosubot's PR labelling is switched off and backport.yaml drops its legacy
460+
# arms, this literal and the count below go back to the pair.
461+
printf '%s\n' "$line" | grep -qF "github.event.action == 'labeled' && github.event.label.name != 'backport' && github.event.label.name != 'backport-previous' && github.event.label.name != 'kind/backport' && github.event.label.name != 'kind/backport-previous'"
462+
463+
# And exactly four of them. The literal above is a substring check, so appending
464+
# a fifth exclusion satisfies it unchanged — and a fifth exclusion is not
456465
# cosmetic: the named label stops being routed aside, lands in the main group,
457466
# takes its single pending slot, skips in `prepare`, and evicts a genuine
458467
# backport request while delivering nothing. Same harm as widening `types:`.
459468
# Presence and count answer different questions; this test needs both.
460469
count="$(printf '%s\n' "$line" | grep -o "github\.event\.label\.name != '" | wc -l | tr -d ' ')"
461-
[ "${count:-0}" -eq 2 ]
470+
[ "${count:-0}" -eq 4 ]
462471

463472
# The suffix the condition selects, not only the condition. Asserting the
464473
# operands alone leaves the whole split deletable — collapsing the tail to
@@ -542,21 +551,27 @@ closed-merged=true"
542551
# ungated it re-enters this job on every later unrelated label — an automated
543552
# size/* or kind/* — for a merged PR still carrying `backport`, redoing a
544553
# backport that has already been delivered.
545-
printf '%s\n' "$block" | grep -qF "(github.event.action == 'closed' && (contains(github.event.pull_request.labels.*.name, 'backport') || contains(github.event.pull_request.labels.*.name, 'backport-previous')))"
554+
#
555+
# TRANSITIONAL: four reads, not the original pair. backport.yaml accepts the
556+
# namespaced and the legacy spelling of each label while the org-level dosubot
557+
# still applies the legacy ones; when its PR labelling is switched off and the
558+
# legacy arms are dropped, this literal and the count below go back to two.
559+
printf '%s\n' "$block" | grep -qF "(github.event.action == 'closed' && (contains(github.event.pull_request.labels.*.name, 'backport') || contains(github.event.pull_request.labels.*.name, 'backport-previous') || contains(github.event.pull_request.labels.*.name, 'kind/backport') || contains(github.event.pull_request.labels.*.name, 'kind/backport-previous')))"
546560

547-
# And the guard reads that set exactly twice, both of them inside the gated
561+
# And the guard reads that set exactly four times, all of them inside the gated
548562
# disjunct above, so it cannot be joined by an ungated one that quietly
549563
# restores the old behaviour while the assertion above stays green.
550564
#
551-
# Counted as OCCURRENCES, not lines. `grep -c` counts matching lines, and both
552-
# reads live on one line here, so it answers 1 and keeps answering 1 when a
553-
# third read is appended to that same line — which is exactly the restoration
565+
# Counted as OCCURRENCES, not lines. `grep -c` counts matching lines, and all
566+
# four reads live on one line here, so it answers 1 and keeps answering 1 when a
567+
# fifth read is appended to that same line — which is exactly the restoration
554568
# this is meant to catch. Only an append on a NEW line would have moved it.
555569
count="$(printf '%s\n' "$block" | grep -o 'contains(github\.event\.pull_request\.labels' | wc -l | tr -d ' ')"
556-
[ "${count:-0}" -eq 2 ]
570+
[ "${count:-0}" -eq 4 ]
557571

558-
# A label event answers for the label it carries.
559-
printf '%s\n' "$block" | grep -qF "(github.event.action == 'labeled' && (github.event.label.name == 'backport' || github.event.label.name == 'backport-previous'))"
572+
# A label event answers for the label it carries. Both spellings of each name,
573+
# for the transitional reason given above.
574+
printf '%s\n' "$block" | grep -qF "(github.event.action == 'labeled' && (github.event.label.name == 'backport' || github.event.label.name == 'backport-previous' || github.event.label.name == 'kind/backport' || github.event.label.name == 'kind/backport-previous'))"
560575

561576
# The two conjuncts the label logic hangs off, which the label assertions above
562577
# would not miss. `base.ref == 'main'` is what stops the bot backporting its own

0 commit comments

Comments
 (0)