From 904095b418798968ba86fba301dec017048b5f00 Mon Sep 17 00:00:00 2001 From: Federico Capoano Date: Fri, 21 Aug 2026 16:13:25 -0300 Subject: [PATCH 1/2] [fix] Exempted Companion bot from PR validation The configured GitHub App has no author association, so its backports were treated as external contributions. --- .github/actions/bot-autoassign/base.py | 3 +++ .../bot-autoassign/tests/test_issue_assignment_bot.py | 9 +++++++++ docs/developer/reusable-github-utils.rst | 5 +++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/actions/bot-autoassign/base.py b/.github/actions/bot-autoassign/base.py index 88686f08..2637935d 100644 --- a/.github/actions/bot-autoassign/base.py +++ b/.github/actions/bot-autoassign/base.py @@ -142,6 +142,9 @@ def validate_pr_issues(self, pr): if pr.user and isinstance(getattr(pr.user, "login", None), str) else "" ) + if pr_author == self.bot_login: + print(f"Author {pr_author} is the configured bot. Proceeding.") + return True exclude_authors_env = os.environ.get( "EXCLUDE_PR_AUTHORS", DEFAULT_EXCLUDE_PR_AUTHORS ) diff --git a/.github/actions/bot-autoassign/tests/test_issue_assignment_bot.py b/.github/actions/bot-autoassign/tests/test_issue_assignment_bot.py index 8b47458e..95448fdc 100644 --- a/.github/actions/bot-autoassign/tests/test_issue_assignment_bot.py +++ b/.github/actions/bot-autoassign/tests/test_issue_assignment_bot.py @@ -1101,6 +1101,15 @@ def test_validate_pr_issues_exempt_association(self, bot_env): mock_pr.author_association = "MEMBER" assert bot.validate_pr_issues(mock_pr) + def test_validate_pr_issues_exempt_bot_author(self, bot_env): + bot = IssueAssignmentBot() + mock_pr = Mock() + mock_pr.user.login = "openwisp-companion[bot]" + mock_pr.author_association = "NONE" + mock_pr.body = "Backport of #504 to `1.2`." + assert bot.validate_pr_issues(mock_pr) + bot_env["repo_validation"].get_issue.assert_not_called() + def test_validate_pr_issues_no_issues(self, bot_env): bot = IssueAssignmentBot() mock_pr = Mock() diff --git a/docs/developer/reusable-github-utils.rst b/docs/developer/reusable-github-utils.rst index 3672b868..38fa8f1e 100644 --- a/docs/developer/reusable-github-utils.rst +++ b/docs/developer/reusable-github-utils.rst @@ -76,8 +76,9 @@ OpenWISP repositories. The bot provides the following features: - **PR validation**: Enforces the `OpenWISP Contributing Guidelines `_ for external contributors by flagging PRs that do not link a validated - issue. The bot removes the ``invalid`` label once the PR is valid and - closes unresolved invalid PRs after 24 hours. + issue. PRs created by the configured GitHub App are exempt. The bot + removes the ``invalid`` label once the PR is valid and closes unresolved + invalid PRs after 24 hours. **How Stale PR Detection Works** From 10b0d3549184314eb0f7b20fee986ad81afd113f Mon Sep 17 00:00:00 2001 From: Federico Capoano Date: Fri, 21 Aug 2026 17:14:30 -0300 Subject: [PATCH 2/2] [chores] Addressed review feedback --- .../actions/bot-autoassign/tests/test_issue_assignment_bot.py | 2 ++ docs/developer/reusable-github-utils.rst | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/actions/bot-autoassign/tests/test_issue_assignment_bot.py b/.github/actions/bot-autoassign/tests/test_issue_assignment_bot.py index 95448fdc..e7b5024f 100644 --- a/.github/actions/bot-autoassign/tests/test_issue_assignment_bot.py +++ b/.github/actions/bot-autoassign/tests/test_issue_assignment_bot.py @@ -1108,6 +1108,8 @@ def test_validate_pr_issues_exempt_bot_author(self, bot_env): mock_pr.author_association = "NONE" mock_pr.body = "Backport of #504 to `1.2`." assert bot.validate_pr_issues(mock_pr) + bot_env["github_validation"].get_repo.assert_not_called() + bot.github_validation.requester.graphql_query.assert_not_called() bot_env["repo_validation"].get_issue.assert_not_called() def test_validate_pr_issues_no_issues(self, bot_env): diff --git a/docs/developer/reusable-github-utils.rst b/docs/developer/reusable-github-utils.rst index 38fa8f1e..48e343d7 100644 --- a/docs/developer/reusable-github-utils.rst +++ b/docs/developer/reusable-github-utils.rst @@ -70,7 +70,7 @@ OpenWISP repositories. The bot provides the following features: no assignment is needed — just open a PR. - **Stale PR management**: Warns PR authors after 7 days of inactivity, marks stale and unassigns after 14 days, and posts a final follow-up - encouragement after 60 days. The bot does not auto-close PRs. + encouragement after 60 days. The bot does not auto-close stale PRs. - **PR reopen reassignment**: When a stale PR is reopened, linked issues are reassigned back to the author. - **PR validation**: Enforces the `OpenWISP Contributing Guidelines