Commit Graph

795 Commits

Author SHA1 Message Date
Xavier-Do
36a35b14c8 [IMP] runbot: update gitignore for static databases 2019-12-18 14:31:49 +01:00
Xavier-Do
630e1d55f7 [IMP] runbot: custom python result
This commit add the possibility to add custom checks to python steps,
as well as ignoring triggered result if log of level error/warning
is not considered as a problem.
2019-12-18 14:31:49 +01:00
Christophe Monniez
6c64bbb49b [IMP] runbot: improve build log view
Co-authored-by: Xavier-Do <xdo@odoo.com>
2019-12-17 16:08:31 +01:00
Christophe Monniez
5552c16102 [IMP] runbot: create a broken symlink in all server sources
As the --upgrade-paths options does not work as expected in Odoo, a
symbolic link has to be created in odoo/addons/base/maintenance pointing
to the migration scripts.

The runbot uses Docker read-only volumes to access the sources that are
shared between builds, preventing the creation of such a link.

With this commit, a symbolic link is created right after the export of a
commit only when the repo is a "server" repo.

This link is broken outside of the Docker volumes but uses the mount
points of the sources inside the container.

Two ir.config_parameter's are used to enable and configure this feature:

* runbot_migration_ln: the relative path where the link should be placed
  (typically odoo/addons/base/maintenance)

* runbot_migration_repo_id: the id of the migration scripts repo, used
to determine the name of the mount point inside the Docker container

A change is also made in the "reverse dependcy build" to avoid the
creation of a build in the migration repo for each push in its
dependency. Simply set the no_build field on this migration repo.
2019-12-16 13:10:55 +01:00
Xavier-Do
8d20c2ce79 [IMP] runbot: add Commit to run_python steps context 2019-12-13 13:44:01 +01:00
Xavier-Do
2ed0b9c4d4 [FIX] runbot: ref_time rounding.
`getmtime` will return a 6 digit float when postgress will only store 5.
Depending on rounding, _get_refs have 1/2 chance to make an update
when it shouldn't. Rounding below psql precision before comparing and
storing should fix this.
2019-12-09 16:32:27 +01:00
Xavier-Do
e5a2f98c59 [IMP] runbot: store times in other tables.
Sometimes, sheduler may have a hard time to create build.
The transaction can be verry long when there are many repo and
a lot of new commits. Writing get_ref_time on repo will fail
due to concurrent update rollbacking the whole transaction.

This is supposedly because of hook occuring during the transaction.
With this new model, hook will only perform an insert, and shouldn't
interfer with ref_times.
2019-12-09 15:40:02 +01:00
Christophe Monniez
3f806416d6 [FIX] runbot: adapt test to new docker_state method 2019-12-06 11:40:38 +01:00
Xavier-Do
a3abdf8505 [IMP] runbot: add docker state
docker_is_running is ambiguous since we dont know if it was started once.
This new feature tries to add tools to know if a docker was started or not.

The main reason of this is that sometimes docker_run may take more than 15 seconds
creating unpredictable errors on build when the second step is launched and
the previous one is still running. Hopefully this fix will help to solve this
issue and detect late docker run.
2019-12-06 10:20:11 +01:00
Christophe Monniez
83651c408e [IMP] runbot: keep txt files when cleaning builds dirs 2019-12-04 16:20:17 +01:00
Xavier-Do
b69d40af59 [FIX] runbot: ignore rebuilds in _find_new_commits
When rebuilding a build/subbuild, the last commit of the branch
won't have the same sha of the branch last commit. find_new_commit
will kill the running builds in the branch and create a new one,
that may be a duplicate of one of the killed commits.

This fix only take normal builds into account when checking for
existing builds.
2019-12-04 15:55:08 +01:00
Xavier-Do
f2db93fc63 [FIX] runbot: create nginx.conf if not exist
When starting a new runbot, nginx.conf does not exist. This fix will
allow _reload_nginx to initialize it the first time.
2019-12-04 13:58:03 +01:00
Xavier-Do
7f8547f4ec [IMP] runbot: add log on get_param failure 2019-12-04 12:21:23 +01:00
Xavier-Do
12febd1920 [FIX] runbot: reintroduce try exept in get_params
This commit was initially there for tests, when no repo exist, but
get_param will also crash if commit does not exist, wich may be
a problem on user rebuild.
2019-12-04 12:13:18 +01:00
Xavier-Do
6681e40231 [FIX] runbot: better source cleaing
A build can sometimes fail and be stuck in a running state
without corresponding sources. In this case, source are not gc anymore
This commit fixes that by always applying gc even when an inconsistency
is detected.
2019-12-04 11:26:54 +01:00
Xavier-Do
9e5ee700f3 [FIX] runbot: sha instead of commit 2019-12-03 16:58:30 +01:00
Christophe Monniez
8ab89d2e2f [FIX] runbot: fix percent in format string and typos 2019-12-03 16:07:44 +01:00
Xavier-Do
9cc46d1d3a [IMP] runbot: add force option to cleanup specific build now 2019-12-03 10:20:12 +01:00
Christophe Monniez
c9732ed68d [FIX] runbot: remove dash options in generated config file
When creating an .odoorc file to store configuration that are proper for
the runbot, the command line options were used as key.
The problem is that the Odoo config file use undescore instead of dash
for options keys.

Also, the Command object was not recreated with the config_tuples
parameter. Because of that, when adding a command in the list, the
config_tuples were losts.

As a consequence, on the Odoo runbot instance, the data dir was created
in the default dir and thus, not included in the zip file of the dump,
causing some runbot steps to fail.
2019-12-02 16:45:13 +01:00
Christophe Monniez
73f720a55c [IMP] runbot: refactor tests
A lot of things have to be mocked during runbot tests, as a consequence,
a lot of patch decorators accumulate in a big stack uppon some tests
methods.

Also, a lot of mocks are used multiple times among tests.

With this commit, a new RunbotClass is added that comes with patches
ready to be started. A start_patcher helper method is available to start
a patch and add the appropriate stop in a cleanup.

Also, when a build is created in the tests, the _get_params method is
always called, resulting in an annoying git warning.

With this commit, a create_build method is added on the test class, that
way the _get_params is always mocked when a build is created.
2019-12-02 16:36:56 +01:00
Xavier-Do
7d1283492b [IMP] runbot: dynamic requirements 2019-12-02 16:36:56 +01:00
Xavier-Do
4ee0d93abf [IMP] runbot: general runbot log improvement 2019-11-27 15:37:58 +01:00
Xavier-Do
54ecee8c4e [IMP] runbot: create build when old HEAD is force-pushed
_find_new_commits will check if a build exists with current branch HEAD
before creating build. This is crutial to avoid to create a new build
at each loop turn. The problem is that in some rare cases, when
force-pushing an old head on a branch, the build won't appear and the only
way to update the branch is to find the corresponding build that may be
hidden in hitory. This may be confusing for the user that will rebuild the
created build with a commit that doesn't represent the head of the branch.

This commit only search for the last build of each branch, in order to
only skip build creation if the last build as the same hash. The new
created build should be marked as the duplicate of the first one.
2019-11-27 15:37:58 +01:00
Christophe Monniez
064546441f [IMP] runbot: use a config file to simplify args
When starting an odoo instance with Docker, a very long command line is
computed and appears in the logs.

With this commit, an .odoorc configuration file is written ind the build
dir and mounted in the Docker container.

Previously, the runbot .odoorc/.openerprc file was mounted to share some
parameters. Now, if that file exsists, its content is merged with build
.odoorc.
2019-11-27 15:37:43 +01:00
Xavier Morel
c7588c32fd [FIX] forwardport: triggers conflict markers detection
Conflict marker checker looks for 7 <s or >s in a row. The forwardport
contains exactly that. So replace one of the literal signs by a hex
escape.
2019-11-26 16:23:36 +01:00
Xavier Morel
f23fb2a35b [FIX] runbot_merge: notification-via-deployment
Previous version incorrectly browsed the PR *number* (rather than ID)
so at best it would do nothing and at worst it might go and notify the
wrong PR entirely.
2019-11-25 11:29:45 +01:00
Christophe Monniez
e8eb4eea10 [IMP] runbot: add unzip tool in Docker image 2019-11-22 15:42:48 +01:00
Xavier Morel
629e00a117 [IMP] runbot_merge: add related PRs to top comment
Discussing #238 with @odony, the main concern was the difficulty of
understanding if things merged in one repo were related to things
merged in an other repo: currently, knowing this requires going to the
merged PR, getting its label, and checking the PRs with the same HEAD
in the other repository to see if there's a correlation (e.g. PRs
merged around the same time).

The current structure of the mergebot makes it reasonably easy to add
the other PRs of the batch in the pseudo-headers, such that we get
links to all "related" PRs in the head commit (and links back from the
commits which is probably less useful but...)

Fixes #238
2019-11-22 09:21:40 +01:00
Xavier Morel
1b5a05e40c [FIX] mergebot: improve handling of having missed PR updates
1. if we try to stage a PR and realize we'd stored / checked the wrong
   head, cancel the staging and notify the PR
2. provide a command to forcefully update pr heads (or at least check
   that a PR's head is up to date)

Closes #241
2019-11-21 08:10:39 +01:00
Xavier Morel
a45f7260fa [IMP] forwardport: better handle authorship information
Before this:

* the forwardport bot always sets itself as the committer when it
  creates a forward-port branch
* when creating squashed / conflict commits, it becomes both author
  and committer

This is not great as it loses a fair amount of authorship information
and doesn't properly give credit where credit is due. Improve this in
the following ways:

* use the original authorship information as-is when forward-porting
  commits
* the the forward port fails, use the original authorship information
  as-is if there's a single commit to forward port
* otherwise if there's only a single author / committer across the
  branch being forwardported use that, if there are multiple give up
  and use the identity of the 'bot, since the branch will probably
  need to be re-done in full the authorship information of the
  placeholder commit should not matter overly much

Uses git's magic ENV variables as that's pretty much the only way to
properly override the COMMITTER date: conf items only provide for
author and committer *identity* (name and email), and while `commit`
allows overriding the *authorship* date (`--date`) it doesn't provide
any option for the *commit* date.

Fixes #255
2019-11-21 08:10:39 +01:00
Xavier Morel
8e67aed792 [IMP] runbot_merge: limit spamming on PR close
When closing a PR, github completely separates the events "close the
PR" and "comment on the PR" (even when using "comment and close" in
the UI, a feature which isn't even available in the API). It doesn't
aggregate the notifications either, so users following the PR for
one reason or another get 2 notifications / mails every time a PR
gets merged, which is a lot of traffic, even more so with
forward-ported PRs multiplying the amount of PRs users are involved
in.

The comment on top of the closure itself is useful though: it allows
tracking exactly where and how the PR was merged from the PR, this
information should not be lost.

While more involved than a simple comment, *deployments* seem like
a suitable solution: they allow providing links as permanent
information / metadata on the PRs, and apparently don't trigger
notifications to users.

Therefore, modify the "close" method so it doesn't do
"comment-and-close", and provide a way to close PRs with non-comment
feedback: when the feedback's message is structured (parsable as
json) assume it's intended as deployment-bound notifications.

TODO: maybe add more keys to the feedback event payload, though in my
      tests (odoo/runbot#222) none of the deployment metadata
      outside of "environment" and "target_url" is listed on the PR
      UI

Fixes #224
2019-11-21 08:10:39 +01:00
Xavier Morel
b853e5ba96 [IMP] runbot_merge: further validation of squash update on retargeting
It should have already been working, added an additional check for
update-then-retarget just in case but that worked out of the box. So
not sure why odoo/odoo#40106 failed.

Closes #256
2019-11-21 08:10:39 +01:00
Xavier Morel
8a47c57c3d [ADD] runbot_merge: logging of every GH request / response
If odoo is configured with a logfile, log to a separate file in the
same directory.

* log request / response when querying github
* log *received* requests for webhooks

Either way log the entire request metadata, though only the first 400
bytes/chars of the entity bodies.

This is intended to help mostly with post-mortem debugging: timestamps
from the main log can be correlated with the timestamps from the
github log in order to have more relevant information, both for
internal use and to send to gh support.

Closes #257
2019-11-21 08:10:39 +01:00
Christophe Monniez
f8614c4abd [FIX] runbot: grep for enhanced test-tag for auto_tags
When using auto_tags, most of the time, the enhanced version are used.
For example, using "-:TestPoSStock" to disable the test class.
If the tested Odoo version does not support this kind of tag, they are
considered as simple tags, thus disabling all tests.

It 's the case for Odoo saas-11.3.

With this commit, the auto_tags are only used on Odoo versions that
support the new test tags.
2019-11-19 14:54:16 +01:00
Xavier Morel
6f68db15d6 [IMP] runbot_merge: sanity check when rebasing
Ensure that the commits we're creating are based on the commit we're
expecting.

This is the second cause (and really the biggest issue) of the "Great
Reset" of master on November 6: a previous commit explains the issue
with non-linear github operations (update a branch, get the branch
head, they don't match).

The second issue is why @awa-odoo's PR was merged with a reversion of
@tivisse's as part of its first commit.

The stage for this issues is based on the incoherence noted above:
having updated a branch, getting that branch's head afterward may
still return the old head. However either delays allow that update to
be visible *or* different operations can have different views of the
system. Regardless it's possible that `repos/merges` "sees" a
different branch head than a `git/refs/heads` which preceded it by a
few milliseconds. This is an issue because github's API does not
provide a generic "rebase" operation, and the operation is thus
implemented by hand:

1. get the head of the branch we're trying to rebase a PR on
2. for each commit of the PR (oldest to newest), *merge* commit on the
   base and associate the merge commit with the original
3. reset the branch to the head we stored previously
4. for each commit of the PR, create a new commit with:

   - the metadata of the original
   - the tree of the merge commit
   - the "current head" as parent

   then update the "current head" to that commit's ref'

If the head fetched at (1) and the one the first merge of (2) sees are
different, the first commit created during (4) will look like it has
not only its own changes but also all the changes between the two
heads, as github records not changes but snapshots of working
copies (that's what a git tree is, a complete snapshot of the entire
state of a working copy).

As a result, we end up not only with commits from a previous staging
but the first commit of the next PR rollbacks the changes of those
commits, making a mess of the entire thing twice over. And because the
commits of the previous staging get reverted, even if there was a good
reason for them to fail (not the case here it was a false positive)
the new staging might just go through.

As noted at the start, mitigate that by asserting that the merge
commits created at (2) have the "base parent" (left parent / parent
from the base branch) we were expecting, and cancel the staging if
that's not the case.

This can probably be removed if / when odoo/runbot#247 happens.
2019-11-12 07:44:01 +01:00
Xavier-Do
1e102b7d76 [FIX] runbot: check support before adding auto-tags 2019-11-08 15:40:36 +01:00
Xavier-Do
0c4d78f497 [FIX] runbot: various small fixes 2019-11-08 15:33:30 +01:00
Xavier-Do
a7992e9f50 [IMP] runbot: add no_build on repo
When runbot is installed to test customs addons, we don't
want to build all odoo commit, but we need to update branches
in order to make _get_closest_branch work.

This commit will allow a user to set odoo in poll mode
with no_build set to True, to create branches only.

(And a small fix for additionnal_env)
2019-11-08 12:08:02 +01:00
Christophe Monniez
631b29fcf8 [FIX] runbot: fix container cli tests
Since 81fefee, the container.py CLI does not work as expected.

With this commit, the CLI is working, a new arg was added to test
flamegraphs and the dump is adapted to mimic the runbot.

Also, a small issue is fixed in the zip file creation. Before the zip
creation, the directory is changed, if the directory change fails, the
zip is created from the current directory which is removed by zip at the
end of the process. That could lead to the deletion of the build dir.
2019-11-08 10:29:51 +01:00
Xavier-Do
685cc282ba [IMP] runbot: add env parameter support for docker in config steps 2019-11-08 10:29:51 +01:00
Xavier Morel
7598d45283 [IMP] runbot_merge: use exponential backoff on head check
It's a waste to lose the entire staging if it's only a short blip /
delay thing, so retry multiple times. Add utility function to make
backoff functions easier (though the UI is not great ATM).

Also log the "left" parent of a merge commit (which should be the
"base") when creating it, for additional post-mortem information.
2019-11-07 10:03:54 +01:00
Xavier-Do
58c683030d [IMP] runbot: add auto test-tags management.
A typical use case when an error is detected is to disable
this test by adding a negated test-tags on config
step 'all' and 'split_all'. This commit will help
to do that by adding a test_tags management on build error.

The user define a test_tag that will only execute failling test.
if a config step has the flag enable_auto_tags, the test tag will
be negated and added to config test-tags.

This commit also add some information for monitoring.
2019-11-07 09:51:05 +01:00
Xavier Morel
10ef6b82f0 [IMP] runbot_merge: sanity check PATCH git/ref/heads
Turns out not only can that operation fail, that operation can succeed
but have its effect delayed. To try and guard against that,
immediately check that we get the correct ref' after having reset it.

This is the cause of the November 6 mess: when preparing a staging,
the mergebot does the following,

1. get the head of <branch>
2. hard-reset tmp.<branch> to that
3. start merging PRs, which requires getting the current state of
   tmp.<branch> back

On the 6ths, these steps looked like this

```text
2019-11-06 10:03:21,588 head(odoo/odoo, master) -> ab6d0c38512e4944458b0b6f80f38d6c26b6b597
2019-11-06 10:03:22,375 set_ref(update, odoo/odoo, tmp.master, ab6d0c38512e4944458b0b6f80f38d6c26b6b597 -> 200 (OK)
2019-11-06 10:03:28,674 head(odoo/odoo, tmp.master) -> de2a852e7cc1f390e50190cfc497bc253687fba8
2019-11-06 10:03:30,292 head(odoo/odoo, tmp.master) -> de2a852e7cc1f390e50190cfc497bc253687fba8
```
So the 'bot fetched the commit at the head of master (ab6d0c), reset
tmp.master to that... and then got a different commit when it fetched
the tmp head to stage a PR on it.

That different head being of course a previous rejected staging. When
the new staging succeeded, it brought the entire thing in and made a
mess.

This was compounded by an issue I still have to investigate: the
staging of the new PR took the wrong base commit *but the right base
tree*, as a result the first thing it did was *reverse the entire
previous commit* (without that we could probably have left it as-is
rather than need to force-push master -- twice).
2019-11-07 07:52:12 +01:00
Christophe Monniez
34d26ad253 [IMP] runbot: add host in build errors debug mode 2019-11-06 14:57:55 +01:00
Xavier-Do
40bc185d28 [FIX] runbot: quite zip 2019-11-06 14:11:15 +01:00
Xavier-Do
d7f6075c8b [FIX] runbot: avoid build failure when test_tags not supported 2019-11-06 12:55:58 +01:00
Xavier-Do
10799ba9d6 [FIX] runbot: allow to manually hook by calling route 2019-11-05 13:42:39 +01:00
Christophe Monniez
daea9018d3 [FIX] runbot: fix database dump
* Add zip utility in Dockerfile
* fix zip command to avoid useless prefix
* write json info file at the right place
* fix zip file link
2019-11-04 17:28:37 +01:00
Xavier-Do
b9550dccca [IMP] runbot: improve db dump
Current dump version doesn't include filestore. This new
version adds the filestore trying to match odoo backup format
in order to ease restore.
manifest.json file is not create since it isn't usefull,
but an info.json is added, with build info.
2019-11-04 14:03:41 +01:00
Christophe Monniez
6e7d8d57f8 [IMP] runbot: add a multibuild wizard
Creating multi builds configs can be tedious. One must create 2 build
configs and 2 build config steps in the right order.

With this commit, a simple wizard is added that creates those 4
configurations by simply filling 4 fields.

Also, a new field, group, is added in order to be able to gather
config's and config steps into  groups. The group is a Many2one on a
config.

While at it, the runbot menu has been a bit rearranged with everything
about config's in a parent menu named Configs.

Config's and config's steps tree views have been enhanced to show the
config group and add some filters in the search views.
2019-10-28 15:26:15 +01:00