Commit Graph

171 Commits

Author SHA1 Message Date
Xavier-Do
7845a718b7 [IMP] runbot: add use_ssl to settings 2023-06-02 10:49:05 +02:00
Christophe Monniez
430a526b5c [FIX] runbot: limit triggers in additionnal_setup
When testing with a populated db, this assertion fails because of
additional repositories.
2023-06-01 15:03:13 +02:00
Christophe Monniez
82c6b22e77 [FIX] runbot: typo in test tag 2023-06-01 15:03:13 +02:00
Xavier-Do
e3d87b5b5d [IMP] runbot: improve test-tags support
The current post_install build mecanism is using extra params to give
test-tags. Unfortunately this disables the support for auto tags
and this have to be done manually. This means that auto tags are in the
build extra-params and not dynamic at rebuild of a post_install.

Also, using extraparams in the post install creation was removing
extra_params comming from custom trigger.

With this commit, the test-tags can be given inside config_data
and will be combined with config step test-tags and auto-tags.

This was an opportunity to simplify the logic.

This commit also fixes the test_install_tags that was broken.
2023-04-06 11:33:01 +02:00
Xavier-Do
d2f9330043 [REF] runbot: various refactoring
The initial motivation is to remove the flush when a log_counter is
written. This flush was initially usefull when the limit was in a
psql trigger, but finally add a side effect to flush everything before
starting the docker. This was limiting concurrent update after starting
the docker, but we still have no garantee that the transaction is
commited after starting the docker. The use case where the docker is
started but the transaction is not commited was not handled well and was
leading to an infinite loop of trying to start a docker (while the
docker was already started)

This refactoring returns the docker to the scheduler so that the
schedulter can commit before starting the docker.

To achieve this, it is ideal to have only one method that could return
a callable in the _scheduler loop. This is done by removing the run_job
from the init_pending method. All satellite method like make result
are also modified and adapted to make direct write: the old way was
technical debt, useless optimization from pre-v13.

Other piece of code are moved arround to prepare for future changes,
mainly to make the last commit easier to revert if needed.

[FIX] runbot: adapt tests to previous refactoring
2023-03-23 13:32:50 +01:00
Christophe Monniez
6fdd35ed50 [FIX] runbot: avoid empty negative test tags
When parenting a build error, if a test_tag is set on it, the tag is
transferred to the parent and cleared to an empty string.
In that case, a single `-` appears in the disabling tags and leads to an
apocalyptic situation ... the runbot builds don't not run any tests.

With this commit, the test_tags is set to `False`.
2023-02-28 12:16:07 +01:00
Xavier-Do
f5caa87da1 [FIX] runbot: fix time related test 2023-02-28 10:59:47 +01:00
Xavier-Do
d3e3228921 [FIX] runbot: get_module remove prefix
Since removeprefix was not available in ubuntu 20.04, a easier alternative
using rebase was used.

The initial assumption was that the prefix would look like `odoo/addons/`
and won't be in the filename.

When the repo is enterprise, the prefix is `enterprise/` meaning that
module name ending with `enterprise` will be truncated

`repo._get_module('enterprise/mail_enterprise/static/src/widgets/form_renderer/form_renderer.js')`

will output

`mail_static`
2023-02-28 10:59:47 +01:00
Xavier-Do
f7a12c6359 [FIX] runbot: fix fetch tests 2023-02-06 10:16:07 +01:00
Xavier-Do
27ac733df6 [IMP] runbot: automatic base master bundle
When adding a new project, if no branch matches a base name,
the created bundles won't have a version and it will fail.

A simple fix will be to add a master bundle for all projects.
2023-01-17 13:41:01 +01:00
Xavier-Do
2b8242cf42 [IMP] runbot: default empty value for result 2023-01-13 14:27:17 +01:00
Christophe Monniez
1c49aaacf7 [IMP] runbot: add a test for _get_refs 2023-01-10 10:37:06 +01:00
Xavier-Do
0d61f6c93b [IMP] runbot: add github login
This idea was postpone for a while since this was most a mergebot
responsability but having the github login of the user will help
for some team feature requests.

The main one is to only ping a team if the pr was not opened by a member
of the team. We want to let the team manager manage that as much as
possible so the team manager group will be able to write the user
github login (as well as the user himself) and add a list of non user
github_login to consider if not all user have a account on runbot.

This commit also improves the views for team managers.
2022-12-16 15:32:39 +01:00
Christophe Monniez
2cad0542f4 [IMP] runbot: queue build logs in a local database
Before the commit the build ir_logging was sent from the build instance
to the main runbot ir.logging table. As the number of runbot hosts
increases, it introduce a lot of concurrency.
e.g.: 80 hosts with 8 builds means 640 instances trying to insert
records in the ir.logging table.

With this commit, a special database is used on the builder host in
order to receive ir.logging's from the build instances.

Regulary, the table is emptied by the builder and the logs are inserted
in the runbot leader ir.logging table.
2022-11-28 06:46:49 +01:00
Xavier-Do
f2d71a0b79 [FIX] runbot: fix pull info 2022-11-21 16:48:54 +01:00
Xavier-Do
2e77a55ddb [IMP] runbot: add codeowner management 2022-11-21 16:32:25 +01:00
Christophe Monniez
ac010405dc [FIX] runbot: use gethostname instead of getfqdn
At boot time, it appears that when the runbot tries to get its hostname
it may get a wrong fqdn.
2022-11-07 10:12:15 +01:00
Christophe Monniez
964a88cb36 [FIX] runbot: take number of builds from config data
Oversight from previous improvement in b79c4a5a52.
2022-11-07 10:12:15 +01:00
Christophe Monniez
309aeaa32e [IMP] runbot: speedup build garbage collecting
When the builds directory is filled with a lot of build directories
(around 100000) the garbage collection process may take up to 2 minutes.
The root cause is that each build directory is scanned to clean it up
even if it was already cleaned.

With this commit, a stamp file is used to mark directories that were
already garbage collected.
2022-10-21 11:32:46 +02:00
Xavier-Do
0287dcaab7 [IMP] runbot: update install documentation 2022-10-21 10:32:40 +02:00
Xavier-Do
303638e507 [FIX] runbot: don't hardcode user odoo 2022-10-21 10:32:40 +02:00
Xavier-Do
785e2dc3bc [IMP] runbot: don't use local odoorc 2022-10-21 10:32:40 +02:00
Xavier-Do
b79c4a5a52 [IMP] runbot: various build_config improvements 2022-10-21 10:32:40 +02:00
Xavier-Do
70e8b15690 [IMP] runbot: add websocket support 2022-08-23 16:30:24 +02:00
Christophe Monniez
78697d2acb [IMP] runbot: use docker python lib
While using the docker cli as a subprocess was KISS and convenient,
the python Docker SDK is mature, easy to use, available as a Debian
package and much more powerful.

It will permit to monitor the containers memory consumption and will
help to spot memory leaks.
2022-06-30 10:58:38 +02:00
Xavier-Do
cdaae9b3ed [IMP] runbot: speedup get_refs
Regarding the number of refs in odoo repo (arround 18 million at this
time), the parsing of the date was significant when filtering old refs.

Using unix time allows a direct comparaison without parsing the date,
and improved performance, going from ~7 seconds to ~1.3 seconds.
2022-06-20 10:20:37 +02:00
Xavier-Do
2ac70f5ab4 [FIX] runbot: fix test_all test for restore 2022-06-13 14:03:16 +02:00
Xavier-Do
d466887f08 [REF] runbot: adapt statistic models
Initial model was a (build_id, key, value) where key is in fact a two
part information: `category.key` (where key is usually a module)

This means that for each module, we will have one entry per
modules*category.
We have between 200 and 400 modules per build * 4 keys -> around 1000
entries per build.

The hudge amount of total entries lead to a fast overflow of the table
sequence + this create important indexes.

Also, most of the time, the js will manage the display of stats meaning
that python will transform
(build_id, category.key, value)
into
(build_id, {key: value}) for one category

A new model makes use of a json field to store values for different
modules in a json dict, on entry per category*build. (4 entry per build)

The table will be renamed and migrate later
2022-06-13 12:42:13 +02:00
Christophe Monniez
a051568213 [FIX] runbot: avoid werkzeug deprecated escape
The `utils.escape` utility was deprecated in werkzeug 2.0.0, so it can
be replaced with our `html_escape` which is itself `markupsafe.escape`.

Also, with this change, the double quotes are now escaped in `"`
instead of `"`, so we fix the test too.
2022-06-08 10:53:50 +02:00
Xavier-Do
ca1246b87a [FIX] runbot: fix pseudo_markdown 2022-06-07 15:56:26 +02:00
Xavier-Do
bf4167670d [IMP] runbot: cleanup 2022-06-07 11:18:34 +02:00
Xavier-Do
6b79d5b96c [REM] runbot: remove runbot_domain
This parameter can be replaced by web.base.url when needed.
2022-06-07 10:54:48 +02:00
Xavier-Do
78f050b132 [IMP] runbot: adapt for 14.0 2022-03-23 09:49:53 +01:00
Xavier-Do
fe987cd0f3 [IMP] runbot: some fixes for ps runbot
- searching on number will search for both pr and branche name
- hooks are now using payload to define repo when not given in url
- fixes .git cleaning in repo
    (remove rstrip since it can fail for repo starting with g, i, t)
- recompute base on prepare if base was not found
- remove local_result form write values if there is a single record
    (instead of raising, makes python step easier to write).
- avoid stucked build/loop after removing a step from a config.
- avoid to send ci for linked base_commit
- add a fallback mechanism for base if no master branch is found
- add option on project to avoid to keep sticky running, usefull
    when using a lots of projects
    WARNING: this is a change of default behaviour, need to update
    existing projects.
- always discover new commits for branch matching base paterns.
    This is especially usefull to discover old versions on project with
    low merge frequency.
- always create a batch, event if there is now trigger. This helps to
    notice that commits are discovered
- add line-through on death branches/pr
- manual trigger are now displayed on main page
2022-01-10 15:19:44 +01:00
Christophe Monniez
91efbec943 [IMP] runbot: add a codeowner model
As a custom codeowner system was successfully implemented in a python
step on our runbot instance, it's now time to have a real model for
that.

This commit adds a skeleton Codeowner model in order to be used for a
basic usage.

This should be improved in the future after some battle testing.
2021-11-25 15:19:26 +01:00
Christophe Monniez
89dcb52215 [IMP] runbot: add a runbot team model
With the increasing usage of runbot to test various things and to take
care of random bugs in tests, the need of a team dashboard arose.

This commit adds a `runbot.team` model. Internal users can be
linked to the team. Module wildcards can be used to automatically assign
build errors to a team at 'build.error` creation.

Also, an upgrade exception can be assigned to a team in order to display
it on a dashboard.

A dashboard model is used to create custom dashboards on the team
frontend page. By default, a dashboard is meant to display a list of
failed builds. The failed builds are selected by specifying a project, a
trigger category (e.g. nightly), a config and a domain (which select
failed builds by default).

The dashboard can be customized by specifying a custom view.

Each created team has a frontend page that displays all the team
dashboards and the errors assigned to the team.

A few other improvement also come with this commit:

 * The cleaned error is now in a tab on the build error form
 * Known errors are displayed as "known" on the build log page
 * The build form shows the config used for the build
2021-11-25 15:19:26 +01:00
Xavier-Do
87214a82a6 [IMP] info: log level debug to info
runbot servers are running with a log-level debug in order to have usefull
debug information, but this also causes some noise comming from odoo.

This pr changes most debug to info.
2021-07-02 15:05:42 +02:00
Xavier-Do
011bdc00e2 [IMP] add draft pr management + multiple custom fields
- Add draft pr management to avoid to trigger code owner on draft pr.
- Add check on falsy config on trigger id (avoid crash, usefull to disable trigger)
- Add extra params on custom trigger to avoid to write specific config every time.
- Trigger a new batch automaticaly when updating target/draft
2021-06-29 10:13:34 +02:00
Christophe Monniez
67d020a8b3 [IMP] runbot: update docker default for focal
Since Odoo 14.0, the recommended Ubuntu LTS release is Focal, the
default Docker should be updated accordingly.

A custom template with bionic have to be manually created on runbot
instances that still build Odoo < 14.0.

* A small change is made in the templates logic that builds the
  Dockerfile: a `runbot_pip` dict entry now exists in order to install the
  python libs required by the runbot. On the other hand, `additional_pip`
  should only be used to install optional python libs for Odoo.

* Upgrade Chrome version to 90.0.4430.93-1 as this one is currently in
  use on our current runbot instance. Just keep in mind that the Odoo
  screencast feature does not work anymore since Chrome 88.

* gsfont is added because of a bug [0] that affects python-reportlab in
  Focal.

* pyCrypto package is removed. It was used in an Odoo addon that
  disappeared in odoo/odoo@2738341c21

* dbfread, websocket-client are now installed as a deb package as they exists in Bionic and
  Focal

* pdfminer.six is now removed because a deb package exists in Focal but
  not in Bionic. It means that it has to be added in deb_packages_python
  in Dockerfiles for odoo > 13.0 and in additional_pip for odoo <= 13.0

[0]: https://bugs.launchpad.net/ubuntu/+source/python-reportlab/+bug/1918107
2021-06-29 09:22:41 +02:00
Xavier-Do
514de022f4 [FIX] runbot: fix markdown code
When code blocks were containing markdown like text, the inside of the code
block was also formated.

This commit removes the code blocks before applying other formating and
place them back at the end.

closes #481
2021-05-10 15:11:21 +02:00
Christophe Monniez
f28485b6a8 [FIX] runbot: allow to retry to send a status
When a status cannot be sent to github, the status is created in
database but the `sent_date` field is not set.

Because of that, the status cannot be sent manually from the frontend.

With this commit, that kind of status can by tried again.
2021-02-02 13:32:03 +01:00
Christophe Monniez
4f4005896c [FIX] runbot: browse a valid record id in test_warning
Since odoo/odoo@824a651 the test_warning_from_runbot_abstract was
failing for a good reason, the `browse` parameter was a recordset
instead of an id.
2021-02-02 11:48:03 +01:00
Xavier-Do
3657a65b20 [IMP] runbot: call docker_run outside steps
When calling a step from a python step, it is impossible to alter some parameter, the only solution is to copy all step code.
With this change, python step are now able to override docker_run parameter of another step by modifying the dict returned by run_* steps
and assigning the result to "docker_params".

This will mainly be used to set the correct docker_image for migration pre and post test. This can also be used to alter a command,
like removing the pip install or adding extra pre/post operation on the command.
2020-11-11 10:47:26 +01:00
Christophe Monniez
4dec2c5f5c [FIX] runbot: fix warning during dockerfile test 2020-11-10 17:33:18 +01:00
Christophe Monniez
981cb7e1b6 [IMP] runbot: use a Dockerfile model
Currently, runbot is using a single Dockerfile maintained in a data file
in the source code. This situation is not convenient for testing Odoo in
different environments.

With this commit, a Dockerfile Odoo model is used to allow usage of
multiple Docker containers.

This model comes with a pre-defined Dockerfile that can be used to build
the current Odoo supported versions (12.0 up to 14.0).
2020-11-10 09:52:48 +01:00
Xavier-Do
f9272cb207 [IMP]: add linitng tools (+bunch of small fixes) 2020-10-15 10:38:36 +02:00
Xavier-Do
675e2f1688 [IMP] runbot: manual host 2020-09-11 15:12:36 +02:00
Xavier-Do
45721cdf6c [IMP] runbot: runbot 5.0
Runbot initial architechture was working for a single odoo repo, and was
adapted to build enterprise. Addition of upgrade repo and test began
to make result less intuitive revealing more weakness of the system.

Adding to the oddities of duplicate detection and branch matching,
there was some room for improvement in the runbot models.

This (small) commit introduce the runbot v5.0, designed for a closer
match of odoo's development flows, and hopefully improving devs
experience and making runbot configuration more flexible.

**Remotes:** remote intoduction helps to detect duplicate between odoo and
odoo-dev repos: a commit is now on a repo, a repo having multiple remote.
If a hash is in odoo-dev, we consider that it is the same in odoo.
Note: github seems to manage commit kind of the same way. It is possible
to send a status on a commit on odoo when the commit only exists in
odoo-dev.
This change also allows to remove some repo duplicate configuration
between a repo and his dev corresponding repo.
(modules, server files, manifests, ...)

**Trigger:** before v5.0, only one build per repo was created, making it
difficult to tweak what test to execute in what case. The example use
case was for upgrade. We want to test upgrade to master when pushing on
odoo. But we also want to test upgrade the same way when pushing on
upgrade. We introduce a build that should be ran on pushing on either
repo when each repo already have specific tests.
The trigger allows to specify a build to create with a specific config.
The trigger is executed when any repo of the trigger repo is pushed.
The trigger can define depedencies: only build enterprise when pushing
enterprise, but enterprise needs odoo. Test upgrade to master when pushing
either odoo or upgrade.
Trigger will also allows to extract some build like cla that where
executed on both enterprise and odoo, and hidden in a subbuild.

**Bundle:** Cross repo branches/pr branches matching was hidden in build
creation and can be confusing. A build can be detected as a duplicate
of a pr, but not always if naming is wrong or traget is invalid/changes.
This was mainly because of how a community ref will be found. This was
making ci on pr undeterministic if duplicate matching fails. This was
also creating two build, with one pointing to the other when duplicate
detection was working, but the visual result can be confusing.
Associtaions of remotes and bundles fix this by adding all pr and
related branches from all repo in a bundle. First of all this helps to
visualise what the runbot consider has branch matching and that should
be considered as part of the same task, giving a place where to warn
devs of some possible inconsistencies. Associate whith repo/remote, we
can consider branches in the same repo in a bundle as expected to have
the same head. Only one build is created since trigger considers repo,
not remotes.

**Batch:** A batch is a group of build, a batch on a bundle can be
compared to a build on a branch in previous version. When a branch
is pushed, the corresponding bundle creates a new batch, and wait for
new commit. Once no new update are detected in the batch for 60 seconds,
All the trigger are executed if elligible. The created build are added
to the batch in a batch_slot. It is also possible that an corresponding
build exists (duplicate) and is added to the slot instead of creating a
new build.

Co-authored-by d-fence <moc@odoo.com>
2020-09-10 13:44:38 +02:00
Xavier Morel
0b1b36d10c [FIX] runbot: mis-migrated test
73f720a55c refactored the runbot tests,
and amongst other things created a single patch point for the "mock
root" as a testcase attribute.

One of the tests was missed during that refactoring, likely because
it's skipped by default.
2020-07-08 08:15:45 +02:00
Christophe Monniez
9684c2d97e [FIX] runbot: avoid unallowed characters in docker names
Docker container names are derived from the dest and step name. The dest
is itself derived from the branch name.

In some rare cases, it happens that a character not allowed by Docker
appears in the container name computed by the runbot.

With this commit, a sanitize_container_name function is used to remove
unallowed characters at the container utility level.
2020-06-17 10:15:37 +02:00
Christophe Monniez
b517df4ff0 [IMP] runbot: try to fetch multiple times before disabling
Sometimes, it happens that a `git fetch` fails with an error code 128
for example. When this happens, the runbot host is immediately disabled.

During investigations of such cases, we found that simply retrying the
fetch command works.

With this commit, the fetch command is tried 5 times with an increasing
delay before deciding to disable the runbot host.
2020-04-24 11:35:01 +02:00
Christophe Monniez
360e31ade4 [IMP] runbot: add a build stat model
When a build is done, various numerical informations could be extracted
from log files.  e.g.: global query count or tests query count ...

The extraction regular expression could be hard-coded in a custom step
but there is no place holder where to store the retrieved information.
In order to compare results, we need to store it.

With this commit, a new model `runbot.build.stat` is used to store
key/values pair linked to a build/config_step.  That way, extracted
values can be stored.

Also, another `runbot.build.stat.regex` is used to store regular
expressions that can be used to grep log files and extract values.

The regular expression must contain a named group like this:
`(?P<value>.+)`
The text catched by this group MUST be castable into a float.

Optionally, another named group can be used in the regular expresion
like this:
`(?P<key>.+)`
This `key` group will then be used to augment the key name in the
database.

Example:
    Consider a log line like this one:
    `odoo.addons.website_blog.tests.test_ui tested in 10.35s`

    A regular expression like this, named `test_duration`:
    `odoo.addons.(?P<key>.+) tested in (?P<value>\d+\.\d+)s`

    Should store the following key:value:
    `{
        'key': 'test_duration.website_blog.tests.test_ui',
        'value': 10.35
    }`

A `generic` boolean field is present on the build.stat.regex object,
meaning that when no regex are linked to a make_stats config step, then,
all the generic regex will be applied.

A wizard is added to help the creation the regular expressions, allowing
to test if they work against a user provided example.

A _make_stats method is added to the ConfigStep model which is called
during the _schedule of a build, just before calling the next step.
The regex search is only apllied in steps that have the `make_stats`
boolean field set to true. Also, the build branch have to be flagged
`make_stats` too or the build can have a key `make_stats` in its
config_data field.

The `make_stats` field on the branch is a compute stored field.
That way, sticky branches are automaticaly set `make_stats' true.

Finally, an SQL view is used to facilitate the stats visualisation.
2020-03-20 11:11:03 +01:00
Christophe Monniez
3918d266fa [IMP] runbot: add coverage xml export
When coverage is computed, a post command is used to generate the HTML
report. In order to use the coverage result locally the HTML report is
not enough.

With this commit, an XML report is also generated. It's a single xml
file, downloadable from the build result web page.

The _post_install_command method is renamed into its plural form because
it was useless to return only one command.
2020-03-13 13:40:46 +01:00
Christophe Monniez
3b00d2576c [IMP] runbot: allow pseudo markdown in log messages
With this commit, a kind of markdown is allowed in log messages and
build.description.
Following patterns are supported:
  **strong**
  ~~striketrough~~
  __underline__
`code`
 [link](target)
 @icon-font-awesome-class
2020-03-09 13:10:49 +01:00
Christophe Monniez
3a428d4877 [IMP] runbot: copy steps when duplicating a config
When a build.config is copied, the config steps are not copied.

The steps have to be explicitly ordered otherwise it leads to a
traceback when trying to copy a 'run' step which  have to be the last
one.
2020-03-09 11:37:54 +01:00
Xavier-Do
2379318b0c [IMP] runbot: add subcommand support 2020-02-28 15:54:44 +01:00
Xavier-Do
6b88cb7688 [IMP] runbot: custom db_names for install and run jobs.
When creating a subbuild from a custom python job/cron, some data can
be given through config_data or extra_params to change another step behaviour.

An example is to give a specific -i to an install job in order to
install different modules from the parent build. Anyway since we
are using the same install step in this case, all databases will
have the same name, and the name may not be correct in regard to
the database content.
This commit allows to give a config_param on build giving the default
db_name to use in an install step.
2020-02-24 13:52:57 +01:00
Christophe Monniez
baea2e73be [IMP] runbot: kill build only when needed
On non sticky branches, when a new build is found while another is
already testing, the older build is killed. This happens during when the
main runbot instance is discovering new commits and create new builds.
As a result, concurrent updates may occur while the builders access the
concerned build.

With this commit, this garbage collecting procedure occurs during the
scheduler loop that runs on runbot builder hosts.

Also, the logic changed in a way that the kill is requested only if the
host needs room to handle pending builds.
2020-02-17 16:38:22 +01:00
Christophe Monniez
149ae4a074 [IMP] runbot: improve local cleanup
When a build age reaches the gc_days parameter, its database is dropped
and its directory is removed.

With this commit, two fields are added in order to keep some builds
longer that the defined gc_days.

The gc_delay field on the build allows to add a delay (in number of
days) that is added to its gc_days to compute the gc_date.

The gc_date field is the date when the cleaning will occur.

Also, a test is added and the RunbotCase test class is improved to allow
the stop of a patcher.
2020-02-17 16:38:22 +01:00
Christophe Monniez
edda6c0265 [IMP] runbot: build docker image once per loop turn
At this moment, the Docker image is built at the beginning of each
runbot build. This blocks the _scheduler while the image is built.

With this commit, the image is built before calling the _scheduler and
is not linked to a runbot build.

Also, the necessary dirs are created in the static path before starting
the loop.
2020-01-22 13:50:01 +01:00
Xavier-Do
3f997cff25 [IMP]: runbot: improve create performances. 2020-01-17 14:41:18 +01:00
Xavier-Do
d75c4f085f [FIX] runbot: fix duplicate id and improve global_state 2020-01-16 13:41:29 +01:00
Christophe Monniez
0c8678e671 [IMP] runbot: add a config_data field on build
When two steps in the same build needs to exchange informations, some
hacks have to be used. E.g. using the extra_params fields to store comma
separated values.

With this commit, a config_data field is added alongside with a
JsonDictField that automatically transform the data into json.
2020-01-15 13:49:33 +01:00
Xavier-Do
d0dff374b0 [FIX] runbot: fix previous versions computation
ORM does not support non_searchable.non_stored dependency.
thus, the closest_sticky.previous_version dependency will log an error
when previous_version is written.
this dependency is usefull to make the compute recursive, avoiding to have
both record and record.closest_sticky in self, in that order, making the record.previous_version
empty in all cases.
Writing self on sticky will mitigate the problem. but it is still posible to
have computation errors if defined_sticky is not sticky. (which is not a normal use case)
2020-01-14 13:24:58 +01:00
Xavier-Do
acf31c2820 [FIX runbot: remove _update_nb_children] 2020-01-14 13:24:58 +01:00
Xavier-Do
93b901dcdd [IMP] runbot: simplify views and adapt to odoo13
mainly fixes datetime and bootstrap layouts
2020-01-14 13:24:58 +01:00
Xavier-Do
4e694ffefa [IMP] runbot: addapt tests to 13.0 2020-01-14 13:24:57 +01:00
Christophe Monniez
926ab4a9d9 [FIX] runbot: fix build_error test tags validation
When trying to remove test_tags on a build_error, the validation fails
because it tries to iterate on False. Also, the ValidationError
exception was not properly imported.

With this commit, the validation is fixed and a test is added.
2020-01-06 11:52:13 +01:00
Xavier-Do
eaee010b25 [IMP] runbot: add relation between branches
Migration tests comming on runbot, it will be usefull to have quick
way to obtain branches related to current build.

This commit adds a field for the colsest sticky branch, previous version
and intermediates stickies.

Example when last sticky is saas-13.2:
branch_name: master-test-tri
closest_sticky: master
previous_version: 13.0
intermediate_stickies: saas-13.1, saas-13.2
2019-12-19 15:38:53 +01:00
Xavier-Do
426b7af2cb [REF] runbot: refactor sheduler 2019-12-18 16:30:01 +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
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
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
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-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
Christophe Monniez
d9b20d6961 [IMP] runbot: dump database at the end of step
Dump a db at the end of a build, using a new 'finals' cmd part
added in order to execute dump even if build fails.

Add a link in last step log to download dump.
2019-10-21 16:23:05 +02:00
Christophe Monniez
3308829e80 [IMP] runbot: uses fnmatch patterns to select modules
Actually some Odoo modules are black_listed from a set hardcoded in the
runbot code. In some cases, one needs to blacklist custom modules,
preferably in a config_step.

With this commit, the repo.modules, branch.modules,
config_step.install_modules fields are concatained in a comma separated
list of fnmatch patterns. The patterns can be prefixed with a dash to
exclude the matching module(s).

Co-authored by @Xavier-Do
2019-10-18 16:30:06 +02:00
Christophe Monniez
27b1c2b5f4 [IMP] runbot: add the active_step_id on the ir_logging log
In order to have a more efficient ir_logging filtering, this commit adds
the currrent build step id on the ir_logging line.
2019-10-18 11:03:22 +02:00
Christophe Monniez
db52bff323 [IMP] runbot: number of log lines per build
When a build is running, a cron, an evil query or something else can
start to fill and bloat the runbot ir_logging table.

With this commit, a log_counter field is added on the build, starting at
100. The SQL trigger decrement this counter after a line is inserted.

When the counter drops to 0, a the last log line contains a message
stating that the limit has been reached. Further log lines are dropped
for this build step.

The counter is reset to a default of 100 before each step.
This value is configurable through an optional ir.config_parameter
runbot_maxlogs.

The runbot itself is still able to add logs lines through the build _log
method.

Thanks @Xavier-Do for the smart idea.
2019-10-18 11:03:22 +02:00
Christophe Monniez
4b2a93af9e [FIX] runbot: fix build_error active field changes
When a build_error active field is changed, the onchange leads to a
traceback. Anyway, the onchange was not a good idea as it only reflects
UI changes.

With this commit, the write method is overwritten to change the
child_ids active fields too. Also, the active_test context is used to
correctly compute the childs_ids and children_build_ids.

A test is also added for all that.
2019-09-20 14:58:16 +02:00
Christophe Monniez
47ad04dc37 [FIX] runbot: remove duplicate import in tests 2019-09-18 15:32:19 +02:00
Christophe Monniez
b7df8566e4 [IMP] runbot: create a new build error when a fixed one reappear
When a build error appears with the same fingerprint as already known
one which was supposedly fixed, the build is simply added to the known
build error.

In order to keep an eye on such reappearing bugs and keep the fixing
history separated, this commit simply creates a new build_error.
Old build errors with the same hash (or child_ids 's hashes) appears in
a computed field error_history_ids.
2019-09-18 13:16:20 +02:00
Xavier-Do
02d2cc4528 [WIP] runbot: monitoring tools
Add a new model runbot.host to keep info and configuration about
hosts (worker servers), like number of worker, reserved or not,
ping times (last start loop, successful iteration, end loop, ...)
and also last errors, number of testing per host, psql connection
count, ...

A new monitoring frontend page is created, similar to glances
but with additionnal information like hosts states and
last_monitored builds (for nightly)

Later this model will be used for runbot_build host instead of char.

Host are automaticaly created when running _scheduler.
2019-09-03 11:10:38 +02:00
Xavier-Do
87c794a9aa [IMP] runbot: add wake up option on builds 2019-07-17 11:34:45 +02:00
Xavier-Do
81fefee137 [FIX] runbot: fix coverage since shared sources
The requirements path and python version where defined from
server in cmd. Since in coverage we add a 'python' before server,
it is difficult to define which element of the cmd is the server.

A solution here is simply to define requirements install and
python version when building cmd since we have access to all
build/source informations. We also add python part in every
cases, and coverage params are now a _cmd python_params.

The _cmd method now returns a Command object instead of a
list, which behave has a list for the cmd part but also contains
a pres and posts list.

pres are requirement install, preparation, ...
cmd is the original cmd list, element can be append or added, this
will allow to keep existing python job without to much changes.
posts are post cmd commands, like coverage result making.

This commit also fix issue with create_job dependencies.
2019-07-16 12:06:09 +02:00
Xavier-Do
f7a4fb7ac3 [IMP] runbot: share sources between builds
Multibuild can create generate a lots of checkout, especially for small
and fast jobs, which can overload runbot discs since we are trying not
to clean build immediatly. (To ease bug fix and allow wake up)

This commit proposes to store source on a single place, so that
docker can add them as ro volume in the build directory.
The checkout is also moved to the installs jobs, so that
builds containing only create builds steps won't checkout
the sources.

This change implies to use --addons-path correctly, since odoo
and enterprise addons wont be merged in the same repo anymore.
This will allow to test addons a dev will do, with a closer
command line.

This implies to change the code structure a litle, some changes
where made to remove no-so-usefull fields on build, and some
hard-coded logic (manifest_names and server_names) are now
stored on repo instead.

This changes implies that a build CANNOT write in his sources.
It shouldn't be the case, but it means that runbot cannot be
tested on runbot untill datas are written elsewhere than in static.

Other possibilities are possible, like bind mounting the sources
in the build directory instead of adding ro volumes in docker.
Unfortunately, this needs to give access to mount as sudo for
runbot user and changes docjker config to allow mounts
in volumes which is not the case by default. A plus of this
solution would be to be able to make an overlay mount.
2019-07-12 14:50:59 +02:00
Xavier-Do
47396ddb46 [IMP] runbot: only drop database and clean localfiles after 30 days. 2019-06-25 16:43:47 +02:00
Xavier-Do
b64c7adce2 [FIX] runbot: make nb_testing count correct when children are duplicates 2019-06-24 15:59:21 +02:00
Xavier-Do
03da48a07a [IMP] runbot: compute nb states without accessing childrens
Accessing childrens can create rollback, especially for builds with
a lot of them, since other runbot will concurently access and update
states. This commit tries to improve this by incrementing and
decrementing counters instead of counting all of them each time.
2019-06-24 14:29:52 +02:00
Xavier-Do
239340e1bc [IMP] runbot: add test for children 2019-06-24 14:29:52 +02:00
Christophe Monniez
c13128a229 [FIX] runbot: try to update github status multiple times
When updating github statuses, it happens that we face a "Bad gateway"
from github. In that case, the error is logged in the runbot logs and
that's it. As a consequence, when the runbot_merge is waiting status for
the staging branch and this kind of error occurs, the runbot_merge
timeouts and the users vainly search the reason.

With this commit, the runbot tries to update the status at least twice.
If it fails, an INFO message is logged on the build itself.
2019-06-19 10:20:38 +02:00
Xavier-Do
55c4e49ada [FIX] runbot: fix time ralated failing test
Some test where failing since _find_new_commits will skip
commit older than max_age
2019-06-18 12:42:07 +02:00
Christophe Monniez
c49e4d21ad [IMP] runbot: allow a parent to ignore some child builds
In a create config, a parent result is computed based on children
results

In some situations, it could be handy to ignore the result of some
sub-builds.

Example: the nightly tests are just the children of one nightly build
with a create config. The external tests are failing randomly and as a
consequence, the nightly result is always red. On the other hand,
keeping the test running, just to have logs is a good idea.

With this commit, a config_step of type create can be marked as
orphan_result, that way, the result is not taken into account in the
parent build result.
2019-05-23 12:32:35 +02:00
Christophe Monniez
b31735406d [FIX] runbot: adapt build write method to api multi
And add tests to avoid regression.
2019-05-22 10:58:30 +02:00
Xavier-Do
427639b77a [FIX] runbot: various fixes (data improvement, python step, logs, ...) 2019-05-20 10:52:13 +02:00