Commit Graph

2019 Commits

Author SHA1 Message Date
Xavier Morel
6d5c539c77 [IMP] *: fork with main_branch_only
Should limit the risk of cases where the fork contains outdated
versions of the reference branches and we end up with odd outdated /
not up to date basis for branches & updates, which can lead to
confusing situations.
2025-02-06 12:41:03 +01:00
Xavier Morel
3b0e59a3cd [IMP] conftest: fstring-ify repo forking
Also use the fork's response for the fork's own URL instead of
composing it by hand.
2025-02-06 12:41:03 +01:00
Xavier Morel
e065206f79 [IMP] conftest: minor cleanups to repo creation
- Use f-strings where appropriate.
- Get the repo url from github instead of composing it by hand
- Resolve URI template for the contents endpoint instead of
  hand-building the URL. URI template implementation is janky AF.
2025-02-06 12:40:54 +01:00
Xavier Morel
88453aa462 [FIX] conftest: assert tunnel response is a proper URL
Since the tunnel value is now a path to a script to run (and get the
public facing address out of), it's pretty easy to give the path to
the wrong program e.g. `--tunnel ngrok` will run ngrok itself, which
is going to yield an error message and do nothing, and then break when
we try to use the nonsensical result (e.g. an empty string or an error
message) as a URL.

So assert that the result does parse as a URL-ish with at least a
scheme and netloc.
2025-02-04 08:16:31 +01:00
Xavier Morel
c67bb64537 [ADD] *: fw=skipmerge
Skipmerge creates forward-ports before the source PR is even merged.

- In a break from the norm, skipmerge will create forwardports even in
  the face of conflicts.
- It will also not *detach* pull requests in case of conflicts, this
  is so the source PR can be updated and the update correctly cascades
  through the stack (likewise for any intermediate PR though *that*
  will detach as usual).

Note that this doesn't really look at outstandings, especially as they
were recently updated, so it might need to be fixed up in case of
freakout, but I feel like that should not be too much of an issue, the
authors will just get their FW reminders earlier than usual. If that's
a hassle we can always update the reminder job to ignore forward ports
whose source is not merged I guess.

Fixes #418
2025-02-04 08:05:15 +01:00
Xavier Morel
12ac32e169 [IMP] forwardport: avoid a full scan when we just want a boolean
There should only be 1 PR with a given parent at most anyway, but
still if it's a boolean we can stop at the first occurrence if any. pg
might even be able to do something more efficient in that case.
2025-02-03 15:14:08 +01:00
Xavier Morel
981760430c [IMP] *: cleanup dead locals 2025-02-03 15:13:49 +01:00
Xavier Morel
9fa106f277 [FIX] runbot_merge: squash update on ignored PR events
Apparently when I updated the logic of the lookup to that of search I
forgot to update the *method* to `search`.
2025-02-03 08:03:08 +01:00
Xavier Morel
d7da328b9f [IMP] runbot_merge: relax requirements for setting the merge method
Not entirely sure about just allowing any PR author to set the merge
method as it gives them a lot more control over commits (via the PR
message), and I'm uncertain about the ramifications of doing that.

However if the author of the PR is classified as an
employee (via a provisioned user linked to the github account) then
allow it. Should not be prone to abuse at least.

Fixes #1036
2025-01-30 11:53:52 +01:00
Xavier Morel
1099fc5119 [IMP] runbot_merge: check squash on every PR event
All `pull_request` events seem to provide the `commits` count
property. As such we can use them all to check the `squash` state even
if we don't otherwise care for the event.

Also split out notifying an approved pull request about its missing
merge method into a separate cron from the one notifying a PR that its
siblings are ready.

Fixes #1036
2025-01-30 11:53:44 +01:00
Xavier Morel
645a10a7ca [IMP] runbot_merge: de-randomise fw/bp uniquifier
The forward port process adds a uniquifier to the branch name as it's
possible to reuse branch names for different sets of PRs (and some
individuals do that systematically) which can cause collisions in the
fw branches.

Originally this uniquifier was random by necessity, however now that
batches are reified and forward port is performed batch-wise we don't
need the randomness we can just use the source batch's id as it's
unique per sequence of forward ports. This means it'll eventually be
possible for an external system to retrieve the source(s) of a forward
port by reading the batch object, and it's also possible to correlate
forward ports through the batch id (although not possible to find the
source set without access to the mergebot's information).

Do the same thing for backports, because why not.
2025-01-30 09:57:43 +01:00
Xavier Morel
25cfaa95a5 [IMP] runbot_merge: remove team when disabling user 2025-01-29 15:39:40 +01:00
Xavier Morel
1097c5f19e [ADD] runbot_merge: support for file creation in patch
Had been left out of the original impl, but turns out it might be
useful e.g. when a new lang gets added to the i18n export.

Fixes #1042
2025-01-29 13:29:53 +01:00
Xavier Morel
54337aeccc [IMP] runbot_merge: rework (de)provisioning
- Update `get_reviewers` to returning all active users, as that makes
  more sense for the server side operations, this is now redundant
  with `list_users`, so eventually internals should be fixed and it
  removed.
- Update `remove_users` to deactivate the user as well as move it to
  portal, since the mergebot doesn't use portal keeping enabled portal
  users doesn't make much sense.
- Reorganise `provision_user` to make the update path more obvious.

Fixes #968
2025-01-28 16:11:14 +01:00
Xavier Morel
62dd3ee636 [ADD] tests: shitty support for context
The API doesn't correctly match the server-side `Environment`/`Model`
API, but neither did `with_user`, so probably fine for now, can
revisit this thing if I start needing it more than once in a blue
moon.
2025-01-28 15:53:04 +01:00
Xavier Morel
86796ed730 [FIX] runbot_merge: project fixture
Turns out this has a hard dependency on `rolemap` to ensure
`conf['github']['name']` is populated.
2025-01-28 15:13:47 +01:00
Xavier Morel
892fce4ddf [ADD] forwardport: email reminders
After 6 months of sitting unmerged, forward ports will now trigger a
monthly email.

Or would, if an email server was configured on the mergebot, but
adding this now should allow debugging its working and tracking the
generation of emails through the "Delivery Failed" collection. This
way if we ever decide to actually do the thing we can just enable an
SMTP server.

Fixes #801
2025-01-28 07:51:27 +01:00
Xavier Morel
896624674f [IMP] forwardport: show a user's outstanding tally in the main alert
Previously the alert would show the total number of outstanding
forward ports, which most people don't care about (if they're even
logged which probably isn't the case), so that was mostly useful
for... me.

Add the current user's tally to the message as well. If the user is
logged. Which is always, because the alert only shows up if the user
has read access to PRs.

Fixes #801
2025-01-24 15:54:58 +01:00
Xavier Morel
63a4916d00 [FIX] forwardport: avoid double counting PRs for teams
In the case where both author and reviewer of a PR have the same
team (which is very common e.g. self review or a team member approving
your PR) then the `outstanding_per_group` entry would be incremented
twice, leading to overcounting outstanding forward ports for the team.

Fixes #801
2025-01-24 15:20:19 +01:00
Xavier Morel
edaf507863 [IMP] runbot_merge: make space characters in regexes clearer
pycharm is a bit dumb so it considers `[ ]` to be unnecessary even in
`re.VERBOSE` regexes. But it has a bit of a point in that it's not
super clear, so inject the space characters by (unicode) name, the
behaviour should be the exact same but the regexes should be slightly
less opaque.
2025-01-24 14:53:47 +01:00
Xavier Morel
60b84490c6 [IMP] forwardport: classify FP as outstanding a week after creation
Rather than a week after *source merge*.

Fixes #801
2025-01-24 14:53:47 +01:00
Xavier Morel
942570e60a [IMP] forwardport: outstanding FP reminders
- only remind weekly initially (not daily)
- root reminders on the forward port's creation, not the source's
  merge date
- cap reminder interval at 4 weeks (instead of doubling every time)
- track reminders on forward ports, don't share between siblings
- remove `forwardport_updated_before` from the testing system, it's
  now possible to just update `reminder_next` to a past date and see
  if it gets triggered (it should to nothing on sources, or on forward
  port in a state which does not warrant concern)

Fixes #801
2025-01-24 14:53:34 +01:00
Xavier Morel
916f144163 [IMP] runbot_merge: staging form
Link stagings to the staging commits instead of the commits directly
in order to have the repository name and not need to try the commit on
every repository.

Also make the trees editable, in combination with `readonly="1"` this
does not make the trees editable but does prevent clicking on a row to
open a dialog with the linked objects, which is convenient if one
wants to copy the commit hash.
2025-01-20 16:04:02 +01:00
Xavier Morel
f3dd3e6fde [FIX] runbot_merge: make staging serialization more useful
Having the staged and merged heads via an easy to reach endpoint is
nice, but having *just* the hashes is not as it requires basically
exhaustively checking commits against repos to see which is
where. That's annoying.

Make the head serializations a map of repository to commit
hash. That's a lot more convenient.
2025-01-20 15:48:47 +01:00
Xavier Morel
f900eb68b6 [FIX] runbot_merge: my pager lied to me
Hopefully this is the last fix to the patcher. From the start of the
implementation I relied on the idea that `git show` was adding a line
composed of a single space (and a newline) before and after the patch
message, as that is what I observed in my terminal, and it's
consistent with RFC 3676 signatures (two dashes, a space, and a
newline).

Turns out that single space, while present in my terminal indeed, was
completely made up by `less(1)`. `git show` itself doesn't generate
that, neither does it appear when using most pagers, or even when
piping the output of `less` into something (a file, an other pager,
...). It's pretty much just something `less(1)` sends to a terminal
during interactive sessions to fuck with you.

Fixes #1037
2025-01-15 08:51:28 +01:00
Xavier Morel
7d5c3dcb73 [IMP] mergebot: staging endpoints
- use lingo `staged` and `merged` for clarity (instead of `heads` and
  `commits`)
- convert from json-rpc to regular HTTP to make easier to call
- add the staged and merged heads when returning staging data
- return more complete objects (rather than a list of ids) when
  matching stagings based on commits / heads

Fixes #1018
2025-01-14 15:05:03 +01:00
Xavier Morel
89411f968f [IMP] runbot_merge: return proper http responses from webhooks
The old controller system required `type='json'` which only did
JSON-RPC and prevented returning proper responses.

As of 17.0 this is not the case anymore, `type='http'` controllers can
get `content-type: application/json` requests just fine and return
whatever they want. So change that:

- `type='json'`.
- Return `Response` objects with nice status codes (and text
  mimetypes, as otherwise werkzeug defaults to html).
- Update ping to bypass normal flow as otherwise it requires
  authentication and event sources which is annoying (it might be a
  good idea to have both in order to check for configuration, however
  it's not possible to just send a ping via the webhook UI on github
  so not sure how useful that would be).
- Add some typing and improve response messages while at it.

Note: some "internal" errors (e.g. ignoring event actions) are
reported as successes because as far as I can tell webhooks only
support success (2xy) / failure (4xy, 5xy) and an event that's ignored
is not really *failed* per se.

Some things are reported as failures even though they are on the edge
because that can be useful to see what's happening e.g. comment too
large or unable to lock rows.

Fixes #1019
2024-12-18 14:07:22 +01:00
Xavier Morel
0fd254b5fe [IMP] runbot_merge: auto-trigger cron for issue closing
Probably should create a mixin for this: when a model is used as a
task queue for a cron, the cron should automatically be triggered on
creation. Requiring an explicit trigger after a creation is error
prone and increase the risks that some of the triggers will be
forgotten/missed.
2024-12-16 09:11:19 +01:00
Xavier Morel
991cae1af0 [IMP] forwardport: test read_tree() v read_tree(recursive=True) 2024-12-16 09:11:19 +01:00
Xavier Morel
594f5988b8 [IMP] conftest cleanup
- merge and sort imports
- convert a few legacy string formattings to f-strings
2024-12-16 09:11:19 +01:00
Xavier Morel
7eeeb18af4 [ADD] tests: support creating repos without webhooks
Most of the repos we create we want to hook into the odoo instance,
but in some rare cases we want repositories for just push/pull, in
that case webhooks configuration just creates log noise (as the events
get rejected on intake).
2024-12-16 09:11:19 +01:00
Xavier Morel
5210cfb59f [IMP] tests: better tree-reading support
- add support for reading commit entries
- add support for reading tree entries in non-recursive mode

Previously the helper would only return blob entries, which does not
allow testing submodule support.
2024-12-16 09:11:19 +01:00
Xavier Morel
a0e237fbfc [IMP] runbot_merge: debug prints in the ngrok tunnel script 2024-12-16 09:11:19 +01:00
Xavier Morel
2deeb914cc [REM] tests: capsys use
Seems like remnants of old debugging of the rate limiting, and can
create odd situations when it fires as it replaces `sys.stdout` with
an in-memory buffer, which doesn't have a `fileno()`, which breaks
`server._move`.
2024-12-16 09:11:19 +01:00
Xavier-Do
90d2906712 [IMP] runbot: remove ruff from default image
ruff is using another specific image, not useful anymore.
2024-12-11 09:57:03 +01:00
Xavier-Do
6bf1991c9d [FIX] runbot: make archive work when an error has no linked build 2024-12-10 10:45:38 +01:00
Xavier-Do
9c995d1f7c [FIX] runbot: add edition access to error content
This was forgotten during the refactoring. Needed to link error together
2024-12-10 10:45:38 +01:00
Christophe Monniez
f74391fc13 [FIX] runbot: avoid empty string in stored compute 2024-12-10 09:33:44 +01:00
Xavier Morel
2e107111f0 [ADD] runbot_merge: basic support for false positive detection
Adds a very limited ability to try and look for false positive /
non-determinstic staging errors. It tries to err on the side of
limiting false false positives, so it's likely to miss many.

Currently has no automation / reporting, just sets a flag on the
stagings which are strongly believed to have failed due to false
positives.

While at it, add link between a "root" staging and its splits. It's
necessary to clear the "false positive" flag, and surfacing it in the
UI could be useful one day.

Fixes #660
2024-12-09 16:02:28 +01:00
Xavier Morel
d6e1516f31 [IMP] runbot_merge: support arbitrary tunnel scripts
Rather than add individual tunnel methods to conftest, just allows
specifying a tunnel script and have that do whatever.

Protocol is uncomplicated: workers run the `$tunnel` with an arbitrary
port, script should create a tunnel to `localhost:$port`, print the
ingress of the tunnel to `STDOUT` with a terminating newline then
close `STDOUT`, and wait for `SIGINT` or `SIGTERM`, doing  whatever
cleanup they need when receiving either of those.

`ngrok` and `localtunnel` adapter scripts are provided out of the box,
though the ngrok one doesn't *really* work when using xdist without a
pre-spawned ngrok worker. Then again using xdist against github actual
is suicidal (because concurrency limits + rate limits) so likely
irrelevant.

Fixes #729
2024-12-09 16:02:28 +01:00
Xavier Morel
461db6a3e7 [ADD] runbot_merge: closing linked issues on merge
Requires parsing the commit messages as github plain doesn't collate
the info from there, but also the descriptions: apparently github only
adds those to the references if the PR targets the default
branch. That's not a limitation we want.

Meaning at the end of the day, the only thing we're calling graphql
for is explicit manual linking, which can't be tested without
extending the github API (and then would only be testable on DC), and
which I'm not sure anyone bothers with...

Limitations
-----------

- Links are retrieved on staging (so if one is added later it won't be
  taken in account).
- Only repository-local links are handled, not cross-repository.

Fixes #777
2024-12-09 16:02:28 +01:00
Xavier Morel
62fbda52a8 [IMP] runbot_merge: a PR can't be reopened if its batch is merged
In that case, ignore the reopen, close the PR, and tell the idiot to
fuck off.

Also the case where a PR is reopened while its batch is staged was
already handled, but probably not tested: it was implicit in
forcefully updating the HEAD of the PR, which triggers an unstage
since c8a06601a7.

Now that scenario is tested, which should lower the odds of breaking
it in the future.

Fixes #965
2024-12-09 16:02:28 +01:00
Xavier Morel
31f3edeea6 [IMP] runbot_merge: minor simplification of test_by_branch
Dedup' the application of statuses. Although it is somewhat slower do
keep applying them one by one to ensure all are required.
2024-12-09 16:02:28 +01:00
Xavier-Do
ee55c8c630 [FIX] runbot: add missing depends 2024-12-05 13:17:11 +01:00
Xavier-Do
4f3838b7e9 [FIX] runbot: fix bundle without batch display
In some case, when creating a bundle from the backend, it is possible
that the bundle has no batch at all, making _get_global_result() fail.
2024-12-05 09:09:52 +01:00
Christophe Monniez
58f0f8108a [FIX] runbot: import json for similar_ids
And small fix in fstring.
2024-12-04 11:03:41 +01:00
Xavier-Do
03a20398a1 [IMP] runbot: add forwarded for headers 2024-12-04 10:18:43 +01:00
Xavier-Do
c45f1a2dd6 [IMP] runbot: add qualifiers ir.model.fields 2024-12-04 10:17:21 +01:00
Christophe Monniez
65f2badd09 [IMP] runbot: add similar errors page
Add a page on error content showing errors with similar qualifiers.
2024-12-04 10:17:21 +01:00
Christophe Monniez
4bdd2e20b8 [IMP] runbot: permit to qualify build errors
Identifying build errors by fingerprint is not enough.
Most of the times we want to link build errors based on some criteria.

With this commit, a build error can be qualified by using regular
expressions that will extract informations.

Those informations will be stored in a jsondict field. That way, we can
find simmilar build errors when they share some qualifiers.

To extract information, the regular expression must use named group
patterns.

e.g:
`^Tour (?P<tour_name>\w+) failed at step (?P<tour_step>.+)`

The above regular expression should extract the tour name and tour step
from a build error and store them like:
`{ "tour_name": "article_portal_tour", "tour_step": "clik on 'Help'" }`

The field can be queried to find similar errors. Also, a button is added
on the Build Error Form to search for errors that share the same
qualifiers.
2024-12-04 10:17:21 +01:00