Commit Graph

835 Commits

Author SHA1 Message Date
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
Christophe Monniez
bf9ec0b7db [FIX] runbot: add file command to build Odoo 8.0 and 9.0 2020-01-17 17:10:25 +01:00
Xavier-Do
eede4dcd77 [IMP] runbot: filter hidden on monitoring page 2020-01-17 16:36:30 +01:00
Xavier-Do
3f997cff25 [IMP]: runbot: improve create performances. 2020-01-17 14:41:18 +01:00
Xavier-Do
9556723617 [FIX] runbot: fix exact rebuild without config_data 2020-01-17 14:41:18 +01:00
Xavier-Do
7058868c0f [IMP] runbot: select for update in ask_kill
When a build has a lot of children, _ask_kill can fail due to concurrent_update.
This solution locks all build before reading/updating builds.
2020-01-17 14:41:18 +01:00
Xavier-Do
534bb728ce [IMP] runbot: add parent_path 2020-01-17 14:41:18 +01:00
Xavier-Do
a2256fffb8 [FIX] runbot: don't detect duplicate on rebuild. 2020-01-17 14:41:18 +01:00
Christophe Monniez
cb05f2b9d8 [FIX] runbot: use template1 when creating databases 2020-01-17 13:53:52 +01:00
Xavier-Do
2274f7ab8b [FIX] runbot: handle externally killed docker.
If a docker is killed from outside, the start file will still be there but
not the end file. (when restarting docker service for instance)
This commits add a docker_state specific to non running docker
with start a file, that should be handled like unknow state:
This state is acceptable for a while, but build should be killed
if this state remains for to long.
2020-01-16 14:47:40 +01:00
Xavier-Do
d75c4f085f [FIX] runbot: fix duplicate id and improve global_state 2020-01-16 13:41:29 +01:00
Xavier-Do
c58d1626ea [FIX] runbot: config_data in duplicates and rebuild 2020-01-15 17:19:42 +01:00
Christophe Monniez
e56bb7a943 [IMP] runbot: allow kwargs in monitoring page 2020-01-15 14:14:53 +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
Christophe Monniez
a7f1b94c41 [IMP] runbot: add a description field on build 2020-01-15 13:32:38 +01:00
Xavier-Do
190f03ab1e [FIX] runbot: update hook time as sudo on rebuild request 2020-01-15 12:40:38 +01:00
Xavier-Do
c7fccf3b56 [FIX] runbot: fix monitoring routes 2020-01-15 12:07:01 +01:00
Christophe Monniez
8cc82b7dde [FIX] runbot: fix compute previous_version and intermediates
When changing the sticky value in a branch form, it triggers the
computes of previous version and intermediate versions.

In the onchange situation, the branch.id is a NEW id and it fails with a
traceback.

With this commit, a verification is made to ensure that the id is there.
2020-01-15 10:22:18 +01:00
Christophe Monniez
45799df094 [FIX] runbot: temporarily freeze the coverage version
As the Odoo requirements were recently updated, the last RUN entry in
the Docker image was rebuilt on our runbot instances.

Since that moment the coverage builds are failing with an import error.
After investigation, it appears that the latest coverage version modifies the sys.path.
A bug report was written for coverage: https://github.com/nedbat/coveragepy/issues/919

For that reason, this commit freeze the coverage version until this bug
is fixed.

Also, the os import problem in conatainer.py is fiexed.
2020-01-14 13:46:58 +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
ec88a68e8a [IMP] runbot: avoid partial invalidation 2020-01-14 13:24:58 +01:00
Xavier-Do
163fa6ca59 [FIX] runbot: fix views 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
2b70c0bcc4 Revert "[IMP] runbot: use counts for global states"
This reverts commit 54f9b9b546.
The main reason is linked to inconsistency in state compute because
of error in nb_ computations.

This was to avoid concurrent update, witch is not a such a big problem
now since workers are no longer using crons. (retry on failure is faster).
2020-01-14 13:24:58 +01:00
Xavier-Do
650a93fee7 [FIX] runbot: fix auto test-tags False 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
9215a23cc1 [FIX] change version number to avoid second execution when migrating to 13.0 2020-01-14 13:24:57 +01:00
Xavier-Do
3ef33a5320 [FIX] runbot: clear environment, do not reset
Resetting env will make this env unusable with the new orm,
breaking field recomputes logic
2020-01-14 13:24:57 +01:00
Xavier-Do
20f97798d9 [FIX] runbot: use create_single decorator everywhere
All create in odoo are now create_multi. This is a quick and dirty
fix to make it work with runbot.
2020-01-14 13:24:57 +01:00
Xavier-Do
8dcaa6669b [FIX] runbot: allow portal user to see frontend 2020-01-14 13:24:57 +01:00
Xavier-Do
4e694ffefa [IMP] runbot: addapt tests to 13.0 2020-01-14 13:24:57 +01:00
Xavier-Do
1dcea28f45 [FIX] runbot: make field name unique 2020-01-14 13:24:57 +01:00
Xavier-Do
1069598616 [REF] runbot: use selection_add 2020-01-14 13:24:57 +01:00
Xavier-Do
df157f7742 [REF] runbot: add descriptions 2020-01-14 13:24:57 +01:00
Xavier-Do
2b53c7cfd0 [REF] runbot: adapt cron path 2020-01-14 13:24:57 +01:00
Xavier-Do
e706bb70c2 [REF] runbot: remove deprecated model_cr 2020-01-14 13:24:57 +01:00
Xavier-Do
24189fd0ee [REF] runbot: runbot deprecated api.multi 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
Christophe Monniez
501142c561 [IMP] runbot: allow to rebuild a branch
When a repo is set to "no_build", there is no way to force a branch to
build from the backend.

With this commit, a button is added on a branch form to ask rebuild of the
branch, even when the repo is set to "no_build".
2019-12-19 15:41:11 +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
328ba2d9c2 [IMP] runbot: adding some log 2019-12-18 17:37:06 +01:00
Xavier-Do
9ae816a23d [IMP] runbot: add some log 2019-12-18 17:27:33 +01:00
Christophe Monniez
7606c03c35 [IMP] runbot: allow to change prefix in multi wizard
Also fix the modules that were not set on the config step.
2019-12-18 16:36:14 +01:00
Xavier-Do
cede4b936e [FIX] runbot: fix docker state and rebuild button
When docker is stopped, end command cannot execute.
Thus the state is considered as running.
2019-12-18 16:30:01 +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
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
Christophe Monniez
e8eb4eea10 [IMP] runbot: add unzip tool in Docker image 2019-11-22 15:42:48 +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-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-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
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
Xavier-Do
af4037261f [IMP] runbot: display childrens on duplicate 2019-10-28 10:54:46 +01:00
Xavier-Do
ddb7bec0c2 [FIX] runbot: remove useless divide by 2 2019-10-28 10:54:08 +01:00
Xavier-Do
3bf0550b3a [FIX] runbot: rename duplicate field description 2019-10-25 19:19:27 +02:00
Xavier-Do
a3d908ac03 [FIX] runbot: fix forgotten cleanup 2019-10-22 17:18:30 +02:00
Xavier-Do
18b37d9002 [IMP] runbot: gc database faster if corresponding build has parent_id 2019-10-22 16:55:12 +02:00
Xavier-Do
c874f4a046 [IMP] runbot: execute flamegraph in case of failure and log dl link 2019-10-22 14:33:10 +02:00
Xavier-Do
8284c7270d [IMP] runbot: add message if docker does not match dest format 2019-10-22 11:40:46 +02:00
Xavier-Do
702a52464d [FIX] avoid docker_ps crash if docker is not installed. 2019-10-22 10:35:09 +02:00
Xavier-Do
7f4f82a881 [FIX] runbot: docker cleanup should be run on workers only 2019-10-21 17:41:59 +02:00
Xavier-Do
ecd718ca2a [FIX] runbot: fix default modules and flamegraph 2019-10-21 17:03:43 +02:00
Xavier-Do
ec8a70a410 [IMP] runbot: allow to generate a flamegraph during a build
With this commit, a new boolean field "flamegraph" is added on the
build_config to allow a flamegraph generation.

In order to be able to generate a flamegraph during a runbot build, the
flamegraph package is added to the Docker image as well as the
flamegraph.pl tool.
2019-10-21 16:30:22 +02: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
d869d22f7b [FIX] runbot: add forgotten imports
Oversight of previous commit.
2019-10-21 15:17:58 +02:00
Christophe Monniez
5ff9cc2382 [FIX] runbot: clean running dockers with done builds
In different situations, a docker container may stay alive even if the
build global_state is done. This can lead to a build failure when a
build wants to go in running state and tries to expose the same ports as
the left over build.
2019-10-21 10:52:45 +02:00
Xavier-Do
5b12f37c74 [REV] runbot: Avoid infinite loop fetching"
This reverts commit 1207daded1.

A too quick review, setting a default value is a good idea but since field is a float now,
default value should be time.time
2019-10-18 20:20:10 +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
Moises Lopez - https://www.vauxoo.com/
1207daded1 [FIX] runbot: Avoid infinite loop fetching
Using `repo.hook_time = None` and `repo.mode = hook` the cron run fetch command in an infinite-loop.
2019-10-18 11:18:46 +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
Xavier-Do
ac578d430d [IMP] runbot: propagate end_time to parent_build
When a build only create sub-builds, the build_time is verry small (a few seconds),
and this information is not relevant. This commit propagates end_time to parent_build
if parent_build is done or running.
2019-10-16 14:25:43 +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
a2a8fe31f1 [IMP] runbot: add firebase-admin to the Docker file
The new feature in odoo/enterprise#4879 needs the firebase-admin
package. As it cannot be added to the requirements.txt, the package is
added in the Dockerfile to be able to test it on the runbot instances.
2019-09-20 14:46:21 +02:00
Christophe Monniez
47ad04dc37 [FIX] runbot: remove duplicate import in tests 2019-09-18 15:32:19 +02:00
Christophe Monniez
56999ecfb4 [IMP] runbot: various improvements
- Add a keep running flag on the build to allow a build to stay in
  running state until the flag is switched off ( or the build killed)
- Do not update configs and config_steps data
- Add a first/last_seen_build and first/last_seen_date on build.error
- Children error builds now include the parent builds too
- Use a notebook on build.error form view to display builds and linked
  errors
- Update result when a build triggers a change from 'warn' to 'ko' too
- Add the sticky flag on the error logs stored sql view
2019-09-18 15:27: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
Christophe Monniez
54f0488b26 [IMP] runbot: add a copy to clipboard button for branch
When using the runbot frontend, it's sometimes very frustrating when
trying to copy branch name, some mouse gym is necessary.

With this commit, a copy to clipboard button is added near the branch
name on the frontend.
2019-09-18 13:10:45 +02:00
Christophe Monniez
5f8e80ea77 [IMP] runbot: add dbfread to the Docker image
The new feature in odoo/enterprise#4892 needs the dbfread module.
As this lib is not required for other Odoo modules, it cannot be added
to the requirements.txt file.

In order to run the tests and use this new feature on the runbot, this
commit installs the dbfread lib in the Docker image.
2019-09-10 10:07:54 +02:00
Xavier ALT
f25ab94517 [FIX] runbot: correctly order repo by sequence
Even if present and editable the user, changing the sequence
of a repository has no effect

Fix by adding missing _order on runbot.repo model
2019-09-06 11:01:15 +02:00
Christophe Monniez
c5582ce154 [FIX] runbot: remove skip old builds logic
When finding new commits, if there is more pending builds on a repo than
the running_max parameter, the exceeding builds are skipped.

As a result, when nightly builds are created on the runbot, it happens
that some of them are skipped.

Also, since e51412d , only refs newer than max_age are builded; thus the
logic is not needed to prevent rebuild of olds refs in case of a fresh
runbot install.
2019-09-04 11:05:43 +02:00
Christophe Monniez
cc388715bc [FIX] runbot: properly compute children_build_ids
The Many2many related on a Many2many does not map the ids as expected.
With this commit, the records are mapped in a compute.

It also fixes an uppercase letter was used in the children_build_ids field name.
2019-09-03 15:33:39 +02:00
Xavier-Do
e7d59d4f88 [IMP] runbot: setting multi to 20 builds 2019-09-03 11:10:38 +02:00
Xavier-Do
9a9de6ad85 [FIX] runbot: fix build_end and port
When killed a build could have his build end changed (problematic when
killing a running since build_time must represent the testing time)
-> if a build already has a build end, don't overwrite it.

Port also needs to be reset on wake_up since another build would have
recycle the current one since port unicity is limited to build not in
done state. This was working most of the time before since port unicity
was determined cross runbots, thus we only had one chance over 17
to have a conflict on wake up. (this changed with prevous commit)
2019-09-03 11:10:38 +02:00
Xavier-Do
2e44c51678 [FIX] runbot: limit port search to local host.
With the increasing number of runbot servers (17), the total number of docker
instances can reach more than 3570 only for running build. Starting at 2000,
this covers the posrt 5432 used by postgress and make the build run step fail.

This commit simply limit the port unicity constraint by host.
2019-09-03 11:10:38 +02:00
Christophe Monniez
5297ac0f5f [IMP] runbot: show no_build on branch form 2019-09-03 11:10:38 +02:00
Christophe Monniez
4c75a8e107 [IMP] runbot: add an action to parse logs from build error views 2019-09-03 11:10:38 +02:00
Christophe Monniez
c49e422a25 [IMP] runbot: add an error log model based on a SQL view
With this commit, a new model is introduced to facilitate the tracking
of the build errors.

Its based on an SQL view (Thanks @Xavier-Do), that way, there is no new
table in DB and this view is also useful from the PSQL CLI.

In the UI, the search for errors easier than manipulate the ir_logging
view because the builds informations can be used in search and filters.
2019-09-03 11:10:38 +02:00
Xavier-Do
7382aa6b79 [FIX] runbot: various small fixes and imps 2019-09-03 11:10:38 +02:00
Christophe Monniez
f94c8d7390 [FIX] runbot: use odoo repo for google-chrome
The since google chrome 74, a random bug makes it crash at startup,
making the odoo tests crash.

With this commit, an odoo custom deb repo is used on nightly with a
known working chrome version.
2019-09-03 11:10:38 +02:00
Xavier-Do
a91b08897f [IMP] runbot: improve archive failure logging 2019-09-03 11:10:38 +02:00
Christophe Monniez
57a32ee937 [IMP] runbot: log error instead of info when wake up fails 2019-09-03 11:10:38 +02:00
Christophe Monniez
8d199b4c16 [FIX] runbot: catch exceptions on wake-up
When a build is wake-up and something goes wrong during the
_run_odoo_run method, the "fetch and build" cron is broken and the
concerned runbot host stops working.

With this commit, the exception is catched and the build goes back to
the "done" state whith a log.
2019-09-03 11:10:38 +02:00
Christophe Monniez
0da30a9f60 [IMP] runbot: add build_error model
With this commit, a new RunbotBuilError model is added in order to
classify and manage errors that appears during runbot builds.  This is
an helper to find undeterministic bugs in Odoo builds.  Build logs can
be parsed on demand, during the parsing, the logs are cleaned with some
regexes stored on the RunbotErrorRegex model.  A hash is computed on the
cleaned log, if a build error already exists with the same fingerprint,
the build is appended on the build error.

Errors can also be manually linked together with a parent/children
relation in case of a related error log. e.g. the error message is
different in two different branches but the bug is the same.

Also, a new build_url field is added to the runbot_build in order to
access the build web page from the backend.
2019-09-03 11:10:38 +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
2a18ef4195 [FIX] runbot: missing indirect
In some case _force can return an empty recordset,
if the corresponding branch is in no_build mode in other
repo may be an explanation here.

This commit avoid to stuck the fetch and build loop in this case.
2019-08-19 12:13:55 +02:00
mreficent
9b174ab706 [FIX] runbot: typo (closet -> closest) 2019-08-14 11:43:03 +02:00
Christophe Simonis
059957282e [IMP] runbot: use babel helper to format timedelta
It allow minimal granularity to minutes and rollover thresholds.
2019-08-13 17:56:52 +02:00
Christophe Monniez
857821e41a [IMP] runbot: use the odoo screenshots args
Since odoo/0dc4a63e2 the screenshots arguments can be used to specify
where to save sceenshots.
With this commit, the argument is used if available.
2019-08-13 14:46:07 +02:00
Xavier-Do
13ca8b98cf [IMP] runbot: only update hook on push event
Hook can represent label changes, closed pr, ....
We only want to fetch is some push or synchronize are sent.

TODO We also may want to catch retarget later in order to update branch.
2019-08-13 14:33:19 +02:00
Xavier-Do
d68d0ffa81 [FIX] runbot: fix tracking visibility
Tracking was inspired from master state of the art. This commit addapt
everything to 11.0 tracking in ordr to make it work.
2019-08-13 14:32:18 +02:00
Xavier-Do
a374c2cba3 [FIX] runbot: fix indirect mechanism
indirect state was writen on parent leading to unconsistent info.
indirect was using last build regardless of build_type. Now, indirect
will only use normal build to avoid red-chain after a sticky rebuild.
2019-08-13 14:30:41 +02:00
Xavier-Do
626f454d8b [IMP] runbot: commit message dep param.
A prototype of feature was added some times a go.
No really tested, this commit improves parmater format
and makes dependency closest_branch_id not required
since a repo/sha is all we need.
2019-08-13 14:30:30 +02:00
Xavier-Do
46a7362d18 [FIX] runbot: tempfix wait for docker mechanism
Docker can take some time to be considered as running after docker_run. This
issue can appear when we speedup sheduling loop. To avoid that when can add an
time condition to consider if a docker is running, but we want to avoid to wait
to much since some jobs are fast.

This solution check if a job is a docker run before waiting, and will also
update job_start after a checkout since this can take some time if
a git fetch is performed.
2019-08-13 14:19:51 +02:00
Xavier-Do
5bbfb06ce1 [IMP] runbot: keep result on kill if result is failure
When a build is killed, result will be set to manually killed,
removing the 'error' or 'warn' result.

This commit removes this behaviour in order to keep error result
in this case.
2019-08-13 14:15:26 +02:00
Xavier-Do
2aed7e1a48 [IMP] runbot: imp build result display
If children are killed, they will all look the same in the parent view
making difficult to find the failed one in staging branches.

This commit displays result rather than status in priority if build
is in failure.
2019-08-13 14:12:31 +02:00
Xavier-Do
694f9e6e05 [IMP] runbot: only gc db after job end
If a user really wants to keep a database up for a long time, he has the possibility
to wake it up multiple times.

Using last job end as reference will allow to keep a database alive longer.
2019-08-13 14:10:21 +02:00
Xavier-Do
fb637194f5 [FIX] runbot: use parent global_state for gitthub status
The main motivation of this commit is to be able to notify github status only
when all children are done.

Until today, children where only used for dev branches and nightly. The needs to
use this system for staging need to enforce github_status behaviour.
Before this commit, a parent won't send github status since he will only
create childrens. And childrens are not awared of other children state,
so sending a succes may be wrong if another one failed.

Asking the parent to make the github_status looks the easiest solution:
-If top parent config will have update_github_state False, we also want to take that into account.
-If a child wants to contact github for failfast, parent will be in global_state error too and will send
message immediatly.
-If a child want to contact github for succsess, we actually want to wait for last child, parent will
be in waiting global_state and notify nothing (or pending).
Only last child will be able to notiffy success since global_state will be running or done at this step.
Orphan builds wont have any impact on result in with this scenario.
2019-08-13 14:03:14 +02:00
Xavier-Do
2e5b1cb240 [FIX] runbot: fix typo
kill -> _kill
2019-08-13 11:10:21 +02:00
Xavier-Do
0efd3fde1d [FIX] runbot: less noisy log
Some data are logged at each loop turn even if nothing interresting was done:
- ... builds [] where allocated to runbot
- reload nginx

That kind of info was interresting for debug but now this noise makes
logs heavier and more difficult to read.
Reload ngnix will be done only if file changed and this this will avoid
a log at each loop turn.

We also display difference between existing sources and source that should
be there instead of complete lists.
2019-08-13 10:58:00 +02:00
Xavier-Do
75dc7bd605 [IMP] runbot: clean sources once they are not used
Sources can be easily exported if needed since they are in the bare repository
most of the time. To avoid using to much space, this commit will garbage collect
all sources at the beginning of a long_running cron.

Only real side effect of this is that it will be impossible to wake up
a build that was force pushed since source cannot be fetched anymore.
We may imagine that we could keep sources of recent build, maybe for
48 hours, but keeping build specific data (logs, database)
is more interresting.
2019-08-13 10:35:19 +02:00
Xavier-Do
22fe792e9f [IMP] runbot: add wake_up button where connect button usually stands
This commit add a wake up button in place of connect button when build is
not running and may be wake up.

Connect button will also be visible immediatly when local_state is 'running'
since we don't need to wait sub build to finish.
2019-08-13 10:33:37 +02:00
Christophe Monniez
dcf3297bff [FIX] runbot: forbid wake-up on dead builds
When a build is completely dead, with directory and db deleted, the
wake-up system fails.

With this commit, a wake-up is not allowed on such dead builds.
2019-07-19 13:56:19 +02:00
Christophe Monniez
c3e23532be [IMP] runbot: allow nginx access to tests dir
In order to stores other things than logs, that could be accessible by
end users, for example screenshots and screencasts, a "tests" directory
is allowed thruough the nginx template in the builds directories.

Also, the "with" context manager is used to open the nginx configuration
to ensure that the file descriptor is released during long running crons.
2019-07-18 14:39:38 +02:00
Xavier-Do
287efc7989 [FIX] runbot: make result for python code too 2019-07-17 15:51:20 +02:00
Xavier-Do
090b84c86c [FIX] runbot: partial fix for build time with children 2019-07-17 15:51:20 +02:00
Xavier-Do
99fcd9638a [IMP] runbot: take care or extras
If a param is in extra, dont add it automaticaly.
This will allow to remove custom 'test from extras' step.
2019-07-17 15:51:18 +02:00
Xavier-Do
87c794a9aa [IMP] runbot: add wake up option on builds 2019-07-17 11:34:45 +02:00
Christophe Monniez
dbe44e2a76 [FIX] runbot: prevent inter Docker communication
When an Odoo instance is run in a Docker container, it listen on all
interfaces by default and a bridge interface is used to communicate with
the outside world.

This bridge interface is necessary to allow the instance to send logging
messages into the runbot postgresql database.

Even though Docker isolate the container from the oustide world, it's
still possible to reach the Odoo instace from the runbot host and worse,
from other Docker containers using the same bridge interface.

To confirm the  Murphy's law, it finally happened with this commit
odoo/enterprise@0ba0ef99de that scanned the ip range of the interface,
disturbing other builds.

One solution would be to create a bridge interface for each instance to
isolate each Docker but that would imply a big change to garbage collect
forgotten bridges ...

An 'icc' (Inter Container Communication) option exists for the Docker
daemon which defaults to True. Setting it to False was tested and works
but it appears that this option can be messed-up by the firewall on the
runbot host.

Finally, if applied, this commit will prevent the Odoo instance to
listen on the bridge interface by only listening to 127.0.0.1 during
tests. A local_only parameter is a added on the _cmd method which is
true by default and means that the Odoo instance will only listen on
127.0.0.1. This parameter is set to False for the running step to allow
the running to be contacted through the Docker exposed ports.
2019-07-17 10:52:14 +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
785001acac [FIX] runbot: fix _coverage_params 2019-07-12 16:37:39 +02:00
Xavier-Do
c31c9642be [IMP] runbot: add read_source on commit 2019-07-12 16:31:17 +02:00
Xavier-Do
21c3686543 [FIX] runbot: _log not log 2019-07-12 15:18:40 +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
Christophe Monniez
0830557cd6 [FIX] runbot: avoid "Modules loaded not found in logs"
In some conditions, Docker can take a little time to start a container.
In that case, if the runbot checks that the container is running before
it starts, runbot consider the job as finished. It the tries to grep the
logs and, as expected, it does not find the "Modules loaded".

With this commit, we consider young builds (less than 15 sec) as
running, giving more time to Docker for starting it.
2019-07-09 13:15:14 +02:00
Christophe Monniez
19b36e4ee6 [FIX] runbot: set force_rebuild when creating multi builds
When creating multi builds config steps, the force_build option is often
forgotten. In that case, the multi builds are detected as duplicate of
the first one.

With this commit, when asking for more that one multi build, the
force_build is chnaged to to True.
2019-07-05 18:03:24 +02:00
Xavier-Do
1b2940705d [FIX] runbot: fix ask_kill for children_ids 2019-07-04 12:17:22 +02:00
Xavier-Do
c4837641cc [FIX] runbot: fix result when make_result crash 2019-07-04 11:48:33 +02:00
Xavier-Do
2de144d299 [IMP] runbot: select all db strating by dest when cleaning 2019-07-04 10:25:25 +02:00
Xavier-Do
fe6788e349 [IMP] runbot: lock an host
In order to be able to test some custom code on one specific worker,
this commit will allow to lock a runbot so that he will only run
assigned build.
2019-07-03 16:23:48 +02:00
Xavier-Do
6bc666b5c3 [IMP] runbot: avoid loosing hooks
In the same spirit of getting garanties that community is updated when enterprise is,
force the hook time of dependencies in case it was lost.
2019-07-03 16:23:48 +02:00
Xavier-Do
f51a021dfe [IMP] runbot: update repo in reversed order
When updating repo, order is  odoo/odoo, odoo-dev/odoo, odoo/enterprise, odoo-dev/enterprise
The problem with this is that if a community hash and an enterprise hash arrives exactly
between odoo/odoo and odoo/enterprise update, enterprise could have a newest version
than community when creating builds.

By inversing this order, we have less chances to have this cornercase (as unlikelly as
it could be)
2019-07-03 16:23:48 +02:00
Xavier-Do
83a0568403 [FIX] runbot: write duplicate_id instead of duplicate when killing build 2019-07-03 16:22:08 +02:00
Xavier-Do
1ffa0468c1 [IMP] runbot: keep cron on transaction rollback 2019-07-03 12:58:58 +02:00
Xavier-Do
c5e0da174a [FIX] runbot: fix exact rebuild 2019-07-03 10:56:57 +02:00
Xavier-Do
53267d64bb [IMP] runbot: improve error logs 2019-07-03 10:50:47 +02:00
Xavier-Do
84ad4cefe0 [IMP] runbot: only display default config in glances 2019-06-27 12:43:24 +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
5c72655e18 [FIX] runbot: invalidate cache at each commit.
In some rare case db could become inconsistent if some data
in cache were used between two _schedule loop turn.
2019-06-25 16:15:24 +02:00
Xavier-Do
94a680f0c8 [FIX] runbot: get_ref_time as float
get_ref_time was cast from float to datetime and thus,
milliseconds where lost. Storing it as float make code
easier to read and avoid this rounding that was breaking
 this feature.
2019-06-24 15:59:21 +02:00
Xavier-Do
b64c7adce2 [FIX] runbot: make nb_testing count correct when children are duplicates 2019-06-24 15:59:21 +02:00
Christophe Monniez
e51412d558 [IMP] runbot: only consider refs newer than max_age
When getting new refs, a lot of them are really old and the
find_new_commits is called for each one and thus browsing branches.

With this commit, refs older than configured max_age are ignored.

Co-authored-by: Xavier Dollé (xdo@odoo.com)
2019-06-24 14:33:17 +02:00
Xavier-Do
54f9b9b546 [IMP] runbot: use counts for global states 2019-06-24 14:29:52 +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
7adfa6c7eb [FIX] runbot: add an index on local state
A slow query was detected on the runbot, causing a latency when loading
any page. After some investigations (thnks jle), we found that an index
on local_state could improve speed.
2019-06-19 15:37:31 +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
2fb0f2c79a [FIX] runbot: kill children even if state is done 2019-06-18 13:33:45 +02:00
Christophe Monniez
ae1eed46f5 [IMP] runbot: add optional warning message on frontend 2019-06-18 12:43:25 +02:00
Xavier-Do
080d5a4e1b [IMP] runbot: remove testing count from repo view 2019-06-18 12:42:07 +02:00
Xavier-Do
6d36455ef1 [FIX] runbot: ensure that job and build end are always set. 2019-06-18 12:42:07 +02:00
Xavier-Do
af7a8b7d8b [IMP] runbot: kill subbuild when killing build 2019-06-18 12:42:07 +02:00
Xavier-Do
a246d60c71 [IMP] runbot: always create new build at rebuild 2019-06-18 12:42:07 +02:00
Xavier-Do
17c57d499e [IMP] runbot: exact rebuild
allow to rebuild using exact config, dependencies, ...
2019-06-18 12:42:07 +02:00
Xavier-Do
a3ff9d102d [IMP] runbot: small runbot_branch view improvements 2019-06-18 12:42:07 +02:00
Xavier-Do
7e9826ba4c [IMP] runbot: add build creation log 2019-06-18 12:42:07 +02:00
Xavier-Do
f691ab5a39 [IMP] add hidden in view form 2019-06-18 12:42:07 +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
Xavier-Do
bdc6506ede [IMP] runbot: always keep one empty slot when assigning sheduled
Nightly build have a low priority but once they have a slot, they keep it.
When pushing a branch or asking robodoo to nicelly merge a branch for the
third time at 22:00, there may be no slot left since all the nightly build are created.

This commit will only assign scheduled build if there is no other build to create and
will always keep a free slot for other builds.
2019-06-18 12:42:07 +02:00
Xavier-Do
86ffeac589 [FIX] runbot: test_enable should be True by default 2019-06-18 12:42:07 +02:00
Christophe Monniez
2715585e31 [IMP] runbot: add python3-markdown in Dockerfile
Needed for running migration scripts.
2019-06-18 11:50:48 +02:00
Christophe Monniez
b98ff23cd9 [IMP] runbot: add write_file and make_dirs methods
When using a "python job", it's sometimes useful to write a file or
create a directory.
Instead of giving a wide open access to the os module in the
"_run_python" context, this commit adds a write_file and make_dirs
methods on the build which is usable in the _run_python eval context.
2019-06-18 11:50:48 +02:00
Christophe Monniez
800691a14c [IMP] runbot: add a mode parameter to readfile
When using the read_method in a "python job", it's sometimes needed to
read a file in binary mode.

With this commit, the mode can be specified when calling the method.
2019-06-18 11:50:48 +02:00
Christophe Monniez
799f3aed22 [IMP] runbot: add more objects in run python
Since the use of the "python jobs", we spotted various needs that were
not fulfilled. In order to add flexibility to "python jobs", this commit
adds some useful objetcs in the _run_python eval context.

Also, the glob.glob function is given instead of the whole glob module
to avoid giving access to the os module via glob.os.
2019-06-18 11:50:48 +02:00
Xavier-Do
c5588b1861 [IMP] runbot: display config name 2019-06-18 11:31:14 +02:00
Christophe Monniez
a9cd5d7a60 [IMP] runbot: allow to configure workers per host
When a runbot instance is scheduling builds, the numbers of builds
depends of a global ir.config_parameter. Even if one of the runbot
instance is running on a more powerful systsem, its number of workers is
limited by this global parameter.

With this commit, this parameter still exists but can be overriden by
specific ir.config_parameter.

For example, if the host 'runbot24.odoo.com' has more cpu power, the
number of workers for this host can be specified in the
ir.config_parameter named 'runbot24.odoo.com.workers'.
2019-06-17 12:44:14 +02:00
Christophe Monniez
b1add16fbd [FIX] runbot: add missing apt update in Dockerfile
When installing software with apt-get in a Dockerfile, it should be
preceded with an apt-get update in the same RUN. Otherwise, the step may
fail if the needed package has been updated.
2019-06-07 10:15:24 +02:00
Christophe Monniez
82dbf43083 [IMP] runbot: add es-check tool to the Docker image
In order to use the new test odoo/odoo#33724 the es-check tool is needed
in the Docker runbot image.
2019-06-04 07:37:51 +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
c24df5fac2 [FIX] runbot: choose quickconnect build with same config
When the quickconnect button is used, the last running build is
searched in the last 10 builds. If no running build is found, the last
one is rebuilt, even if it's a nightly build.

With this commit, the quickconnect build is choosen only among the ones
with the same config.
2019-05-23 10:52:13 +02:00
Xavier-Do
0384f2c98b [FIX] runbot: correct indentation 2019-05-22 14:08:45 +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
534368b675 [FIX] runbot: minimize transactionnal errors
With recursive states computation, schedule is
most likely to have transactionnal errors.
This is particularly a problem when external
operations are done during the transaction,
like running a docker.

Adding some commits will help to reduce
transactionnal errors, and ensure that the db
is consistent with docker states.
2019-05-22 10:15:53 +02:00
Christophe Monniez
45516f9d33 [FIX] runbot: properly call _log when time exceeds 2019-05-22 09:25:56 +02:00
Christophe Monniez
5761fd1694 [FIX] runbot: properly omit manifest files in coverage 2019-05-21 23:21:45 +02:00
Xavier-Do
519f50790d [FIX] runbot: make python jobs usable and improve logs 2019-05-21 16:03:47 +02:00
Christophe Monniez
d3e3f75224 [FIX] runbot: only logged in users are allowed to kill
As the public user needs to be in runbot user group to display the
frontend, the public user is allowed to kill or rebuild a build.

With this commit, only the logged in users have access to the Rebuil/Kill
menu entry.
2019-05-21 09:42:46 +02:00
Christophe Monniez
d55a71d675 [FIX] runbot: oversight of a repo arg not needed anymore 2019-05-20 11:23:27 +02:00
Xavier-Do
427639b77a [FIX] runbot: various fixes (data improvement, python step, logs, ...) 2019-05-20 10:52:13 +02:00