Skip to content

Label PRs with modified addons#300

Open
sbidoul wants to merge 7 commits intoOCA:masterfrom
acsone:label-pr-modified-addons
Open

Label PRs with modified addons#300
sbidoul wants to merge 7 commits intoOCA:masterfrom
acsone:label-pr-modified-addons

Conversation

@sbidoul
Copy link
Copy Markdown
Member

@sbidoul sbidoul commented Jul 22, 2024

closes #265

This adds a addon:{addon_name} and a series:{branch_name} labels. Note: distinguishing by modification type can be added later.

With this it should become much easier to write tools to be notified about modifications to addons of interest.

@sbidoul sbidoul force-pushed the label-pr-modified-addons branch from bc85ee4 to 5c7b4e5 Compare July 22, 2024 15:16
@sbidoul sbidoul force-pushed the label-pr-modified-addons branch from 5c7b4e5 to 93cc406 Compare July 22, 2024 15:24
@hhgabelgaard
Copy link
Copy Markdown

@sbidoul Why not use Milestone for the branch series tagging?
Like its done with the migration issues
And manually in som OCA repos

@sbidoul
Copy link
Copy Markdown
Member Author

sbidoul commented Nov 28, 2024

Why not use Milestone for the branch series tagging? Like its done with the migration issues And manually in som OCA repos

We could and probably should.

But I always have been thinking that this is a misuse of Milestones which are meant to manage the next release of a project. On small repos like MIS Builder I have sometimes used the milestone to that end.

@legalsylvain
Copy link
Copy Markdown
Collaborator

Hi @sbidoul
thanks for this contribution.

I deployed this PR on GRAP bot. It doesn't seems to work. Is it working in Acsone context ?

as you can see, in the logs :

  • there is the tasks oca_github_bot.tasks.label_modified_addons.label_modified_addons in the list

But when the a new PR is opened, the following task are executed : mention_maintainer.mention_maintainer and tag_needs_review.tag_needs_review but no label_modified_addons

Did I missed something ? (I didnt' touched the environment file).

Original PR : grap/grap-odoo-business#229


worker_1   | [tasks]
worker_1   |   . oca_github_bot.tasks.add_pr_comment.add_pr_comment
worker_1   |   . oca_github_bot.tasks.delete_branch.delete_branch
worker_1   |   . oca_github_bot.tasks.heartbeat.heartbeat
worker_1   |   . oca_github_bot.tasks.label_modified_addons.label_modified_addons
worker_1   |   . oca_github_bot.tasks.main_branch_bot.main_branch_bot
worker_1   |   . oca_github_bot.tasks.main_branch_bot.main_branch_bot_all_repos
worker_1   |   . oca_github_bot.tasks.mention_maintainer.mention_maintainer
worker_1   |   . oca_github_bot.tasks.merge_bot.merge_bot_start
worker_1   |   . oca_github_bot.tasks.merge_bot.merge_bot_status
worker_1   |   . oca_github_bot.tasks.migration_issue_bot.migration_issue_start
worker_1   |   . oca_github_bot.tasks.rebase_bot.rebase_bot_start
worker_1   |   . oca_github_bot.tasks.tag_approved.tag_approved
worker_1   |   . oca_github_bot.tasks.tag_needs_review.tag_needs_review
worker_1   |   . oca_github_bot.tasks.tag_ready_to_merge.tag_ready_to_merge
worker_1   | 
worker_1   | [2026-03-31 15:56:42,941: INFO/MainProcess] Connected to redis://queue:6379//
worker_1   | [2026-03-31 15:56:42,943: INFO/MainProcess] mingle: searching for neighbors
worker_1   | [2026-03-31 15:56:43,951: INFO/MainProcess] mingle: all alone
worker_1   | [2026-03-31 15:56:43,968: INFO/MainProcess] celery@19280130fc68 ready.
worker_1   | [2026-03-31 15:56:46,241: INFO/MainProcess] Events of group {task} enabled by remote.
bot_1      | DEBUG:celery.utils.functional:
bot_1      | def mention_maintainer(*args, **kwargs):
bot_1      |     return 1
bot_1      | 
bot_1      | INFO:aiohttp.access:140.82.115.30 [31/Mar/2026:15:57:17 +0000] "POST / HTTP/1.1" 200 130 "-" "GitHub-Hookshot/294d65e"
worker_1   | [2026-03-31 15:57:17,204: INFO/MainProcess] Task oca_github_bot.tasks.mention_maintainer.mention_maintainer[563b4991-7b6d-4dd4-994c-20bffc4ca5a0] received
worker_1   | [2026-03-31 15:57:17,207: INFO/ForkPoolWorker-2] Building a url from ('https://api.github.com', 'repos', 'grap', 'grap-odoo-business', 'pulls', '229')
worker_1   | [2026-03-31 15:57:17,207: INFO/ForkPoolWorker-2] Missed the cache building the url
worker_1   | [2026-03-31 15:57:17,591: INFO/ForkPoolWorker-2] JSON was returned
worker_1   | [2026-03-31 15:57:19,187: INFO/ForkPoolWorker-2] oca_github_bot.tasks.mention_maintainer.mention_maintainer[563b4991-7b6d-4dd4-994c-20bffc4ca5a0]: Comment Hi @quentinDupont,
worker_1   | some modules you are maintaining are being modified, check this out!
worker_1   | [2026-03-31 15:57:19,697: INFO/ForkPoolWorker-2] JSON was returned
worker_1   | [2026-03-31 15:57:19,699: INFO/ForkPoolWorker-2] Task oca_github_bot.tasks.mention_maintainer.mention_maintainer[563b4991-7b6d-4dd4-994c-20bffc4ca5a0] succeeded in 2.492654458001198s: <IssueComment [github-grap-bot]>
bot_1      | INFO:aiohttp.access:140.82.115.113 [31/Mar/2026:15:57:20 +0000] "POST / HTTP/1.1" 200 130 "-" "GitHub-Hookshot/294d65e"
bot_1      | INFO:aiohttp.access:140.82.115.38 [31/Mar/2026:15:57:20 +0000] "POST / HTTP/1.1" 200 130 "-" "GitHub-Hookshot/294d65e"
bot_1      | INFO:aiohttp.access:140.82.115.24 [31/Mar/2026:15:57:21 +0000] "POST / HTTP/1.1" 200 130 "-" "GitHub-Hookshot/294d65e"
bot_1      | INFO:aiohttp.access:140.82.115.106 [31/Mar/2026:15:57:21 +0000] "POST / HTTP/1.1" 200 130 "-" "GitHub-Hookshot/294d65e"
bot_1      | INFO:aiohttp.access:140.82.115.31 [31/Mar/2026:15:57:21 +0000] "POST / HTTP/1.1" 200 130 "-" "GitHub-Hookshot/294d65e"
bot_1      | INFO:aiohttp.access:140.82.115.153 [31/Mar/2026:15:57:21 +0000] "POST / HTTP/1.1" 200 130 "-" "GitHub-Hookshot/294d65e"
bot_1      | INFO:aiohttp.access:140.82.115.243 [31/Mar/2026:15:57:21 +0000] "POST / HTTP/1.1" 200 130 "-" "GitHub-Hookshot/294d65e"
bot_1      | INFO:aiohttp.access:140.82.115.160 [31/Mar/2026:15:57:24 +0000] "POST / HTTP/1.1" 200 130 "-" "GitHub-Hookshot/294d65e"
bot_1      | INFO:aiohttp.access:140.82.115.123 [31/Mar/2026:15:57:24 +0000] "POST / HTTP/1.1" 200 130 "-" "GitHub-Hookshot/294d65e"
bot_1      | INFO:aiohttp.access:140.82.115.73 [31/Mar/2026:15:57:25 +0000] "POST / HTTP/1.1" 200 130 "-" "GitHub-Hookshot/294d65e"
bot_1      | INFO:aiohttp.access:140.82.115.148 [31/Mar/2026:15:57:25 +0000] "POST / HTTP/1.1" 200 130 "-" "GitHub-Hookshot/294d65e"
bot_1      | INFO:aiohttp.access:140.82.115.151 [31/Mar/2026:15:57:44 +0000] "POST / HTTP/1.1" 200 130 "-" "GitHub-Hookshot/294d65e"
bot_1      | INFO:aiohttp.access:140.82.115.84 [31/Mar/2026:15:57:44 +0000] "POST / HTTP/1.1" 200 130 "-" "GitHub-Hookshot/294d65e"
bot_1      | DEBUG:celery.utils.functional:
bot_1      | def tag_needs_review(*args, **kwargs):
bot_1      |     return 1
bot_1      | 
bot_1      | INFO:aiohttp.access:140.82.115.99 [31/Mar/2026:15:57:44 +0000] "POST / HTTP/1.1" 200 130 "-" "GitHub-Hookshot/294d65e"
worker_1   | [2026-03-31 15:57:44,508: INFO/MainProcess] Task oca_github_bot.tasks.tag_needs_review.tag_needs_review[4092bef3-db2b-42ad-8403-9a371ad98d46] received
worker_1   | [2026-03-31 15:57:44,511: INFO/ForkPoolWorker-2] Building a url from ('https://api.github.com', 'repos', 'grap', 'grap-odoo-business')
worker_1   | [2026-03-31 15:57:44,511: INFO/ForkPoolWorker-2] Missed the cache building the url
bot_1      | INFO:aiohttp.access:140.82.115.33 [31/Mar/2026:15:57:44 +0000] "POST / HTTP/1.1" 200 130 "-" "GitHub-Hookshot/294d65e"
worker_1   | [2026-03-31 15:57:44,917: INFO/ForkPoolWorker-2] JSON was returned
worker_1   | [2026-03-31 15:57:44,919: INFO/ForkPoolWorker-2] Building a url from ('https://api.github.com/repos/grap/grap-odoo-business', 'pulls', '229')
worker_1   | [2026-03-31 15:57:44,919: INFO/ForkPoolWorker-2] Missed the cache building the url
worker_1   | [2026-03-31 15:57:45,306: INFO/ForkPoolWorker-2] JSON was returned
worker_1   | [2026-03-31 15:57:45,601: INFO/ForkPoolWorker-2] JSON was returned
worker_1   | [2026-03-31 15:57:45,602: INFO/ForkPoolWorker-2] Building a url from ('https://api.github.com/repos/grap/grap-odoo-business/issues/229', 'labels')
worker_1   | [2026-03-31 15:57:45,602: INFO/ForkPoolWorker-2] Missed the cache building the url
worker_1   | [2026-03-31 15:57:45,926: INFO/ForkPoolWorker-2] JSON was returned
worker_1   | [2026-03-31 15:57:45,926: INFO/ForkPoolWorker-2] Building a url from ('https://api.github.com/repos/grap/grap-odoo-business/issues/229', 'labels')
worker_1   | [2026-03-31 15:57:46,772: INFO/ForkPoolWorker-2] JSON was returned
worker_1   | [2026-03-31 15:57:46,774: INFO/ForkPoolWorker-2] Task oca_github_bot.tasks.tag_needs_review.tag_needs_review[4092bef3-db2b-42ad-8403-9a371ad98d46] succeeded in 2.263711717998376s: None
bot_1      | INFO:aiohttp.access:140.82.115.63 [31/Mar/2026:15:57:48 +0000] "POST / HTTP/1.1" 200 130 "-" "GitHub-Hookshot/294d65e"


@sbidoul
Copy link
Copy Markdown
Member Author

sbidoul commented Mar 31, 2026

@legalsylvain I think you need to enable it explicitly with BOT_TASKS in the config?

@legalsylvain
Copy link
Copy Markdown
Collaborator

@legalsylvain I think you need to enable it explicitly with BOT_TASKS in the config?

Hum, I don't think so. By default, BOT_TASKS = all

Here is my current configuration. Other task like mention_maintainer, tag_needs_review, rebase_bot are working correctly without any explicit mention.


# Coma separated list of task to run
# By default all configured tasks are run.
# Available tasks:
#  delete_branch,tag_approved,tag_ready_to_merge,gen_addons_table,
#  gen_addons_readme,gen_addons_icon,setuptools_odoo,mention_maintainer,
#  merge_bot,rebase_bot,merge_bot_towncrier,tag_needs_review
#BOT_TASKS=all

# Coma separated list of task to ignore
BOT_TASKS_DISABLED=gen_addons_icon,setuptools_odoo


Ref : https://github.com/OCA/oca-github-bot/blob/master/environment.sample#L37-L46

Is this PR in production in any bot deployment ? (OCA / acsone / other ?)

thanks !

@sbidoul
Copy link
Copy Markdown
Member Author

sbidoul commented Apr 1, 2026

I have not deployed this in production myself anywhere.

@legalsylvain I think I spotted a missing import, which I just added, can you try again?

@legalsylvain
Copy link
Copy Markdown
Collaborator

the trigger is catched ! Thanks for your patch, @sbidoul !

then, first error.

First error worker_1 | [2026-04-01 09:01:55,996: ERROR/ForkPoolWorker-1] Task oca_github_bot.tasks.label_modified_addons.label_modified_addons[4edc8d92-4f3b-4540-8818-a4e9d545d10b] raised unexpected: TypeError("label_modified_addons() missing 1 required positional argument: 'dry_run'") worker_1 | Traceback (most recent call last): worker_1 | File "/app/lib/python3.12/site-packages/celery/app/trace.py", line 453, in trace_task worker_1 | R = retval = fun(*args, **kwargs) worker_1 | ^^^^^^^^^^^^^^^^^^^^ worker_1 | File "/app/lib/python3.12/site-packages/celery/app/trace.py", line 736, in __protected_call__ worker_1 | return self.run(*args, **kwargs) worker_1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ worker_1 | File "/app/src/oca-github-bot/src/oca_github_bot/config.py", line 27, in func_wrapper worker_1 | return func(*args, **kwargs) worker_1 | ^^^^^^^^^^^^^^^^^^^^^ worker_1 | TypeError: label_modified_addons() missing 1 required positional argument: 'dry_run'

Fixed by acsone#4

Then, it works ! See the result of grap/grap-odoo-business#229

image

However, this is a error in the log, but I didn't understood. do you have any idea ?

Second error

worker_1 | [2026-04-01 09:18:52,206: INFO/ForkPoolWorker-1] Building a url from ('https://api.github.com/repos/grap/grap-odoo-business/issues/229', 'labels')
bot_1 | INFO:aiohttp.access:140.82.115.41 [01/Apr/2026:09:18:52 +0000] "POST / HTTP/1.1" 200 130 "-" "GitHub-Hookshot/9b72932"
bot_1 | INFO:aiohttp.access:140.82.115.121 [01/Apr/2026:09:18:52 +0000] "POST / HTTP/1.1" 200 130 "-" "GitHub-Hookshot/9b72932"
bot_1 | INFO:aiohttp.access:140.82.115.103 [01/Apr/2026:09:18:52 +0000] "POST / HTTP/1.1" 200 130 "-" "GitHub-Hookshot/9b72932"
bot_1 | INFO:aiohttp.access:140.82.115.144 [01/Apr/2026:09:18:52 +0000] "POST / HTTP/1.1" 200 130 "-" "GitHub-Hookshot/9b72932"
worker_1 | [2026-04-01 09:18:53,045: INFO/ForkPoolWorker-1] JSON was returned
worker_1 | [2026-04-01 09:18:53,046: INFO/ForkPoolWorker-1] Building a url from ('https://api.github.com/repos/grap/grap-odoo-business/issues/229', 'labels')
bot_1 | INFO:aiohttp.access:140.82.115.95 [01/Apr/2026:09:18:53 +0000] "POST / HTTP/1.1" 200 130 "-" "GitHub-Hookshot/9b72932"
worker_1 | [2026-04-01 09:18:54,054: INFO/ForkPoolWorker-1] JSON was returned
worker_1 | [2026-04-01 09:18:54,055: INFO/ForkPoolWorker-1] Building a url from ('https://api.github.com/repos/grap/grap-odoo-business/issues/229', 'labels')
bot_1 | INFO:aiohttp.access:140.82.115.126 [01/Apr/2026:09:18:53 +0000] "POST / HTTP/1.1" 200 130 "-" "GitHub-Hookshot/9b72932"
bot_1 | INFO:aiohttp.access:140.82.115.57 [01/Apr/2026:09:18:54 +0000] "POST / HTTP/1.1" 200 130 "-" "GitHub-Hookshot/9b72932"
bot_1 | INFO:aiohttp.access:140.82.115.168 [01/Apr/2026:09:18:54 +0000] "POST / HTTP/1.1" 200 130 "-" "GitHub-Hookshot/9b72932"
worker_1 | [2026-04-01 09:18:54,938: INFO/ForkPoolWorker-1] JSON was returned
worker_1 | [2026-04-01 09:18:54,939: INFO/ForkPoolWorker-1] Building a url from ('https://api.github.com/repos/grap/grap-odoo-business/issues/229', 'labels')
bot_1 | INFO:aiohttp.access:140.82.115.62 [01/Apr/2026:09:18:55 +0000] "POST / HTTP/1.1" 200 130 "-" "GitHub-Hookshot/9b72932"
worker_1 | [2026-04-01 09:18:55,744: INFO/ForkPoolWorker-1] JSON was returned
worker_1 | [2026-04-01 09:18:55,745: INFO/ForkPoolWorker-1] Building a url from ('https://api.github.com/repos/grap/grap-odoo-business/issues/229', 'labels')
bot_1 | INFO:aiohttp.access:140.82.115.59 [01/Apr/2026:09:18:55 +0000] "POST / HTTP/1.1" 200 130 "-" "GitHub-Hookshot/9b72932"
bot_1 | INFO:aiohttp.access:140.82.115.169 [01/Apr/2026:09:18:56 +0000] "POST / HTTP/1.1" 200 130 "-" "GitHub-Hookshot/9b72932"
worker_1 | [2026-04-01 09:18:56,142: ERROR/ForkPoolWorker-1] Task oca_github_bot.tasks.label_modified_addons.label_modified_addons[a363cac8-a8e5-4cc0-9a51-7e9a9215bd17] raised unexpected: <UnprocessableEntity [Validation Failed]>
worker_1 | Traceback (most recent call last):
worker_1 | File "/app/lib/python3.12/site-packages/celery/app/trace.py", line 453, in trace_task
worker_1 | R = retval = fun(*args, **kwargs)
worker_1 | ^^^^^^^^^^^^^^^^^^^^
worker_1 | File "/app/lib/python3.12/site-packages/celery/app/trace.py", line 736, in protected_call
worker_1 | return self.run(*args, **kwargs)
worker_1 | ^^^^^^^^^^^^^^^^^^^^^^^^^
worker_1 | File "/app/src/oca-github-bot/src/oca_github_bot/config.py", line 27, in func_wrapper
worker_1 | return func(*args, **kwargs)
worker_1 | ^^^^^^^^^^^^^^^^^^^^^
worker_1 | File "/app/src/oca-github-bot/src/oca_github_bot/tasks/label_modified_addons.py", line 39, in label_modified_addons
worker_1 | _label_modified_addons(gh, org, repo, pr, dry_run)
worker_1 | File "/app/src/oca-github-bot/src/oca_github_bot/tasks/label_modified_addons.py", line 32, in _label_modified_addons
worker_1 | github.gh_call(gh_issue.add_labels, new_label)
worker_1 | File "/app/src/oca-github-bot/src/oca_github_bot/github.py", line 38, in gh_call
worker_1 | return func(*args, **kwargs)
worker_1 | ^^^^^^^^^^^^^^^^^^^^^
worker_1 | File "/app/lib/python3.12/site-packages/github3/decorators.py", line 24, in auth_wrapper
worker_1 | return func(self, *args, **kwargs)
worker_1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
worker_1 | File "/app/lib/python3.12/site-packages/github3/issues/issue.py", line 99, in add_labels
worker_1 | json = self._json(self._post(url, data=args), 200)
worker_1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
worker_1 | File "/app/lib/python3.12/site-packages/github3/models.py", line 161, in _json
worker_1 | raise exceptions.error_for(response)
worker_1 | github3.exceptions.UnprocessableEntity: 422 Validation Failed
bot_1 | INFO:aiohttp.access:140.82.115.58 [01/Apr/2026:09:18:56 +0000] "POST / HTTP/1.1" 200 130 "-" "GitHub-Hookshot/9b72932"
bot_1 | INFO:aiohttp.access:140.82.115.148 [01/Apr/2026:09:18:56 +0000] "POST / HTTP/1.1" 200 130 "-" "GitHub-Hookshot/9b72932"
bot_1 | DEBUG:celery.utils.functional:
bot_1 | def tag_needs_review(*args, **kwargs):
bot_1 | return 1

@legalsylvain
Copy link
Copy Markdown
Collaborator

I get the second error. An annoying github limitation. see :

-> addon:account_invoice_supplierinfo_update_standard_price

image

[FIX] label_modified_addons: dry_run is allway optional arg
@sbidoul
Copy link
Copy Markdown
Member Author

sbidoul commented Apr 1, 2026

Hm, that's annoying indeed. I guess that pretty much kills the idea...

@legalsylvain
Copy link
Copy Markdown
Collaborator

Hm, that's annoying indeed. I guess that pretty much kills the idea...

I developped a work around here acsone#5

  • if size < 50 -> as before,
  • if size > 50 we keep 44 chars, and add a space and 5 chars that are a small hash of the module name

We populate labels with the full create method, so we can set a description. (there is no limitation description field)

You can take a look on the result.

image

WDYT ?

  • the hash is not ultra user friendly, but at least, all labels are created and unique. It is possible to search.
  • it doesn't occures a lot. I think some modules in a few repo. for exemple, there is no problem in server-tools, and only two in OCA/web repo:

addons:web_widget_product_label_section_and_note_full_label
addons:web_widget_product_label_section_and_note_name_visibility

@sbidoul
Copy link
Copy Markdown
Member Author

sbidoul commented Apr 2, 2026

Interesting approach. My initial use case was to search by label though so that would be a bit more complicated as we'd need a helper to compute the label with hash from the addon name. But feasible I guess.

@legalsylvain
Copy link
Copy Markdown
Collaborator

legalsylvain commented Apr 2, 2026

Interesting approach. My initial use case was to search by label though so that would be a bit more complicated as we'd need a helper to compute the label with hash from the addon name. But feasible I guess.

  • if you want to implement search for a tool / by API, you can easily implement the 5 lines that compute the name with the hash.
  • if you want to use it manually, you can do it without knowing the hash, because the search is done in the description field. Step to reproduce :

-> go to https://github.com/grap/grap-odoo-business/pulls
-> Open the label filter search bar
-> enter the full name of your module (account_invoice_supplierinfo_update_standard_price)
-> the label with the hash is proposed. (the description with the full name is proposed below).

image

As a result :

  • it is possible to search & filter
  • The label name will look a bit ugly for 3–5% of OCA modules. (not a big deal). 3-5 is approximative, because I could not find in odoo-community.org the list of all OCA modules. (like in V14, I think that there is a pending refactor regarding the github-connector features) However, I honestly don't think there are many modules that are longer than 43 characters. (50 - len("addons:"))

WDYT ?

@sbidoul
Copy link
Copy Markdown
Member Author

sbidoul commented Apr 2, 2026

WDYT ?

I think good things :) Sounds cool. Thanks for picking up this topic!

legalsylvain and others added 3 commits April 2, 2026 12:29
if label name is too long, it is cut, and ended by an hash of the module name.
the module name is present in the description of the label

- factor out function that computes the shortened label
- use 'mod:' instead of 'addon:'
- add MODULE_LABEL_COLOR as new configuration

Co-authored-by: Stéphane Bidoul <stephane.bidoul@acsone.eu>
@legalsylvain
Copy link
Copy Markdown
Collaborator

Ready to be merged for me.
@hhgabelgaard, @manuel-florido, @ValentinVinagre, @sebastienbeau a final review ?

See #265

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Autolabel PRs with the name of new / modified addons

3 participants