Commit Graph

644 Commits

Author SHA1 Message Date
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
af00bf16e7 [IMP] runbot: add ocrmypdf package to Dockerfile
The ocrmypdf suite of tools are needed by task #2238654.

Altough this package will be optional for Odoo users, it has to be
usable by dev's in order to test and/or fix the feature.
2020-06-19 15:26:31 +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
5ad74635e0 [IMP] runbot: install postgresql-client 12 in Dockerfile
The postgresql-client in the Dockerfile is the one provided by the
Debian package. When the postgresql server on the host has a higher
version than the client, some builds may fail (for example, dumping a
database with the pg_dump).

With this commit, the postgresql-client 12 from the postgresql repo is
used in the Dockerfile.
2020-05-28 16:30:38 +02:00
Xavier-Do
3bf9b263f0 [FIX] runbot: send status only once.
Runbot can send status multiple time for the same hash:
- if transaction fails in scheduler and is retried
- if multiple subbuild are failing

Leading to multiple issues:
- when github receive more than one failure status, mergebot will
be notified multiple times and send multiple mail (for forward ports mainly)
- github will answer `422 Unprocessable Entity for url...` after
1000 status.

This fix proposes to limit number of status:
- By avoiding to send status for orphan build (parent status will never change)
- By storing last send status to avoid to notify multiple time
- By sending status post commit to avoid to contact  github in case of failure.
This will also slightly reduce transaction time by removing an http request.
2020-04-24 11:39:36 +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
4c4b7213bb [IMP] runbot: remove pull_head_name patch filter
Since we store the target_branch_name, filtering out pull head names
that contains `patch-` is not necessary anymore.

This commit is one first step towards a clean refactoring.
2020-04-03 14:53:21 +02:00
Christophe Monniez
59d4eeaf24 [FIX] runbot: use proxy-mode for running instances
When deployed behind nginx reverse proxy and https, the Odoo proxy-mode
must be enabled.
2020-03-30 14:35:15 +02:00
Christophe Monniez
ed8d194d7e [FIX] runbot: typo in stat sql view 2020-03-23 13:54:43 +01:00
Xavier-Do
55ed520823 [FIX] runbot: avoid useless make_stats logs 2020-03-20 11:24:15 +01: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
03d7f871be [FIX] runbot: silently ignore template database 2020-03-18 11:42:57 +01:00
Christophe Monniez
e30d2fbeb1 [FIX] runbot: show connect links when build is a duplicate
When a build is a duplicate, the connections links are not visible
because the local_state is "duplicate".
2020-03-18 11:41:42 +01:00
Martin Trigaux
60a4a9de85 [FIX] runbot: displayed collapsed error
By default, the error was displayed with arrow pointing UP, not down
2020-03-16 15:32:13 +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
820adae5ac [IMP] runbot: auto disable host when git fetch fail
From times to times, a git repo gets corrupted, making builds fail in
chain.

With this commit, the host on which the git fetch fails will be reserved
if not more than half the hosts are reserved.
2020-03-13 13:38:42 +01:00
Xavier-Do
6b52687ed1 [FIX] runbot: better log list
Before intensive python steps, every build exept create build should have logs.
This is not true since now many python steps are creating build, leading
to 404 links to inexisting logs file.

Checking That a step is a docker build looks like a good heuristic since since
most of the time the log file will be the one created by docker. In all case we
can access other logs files in browsing /logs.

A future improvement would be to listdir logs to create all links.
2020-03-13 11:46:50 +01:00
Xavier Morel
5bba39e153 [FIX] runbot: run with unaccent enabled 2020-03-11 13:02:48 +01:00
Christophe Monniez
1fca89e3fd [FIX] runbot: fix invalid type argument when calling _log method 2020-03-10 17:07:47 +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
Christophe Monniez
31e10a059e [IMP] runbot: bump Google Chrome version to 80
The fix odoo/odoo#45347 was merged two weeks ago, it's now time to
deploy on runbot.
2020-03-09 11:34:56 +01:00
Xavier-Do
2379318b0c [IMP] runbot: add subcommand support 2020-02-28 15:54:44 +01:00
Xavier-Do
7e49b4cd2b [IMP] runbot: add a public route for monitoring 2020-02-24 14:45:23 +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
Xavier-Do
ef7029668a [FIX] runbot: take parent into account when searching last branch build
If a branch triggers an hidden build on a another one (sticky ususally),
the last build of the branch will be considered to be this one and
trigger a new build. The same problem can occur when cloning a subbuild
to slighlty change a parameter instead of making an exact rebuild
since the build type may still be normal in this case.

This commit will simply ignore subbuild in this case.
2020-02-20 15:40:34 +01:00
Christophe Monniez
d9ff43fa6b [REM] runbot: remove reverse dependency build feature
When a new commit is found, a rebuild is forced on sticky branches
builds in repositories that depends on the new commit repository.

If one of the repo is protected by groups, the main page gives access
errors for public users and finally leads to a CPU overload.

With this commit, the feature is removed as it will be re-implemented in
custom config steps.
2020-02-20 10:58:20 +01:00
Christophe Monniez
931e2bef8f [FIX] runbot: avoid dependency build from an hidden build 2020-02-19 17:28:38 +01:00
Christophe Monniez
26dce90dd8 [FIX] runbot: avoid ask kill on already dying builds 2020-02-19 17:28:38 +01:00
Christophe Monniez
3d428428eb [IMP] runbot: replace fixing_commit by test_tags errors tree 2020-02-17 16:38:22 +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
5d4979a5f6 [IMP] runbot: set google-chrome version precisely
With this commit, it will be possible to play with different chrome
versions without impacting all runbot instances.

Chrome issues summary:

* 71: innerText linefeed issue
* 74: random chrome crash
* 80: V8 pointer compression exceed Odoo memory limits
2020-02-17 16:37:02 +01:00
Xavier-Do
b4a25c54e4 [IMP] runbot: better same branch build filter 2020-02-12 11:41:08 +01:00
Christophe Monniez
3e7d98a6b8 [FIX] runbot: use a custom template to create db
Since cb05f2b9d8, when creating a database, the template1 is used, this
allows to customize the template and install some needed Postgress
extensions.

Unfortunately, it's also a source of build failures. For example, if the
pg_activity util is used on a runbot host, database creation may fail
with a message like this:

source database "template1" is being accessed by other users

It's because pg_activity needs a database and uses template1.

With this commit, template1 is still used by default but can be changed
with a system parameter. That way, a custom template can be created on
runbot hosts and used when creating DB in builds.
2020-02-12 10:38:54 +01:00
Xavier-Do
c816ba2161 [IMP] runbot: add latest builds of same branch 2020-02-11 17:15:20 +01:00
Christophe Monniez
464893d248 [IMP] runbot: handle PR re-targeting
When a PR branch target is changed on Github, the change is not applied
in the runbot DB.

With this commit, the Github hook payload is taken into account to
detect such a change and the branch infos are recomputed accordingly.

Also, a button is now available on the branch form in order to manually
recompute those changes.
2020-02-11 17:05:33 +01:00
Christophe Monniez
46c8c6d635 [FIX] runbot: more flexible duplicate detection 2020-02-10 14:13:38 +01:00
Xavier-Do
6909b7e583 [IMP] runbot: allow build copy 2020-02-05 15:59:57 +01:00
Xavier-Do
c561f212e2 [IMP] runbot: improve build form view 2020-02-05 15:59:57 +01:00
Xavier-Do
a7ecf6a631 [FIX] runbot: fix build creation from view form
Before this commit, creating branch/build from view form may lead to errors
because of missing fields/ inexisting id.
2020-02-05 15:59:57 +01:00
Xavier-Do
3345d18050 [IMP] runbot: split prending count and scheduled count 2020-02-04 14:35:07 +01:00
Christophe Monniez
e267533513 [IMP] runbot: add pdfminer to Docker image
As pdfminer is going to be used in Odoo attachement_indexation module and
that there is no python3-pdfminer package in Ubuntu Bionic, it was
decided to have an optional dependency.

In order to run the attachement_indexation tests, the pip package is
added to the runbot Docker image.
2020-01-30 14:52:29 +01:00
Xavier-Do
e65859c161 [FIX] runbot: catch ValueError instead of RunbotException in safe_eval 2020-01-24 13:09:36 +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
Christophe Monniez
61101eaf46 [FIX] runbot: fix separtor class in build template 2020-01-22 13:32:27 +01:00
Christophe Monniez
e4e2634de1 [FIX] runbot: keep tests directory
Since 857821e4 a screenshot can be saved in the build directory under
the "tests" subdirectory.
Unfortunately, this directory is cleaned in case of local_cleanup.

With this commit, the 'tests' subdirectory is kept in place.
2020-01-22 13:32:27 +01:00
Xavier Morel
5d1772a9a5 [FIX] runbot: redirect to the relevant build on actions
Currently killing, waking or rebuilding a build then redirects to the
repository root which is worse than useless: you've lost the build you
come from, and for rebuilds it's no help getting to the new build.

Since it's very easy to go from a build to its repository, redirect to
the "most useful" build instead:

* if rebuilding the current build (from its page), open the page of
  the new build which was just created
* otherwise reload the current page whatever it is
2020-01-21 09:21:02 +01:00
Xavier-Do
4ae6907e3a [FIX] runbot: keep description on exact rebuild 2020-01-20 14:44:16 +01:00
Christophe Monniez
ca4768230d [FIX] runbot: avoid crash when creating migration symlink 2020-01-17 17:14:12 +01:00