Skip to content

Commit 3d12ece

Browse files
chore(ci): namespace the backport labels without breaking the trigger (#3844)
Takes over #3433 and finishes it. Closes #2585. The rename itself is IvanHunters' work, replayed here on current main with his commits intact. What was blocking it was my own review, and this fixes that plus one thing that appeared on main afterwards. ## What was blocking it The gate in `backport.yaml` matched `kind/backport` only after the rename. The `aliases:` in `labels.yml` migrate labels already attached to issues and pull requests, but they do not change what an external applier does going forward, and the org-level dosubot still applies the legacy names. So the bot would have quietly stopped firing for the share of backports it labels. Both spellings are now accepted, in the `if:` gate and in the JS step that reads them. ## What appeared afterwards #3569 landed while #3433 sat, and it added a concurrency guard that appends `-label` to the group for any labeled event that is not a backport label, so a backport label never cancels a run already in flight. That guard enumerated the two legacy names, so once the labels are namespaced a `kind/backport` event takes the `-label` branch and the guard stops covering the case it exists for. Extended to the new names. ## The dual acceptance is transitional and says so Accepting two spellings is a bridge, not a design. The plan is to switch dosubot's pull request labelling off and leave the in-repo labeler as the only applier, at which point the legacy arms can go. The comment in the workflow names all three deletion sites so that cleanup is mechanical: the `if:` gate, the JS step, and the concurrency group. Landing this before or after dosubot is switched off both work, which is the point. ## Checks `actionlint` clean on the workflow. There is no bats coverage for this gate on main; #3813 is what adds `hack/pr-labeler-contract.bats`, so the two are worth landing in that order. ### Release note ```release-note NONE ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Workflow Improvements** - Backport automation now supports standardized `kind/backport` and `kind/backport-previous` labels while maintaining compatibility with legacy labels during the transition. - Stale pull request handling and backport detection now follow the standardized labeling scheme. - **Documentation** - Updated contribution and release documentation with the new labels, labeling requirements, and troubleshooting guidance. - **Tests** - Expanded validation to cover both standardized and legacy backport labels. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2 parents 02c6942 + cb60f74 commit 3d12ece

7 files changed

Lines changed: 61 additions & 35 deletions

File tree

‎.github/PULL_REQUEST_TEMPLATE.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
- Breaking changes: append `!` after type/scope (`feat(api)!: ...`) or add a `BREAKING CHANGE:` footer
99
- If it's a work in progress, consider creating this PR as a draft.
1010
- Don't hesistate to ask for opinion and review in the community chats, even if it's still a draft.
11-
- Add the label `backport` if it's a bugfix that needs to be backported to a previous version.
11+
- Add the label `kind/backport` if it's a bugfix that needs to be backported to a previous version.
1212
-->
1313

1414
## What this PR does

‎.github/labels.yml‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,18 @@
7878
color: 'e11d21'
7979
description: Indicates the change introduces a breaking API or behaviour change
8080

81+
# kind/backport-previous has no upstream Kubernetes equivalent (k8s has no
82+
# two-release-line model); it stays under kind/ per the file convention.
83+
- name: kind/backport
84+
color: 'fbca04'
85+
description: Categorizes issue or PR as requiring a backport to the current release line
86+
aliases: ['backport']
87+
88+
- name: kind/backport-previous
89+
color: 'fbd876'
90+
description: Categorizes issue or PR as requiring a backport to the previous release line
91+
aliases: ['backport-previous']
92+
8193
# ──────────────────────────────────────────────
8294
# priority/ — urgency
8395
# ──────────────────────────────────────────────
@@ -282,14 +294,6 @@
282294
color: 'aaaaaa'
283295
description: Requires resolving an issue in an upstream project
284296

285-
- name: backport
286-
color: 'fbca04'
287-
description: Should change be backported on previous release
288-
289-
- name: backport-previous
290-
color: 'fbd876'
291-
description: Backport target — previous release line
292-
293297
- name: release
294298
color: 'aaaaaa'
295299
description: Releasing a new Cozystack version

‎.github/workflows/backport.yaml‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ on:
5454
# surviving run rather than a hundred queued ones, and the feature only shipped
5555
# 2026-05-07, on a path that delivers fixes to release lines.
5656
concurrency:
57-
group: backport-${{ github.workflow }}-${{ github.event.pull_request.number }}${{ (github.event.action == 'labeled' && github.event.label.name != 'backport' && github.event.label.name != 'backport-previous') && '-label' || '' }}
57+
group: backport-${{ github.workflow }}-${{ github.event.pull_request.number }}${{ (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') && '-label' || '' }}
5858
# Stated positively, matching the group key above. `!= 'labeled'` is equivalent
5959
# only while `types:` holds exactly these two, and that form fails open: adding
6060
# `unlabeled` or `reopened` there would hand those events cancellation in the
@@ -95,8 +95,8 @@ jobs:
9595
github.event.pull_request.merged == true &&
9696
github.event.pull_request.base.ref == 'main' &&
9797
(
98-
(github.event.action == 'closed' && (contains(github.event.pull_request.labels.*.name, 'backport') || contains(github.event.pull_request.labels.*.name, 'backport-previous'))) ||
99-
(github.event.action == 'labeled' && (github.event.label.name == 'backport' || github.event.label.name == 'backport-previous'))
98+
(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'))) ||
99+
(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'))
100100
)
101101
# GitHub API calls only — no docker, no repo toolchain: GitHub-hosted.
102102
runs-on: ubuntu-latest
@@ -144,8 +144,15 @@ jobs:
144144
script: |
145145
const pr = context.payload.pull_request;
146146
const labels = pr.labels.map(l => l.name);
147-
const isBackport = labels.includes('backport');
148-
const isBackportPrevious = labels.includes('backport-previous');
147+
// TRANSITIONAL: both spellings are accepted so the rename can land
148+
// in any order relative to the org-level dosubot, which still
149+
// applies the legacy names and is today the dominant applier on
150+
// real backports. Once dosubot's PR labelling is switched off and
151+
// the in-repo labeler is the only applier, the legacy arms here,
152+
// in the `if:` gate above and in the concurrency group can all be
153+
// deleted in one pass.
154+
const isBackport = labels.includes('kind/backport') || labels.includes('backport');
155+
const isBackportPrevious = labels.includes('kind/backport-previous') || labels.includes('backport-previous');
149156
150157
core.setOutput('backport', isBackport ? 'true' : 'false');
151158
core.setOutput('backport_previous', isBackportPrevious ? 'true' : 'false');

‎.github/workflows/stale.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
triage/accepted,kind/regression
4141
exempt-pr-labels: >-
4242
lifecycle/frozen,do-not-merge/hold,
43-
backport,backport-previous
43+
kind/backport,kind/backport-previous
4444
days-before-stale: 60
4545
days-before-close: 14
4646
operations-per-run: 100

‎docs/agents/contributing.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ git commit --signoff -m "docs(contributing): add installation guide"
106106

107107
**Special handling:**
108108

109-
- `[Backport release-1.x]` prefix is stripped before parsing; `area/release` and `backport` labels are added.
109+
- `[Backport release-1.x]` prefix is stripped before parsing; the `area/release` label is added.
110110
- Composite scope (`feat(platform, system, apps): ...`) — each comma-separated part is mapped independently.
111111
- `!` after type or `BREAKING CHANGE:` footer in the body → `kind/breaking-change`.
112112
- Unmapped scope or non-conventional title → `area/uncategorized` (signals the PR needs manual area selection).

‎docs/release.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,8 @@ The matching Talos node image is `ghcr.io/cozystack/cozystack/cozystack-nocloud:
345345

346346
| Label | Target branch |
347347
|-------|---------------|
348-
| `backport` | the newest existing `release-X.Y` branch |
349-
| `backport-previous` | the second-newest existing `release-X.Y` branch |
348+
| `kind/backport` | the newest existing `release-X.Y` branch |
349+
| `kind/backport-previous` | the second-newest existing `release-X.Y` branch |
350350

351351
Resolution is dynamic at run time, and it reads the branches themselves: the job lists the repository's branches, keeps the ones matching `release-<major>.<minor>`, and sorts them numerically descending — so `release-1.10` ranks above `release-1.9`, which a lexicographic sort gets backwards. `backport` takes the first, `backport-previous` the second, so both name a branch that exists by construction; asking for `backport-previous` when only one line exists fails the job rather than inventing a target. Nothing is derived arithmetically — an earlier version computed the previous line as `Y-1`, which named a non-existent branch whenever a minor was skipped.
352352

@@ -376,7 +376,7 @@ git push origin release-X.Y # or push to a new branch and open a PR
376376
To find the bot's failed comments across a batch of PRs:
377377

378378
```bash
379-
for n in $(gh pr list --search "label:backport label:backport-previous merged:>=2026-01-01" --json number --jq '.[].number'); do
379+
for n in $(gh pr list --search "label:kind/backport label:kind/backport-previous merged:>=2026-01-01" --json number --jq '.[].number'); do
380380
echo "=== #$n ==="
381381
gh pr view $n --json comments --jq '.comments[] | select(.author.login == "github-actions" or (.author.login | contains("backport"))) | .body' | head -20
382382
done
@@ -388,8 +388,8 @@ A patch release includes bugfixes for code that shipped in the corresponding min
388388

389389
```bash
390390
# 1. Inventory PRs already labeled for backport (merged but not yet on release-X.Y)
391-
gh pr list --search "is:merged label:backport" --limit 100
392-
gh pr list --search "is:merged label:backport-previous" --limit 100
391+
gh pr list --search "is:merged label:kind/backport" --limit 100
392+
gh pr list --search "is:merged label:kind/backport-previous" --limit 100
393393

394394
# 2. List commits on main since the release branch diverged that are NOT yet on release-X.Y
395395
git merge-base origin/main origin/release-X.Y

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