-
-
Notifications
You must be signed in to change notification settings - Fork 99
[ci:fix] Refined reusable autoassign workflow #623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8ceddd1
[chores] Added reusable active autoassign bots workflow and fixed exi…
Eeshu-Yadav 6933114
[fix] Quote pip install target to prevent bash glob expansion
Eeshu-Yadav e1620de
[fix] Fix shell syntax and protect against shell injection
Eeshu-Yadav c253c40
[docs] Added the docs
Eeshu-Yadav 153ff20
[fix] Return True on early skips to avoid GitHub Actions failures
Eeshu-Yadav a9b28ac
[fix] Return False on true exceptions to avoid masking failures
Eeshu-Yadav fdaa739
[fix] Return False on true exceptions to avoid masking failures
Eeshu-Yadav 9f08f55
[docs] Added note on permissions
nemesifier e18cfde
[chores:fix[ Avoid running if PR is merged
nemesifier 7e387f5
[docs] Improved docs
nemesifier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -108,7 +108,7 @@ def test_handle_pr_reopen_no_payload(self, bot_env): | |
| def test_run_unsupported_event(self, bot_env): | ||
| bot = PRReopenBot() | ||
| bot.event_name = "push" | ||
| assert not bot.run() | ||
| assert bot.run() | ||
|
|
||
|
|
||
| class TestPRActivityBot: | ||
|
|
@@ -160,7 +160,7 @@ def test_handle_contributor_activity_not_author(self, bot_env): | |
| mock_pr = Mock() | ||
| mock_pr.user.login = "testuser" | ||
| bot_env["repo"].get_pull.return_value = mock_pr | ||
| assert not bot.handle_contributor_activity() | ||
| assert bot.handle_contributor_activity() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Strengthen skip-path tests with side-effect assertions. These tests currently assert truthy return only; please also assert no reassignment/label/comment side effects occurred in each skip branch. ✅ Suggested test hardening def test_handle_contributor_activity_not_author(self, bot_env):
...
bot_env["repo"].get_pull.return_value = mock_pr
assert bot.handle_contributor_activity()
+ mock_pr.remove_from_labels.assert_not_called()
+ mock_pr.create_issue_comment.assert_not_called()
def test_handle_contributor_activity_pr_not_stale(self, bot_env):
...
bot_env["repo"].get_pull.return_value = mock_pr
assert bot.handle_contributor_activity()
+ mock_pr.remove_from_labels.assert_not_called()
+ mock_pr.create_issue_comment.assert_not_called()
def test_handle_contributor_activity_not_pr(self, bot_env):
...
assert bot.handle_contributor_activity()
+ bot_env["repo"].get_pull.assert_not_called()Also applies to: 180-180, 193-193 🤖 Prompt for AI Agents |
||
|
|
||
| def test_handle_contributor_activity_pr_not_stale(self, bot_env): | ||
| bot = PRActivityBot() | ||
|
|
@@ -177,7 +177,7 @@ def test_handle_contributor_activity_pr_not_stale(self, bot_env): | |
| mock_pr.user.login = "testuser" | ||
| mock_pr.get_labels.return_value = [] | ||
| bot_env["repo"].get_pull.return_value = mock_pr | ||
| assert not bot.handle_contributor_activity() | ||
| assert bot.handle_contributor_activity() | ||
|
|
||
| def test_handle_contributor_activity_not_pr(self, bot_env): | ||
| bot = PRActivityBot() | ||
|
|
@@ -190,7 +190,7 @@ def test_handle_contributor_activity_not_pr(self, bot_env): | |
| "comment": {"user": {"login": "testuser"}}, | ||
| } | ||
| ) | ||
| assert not bot.handle_contributor_activity() | ||
| assert bot.handle_contributor_activity() | ||
|
|
||
| def test_handle_contributor_activity_no_payload(self, bot_env): | ||
| bot = PRActivityBot() | ||
|
|
@@ -199,4 +199,4 @@ def test_handle_contributor_activity_no_payload(self, bot_env): | |
| def test_run_unsupported_event(self, bot_env): | ||
| bot = PRActivityBot() | ||
| bot.event_name = "push" | ||
| assert not bot.run() | ||
| assert bot.run() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| name: Reusable Bot Autoassign | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| bot_command: | ||
| required: true | ||
| type: string | ||
| description: "The bot to execute (e.g., 'issue_assignment', 'pr_reopen', 'stale_pr')" | ||
| secrets: | ||
| OPENWISP_BOT_APP_ID: | ||
| required: true | ||
| OPENWISP_BOT_PRIVATE_KEY: | ||
| required: true | ||
|
|
||
| jobs: | ||
| run-bot: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Generate GitHub App token | ||
| id: generate-token | ||
| uses: actions/create-github-app-token@v2 | ||
| with: | ||
| app-id: ${{ secrets.OPENWISP_BOT_APP_ID }} | ||
| private-key: ${{ secrets.OPENWISP_BOT_PRIVATE_KEY }} | ||
|
|
||
| - name: Checkout openwisp-utils | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| repository: openwisp/openwisp-utils | ||
| ref: master | ||
| path: openwisp-utils | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: "3.13" | ||
|
|
||
| - name: Install dependencies | ||
| run: pip install -e 'openwisp-utils/.[github_actions]' | ||
|
|
||
| - name: Execute bot script | ||
| env: | ||
| GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} | ||
| REPOSITORY: ${{ github.repository }} | ||
| GITHUB_EVENT_NAME: ${{ github.event_name }} | ||
| BOT_COMMAND: ${{ inputs.bot_command }} | ||
| run: | | ||
| if [ -n "$GITHUB_EVENT_PATH" ]; then | ||
| python openwisp-utils/.github/actions/bot-autoassign/__main__.py "$BOT_COMMAND" "$GITHUB_EVENT_PATH" | ||
| else | ||
| python openwisp-utils/.github/actions/bot-autoassign/__main__.py "$BOT_COMMAND" | ||
| fi |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
Add no-side-effect assertions for skip paths.
Since these now return handled=True, please also assert they do not perform assignment-response side effects (e.g., no
repo.get_issue/ no issue comment creation).Based on learnings: Changes: Update tests to cover non-trivial changes and ensure proper validation of modified behavior.
Also applies to: 307-307
🤖 Prompt for AI Agents