Skip to content

Conversation

@Williambraecky
Copy link
Contributor

  • Use webhook secrets with github (optional)
  • Store webhooks to be processed by the leader
  • automagically match prs with runbot errors if the pr_body contains the appropriate content

Comment on lines 98 to 103
pr_body_regex = r'^.*runbot.*error[^\d]*(\d+)[ \S]*\r?$'
error_ids = re.findall(
pr_body_regex,
self.pr_body,
re.IGNORECASE | re.MULTILINE
)
Copy link
Collaborator

@xmo-odoo xmo-odoo May 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the regex can be simplified to this:

Suggested change
pr_body_regex = r'^.*runbot.*error[^\d]*(\d+)[ \S]*\r?$'
error_ids = re.findall(
pr_body_regex,
self.pr_body,
re.IGNORECASE | re.MULTILINE
)
pr_body_regex =
error_ids = re.findall(
r'\brunbot.*error.*?(\d+)',
self.pr_body,
re.IGNORECASE | re.ASCII
)
  • there's no reason to limit the pattern to one match per line
  • \d+ is greedy so there's no need to end it with something wonky, especially not "space or non-whitespace"
  • no idea why \r is even there
  • by default re will consider e.g. to be a valid \d, which probably isn't desirable here

])
errors.fixing_pr_id = self
for error in errors:
error.message_post(body='Fixing pr automatically set through PR message')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be useful to log the user triggering this, and also maybe to first check that the author of the PR is a known / internal user to avoid abuse (as anyone can create a PR)

Use github secret and header verification to validate that the sender is
indeed github.
Decouples the hook processing from the controller, this ensures that
latency for the controller stays low while allowing more complex logic
during hook handling.
@xmo-odoo xmo-odoo force-pushed the 18.0-store-hooks-process-wbr branch from fb9861c to 16b37a2 Compare May 28, 2025 10:08
@Xavier-Do Xavier-Do force-pushed the 18.0-store-hooks-process-wbr branch 5 times, most recently from b4d247f to 97caf80 Compare May 28, 2025 13:02
Automatically link the pr with the build error if it contains anything
along the lines of `runbot.*error.*{id}`.
Among the changes:
 - Add a path for the build error act_window so that it include
   runbot-error
 - Fix the widget for `pr_body` in branch form view to use `text`
   instead of char as they are most likely multi line string.
@Xavier-Do Xavier-Do force-pushed the 18.0-store-hooks-process-wbr branch from 97caf80 to 2c82db7 Compare May 30, 2025 06:16
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.

3 participants