You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by pk...@apache.org on 2026/09/14 21:58:13 UTC

(logging-log4j2) 01/01: Require a `port-to-*` or `port-done` label on every PR

This is an automated email from the ASF dual-hosted git repository.

ppkarwasz pushed a commit to branch feat/2.x/port-label-check
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit a53da1fbfecdeef31c3006a48a14916f21c44c2d
Author: Piotr P. Karwasz <pk...@apache.org>
AuthorDate: Mon Sep 14 23:58:02 2026 +0200

    Require a `port-to-*` or `port-done` label on every PR
    
    Adds a `Check port label` workflow that fails unless the PR carries a
    `port-to-<branch>` or `port-done` label, registers it as a required
    status check on `2.x` through a dedicated ruleset in `.asf.yaml`, and
    labels Dependabot PRs with `port-done` automatically, since dependency
    updates never need to be ported.
    
    The ruleset is limited to `2.x` on purpose: a required check that never
    reports would block merges on the other protected branches until the
    workflow is ported there.
    
    See https://github.com/apache/logging-log4j2/issues/3161
    
    Assisted-By: Claude Fable 5.1 <no...@anthropic.com>
    Claude-Session: https://claude.ai/code/session_013pu6pykS9KYuoXAYLvJyBg
---
 .asf.yaml                                 | 10 ++++++
 .github/workflows/analyze-dependabot.yaml | 18 ++++++++++
 .github/workflows/check-port-label.yaml   | 57 +++++++++++++++++++++++++++++++
 3 files changed, 85 insertions(+)

diff --git a/.asf.yaml b/.asf.yaml
index 805ab3bbcd..8dcdc553c9 100644
--- a/.asf.yaml
+++ b/.asf.yaml
@@ -95,6 +95,16 @@ github:
       # At least one positive review must be present
       required_pull_request_reviews:
         required_approving_review_count: 1
+    # Every PR must carry a `port-to-*` or `port-done` label (see `.github/workflows/check-port-label.yaml`).
+    # Kept as a separate ruleset, so that it can be limited to the branches that run the workflow.
+    - name: "Port label"
+      type: branch
+      branches:
+        includes:
+          - "2.x"
+      required_status_checks:
+        - app_slug: github-actions
+          name: "Check port label"
     # Use raw rules, until a convenience notation for `restrict_update` is introduced.
     # See: https://github.com/apache/infrastructure-asfyaml/issues/96
     #
diff --git a/.github/workflows/analyze-dependabot.yaml b/.github/workflows/analyze-dependabot.yaml
index cd991d3637..2b879c7c0e 100644
--- a/.github/workflows/analyze-dependabot.yaml
+++ b/.github/workflows/analyze-dependabot.yaml
@@ -26,6 +26,24 @@ permissions: { }
 
 jobs:
 
+  # Dependency updates never need to be ported: Dependabot maintains every branch on its own.
+  label-dependabot:
+    if: ${{
+      github.repository == 'apache/logging-log4j2'
+      && github.actor == 'dependabot[bot]'
+      && github.event.pull_request.user.login == 'dependabot[bot]'
+      }}
+    runs-on: ubuntu-slim
+    permissions:
+      # Add the `port-done` label
+      pull-requests: write
+    steps:
+      - name: Add `port-done` label
+        env:
+          GH_TOKEN: ${{ github.token }}
+          PR: ${{ github.event.pull_request.html_url }}
+        run: gh pr edit "$PR" --add-label port-done
+
   analyze-dependabot:
     # `github.actor` prevents recursive calls when `github-actions[bot]` pushes to the PR;
     # `github.event.pull_request.user.login` skips PRs not opened by Dependabot.
diff --git a/.github/workflows/check-port-label.yaml b/.github/workflows/check-port-label.yaml
new file mode 100644
index 0000000000..e3560f94f1
--- /dev/null
+++ b/.github/workflows/check-port-label.yaml
@@ -0,0 +1,57 @@
+#
+# 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.
+#
+
+name: "Check port label"
+
+# Every PR must state whether its change needs to be ported to the other development branch
+# (`2.x` <-> `main`) or to a maintenance branch. See:
+# https://github.com/apache/logging-log4j2/issues/3161
+#
+# Accepted labels:
+#
+# - `port-to-*` (e.g. `port-to-main`, `port-to-2.x`, `port-to-2.26.x`): a port is still needed.
+# - `port-done`: nothing more to port, either because every port is merged or because none was needed.
+on:
+  pull_request:
+    types:
+      - opened
+      - reopened
+      - synchronize
+      - labeled
+      - unlabeled
+
+# Default permissions for each job.
+# Additional permissions should be assigned on a per-job basis.
+permissions: { }
+
+jobs:
+
+  check-port-label:
+    name: "Check port label"
+    runs-on: ubuntu-slim
+    steps:
+      - name: Require a `port-to-*` or `port-done` label
+        env:
+          LABELS: ${{ join(github.event.pull_request.labels.*.name, '\n') }}
+        shell: bash
+        run: |
+          if printf '%b\n' "$LABELS" | grep -qE '^(port-to-.+|port-done)$'; then
+            echo "Port label found."
+          else
+            echo "::error::Add a \`port-to-<branch>\` label if this change must be ported to another branch, or \`port-done\` if no port is needed. See https://github.com/apache/logging-log4j2/issues/3161"
+            exit 1
+          fi