Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syncing from upstream odoo/runbot (18.0-min-max-version-xdo) #819

Open
wants to merge 37 commits into
base: 18.0-min-max-version-xdo
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
7542f41
[FIX] runbot: fix _compute_similar_ids
Xavier-Do Jan 2, 2025
a0ff53f
[IMP] runbot: add config_data to trigger form
Williambraecky Jan 2, 2025
e49c583
[FIX] runbot: replace target new with _blank
Williambraecky Jan 3, 2025
86810df
[FIX] runbot: fix frontend team dashboards again
d-fence Jan 6, 2025
6a58915
[FIX] runbot: remove unknown compute
Williambraecky Jan 8, 2025
5652adb
[FIX] runbot: fix typo in reference build message
Williambraecky Jan 6, 2025
6bd7a30
[IMP] runbot: fix display error in bundle toolbar
Williambraecky Jan 2, 2025
1add8d5
[FIX] runbot: fix branch search
Williambraecky Dec 12, 2024
5d99d53
[IMP] runbot: add a widget for pull requests url's
d-fence Dec 6, 2024
1fa7e4c
[IMP] runbot: improve pull request widget
Williambraecky Dec 23, 2024
c9c31f8
[IMP] runbot: support github display for branch search
Williambraecky Jan 22, 2025
56912d3
[IMP] runbot: allow to specify a custom docker registry
Xavier-Do Jan 29, 2025
18bb21e
[REF] runbot: replace deprecated _cr access
Williambraecky Jan 21, 2025
344792a
[IMP] runbot: add created by me on exceptions
Williambraecky Jan 23, 2025
f7003fb
[IMP] runbot: support environment variables in config data
d-fence Feb 7, 2025
d6a77ce
[IMP] runbot: qualify error contents on selected fields
d-fence Dec 5, 2024
c29b55a
[IMP] runbot: remove auto tag if fixing match
Williambraecky Jan 31, 2025
6409a14
Update README.md
kiga-odoo Feb 11, 2025
0594c71
Update README.md
kiga-odoo Feb 11, 2025
ff6160b
[IMP] runbot: add tracking on error qualiliers
Xavier-Do Feb 10, 2025
b0201bd
[PERF] runbot: remove row_number queries
Williambraecky Dec 5, 2024
415bd31
[IMP] cleaner reference builds display
Xavier-Do Feb 18, 2025
d0eaa85
[IMP] runbot: faster main page
Xavier-Do Feb 18, 2025
48cd3a7
[IMP] runbot: fetch fields on build instead of params
Xavier-Do Feb 18, 2025
8012b57
[IMP] runbot: custom triger without branch changes
Xavier-Do Feb 19, 2025
f18e6c7
[IMP] runbot: allow to use base commit on new batch
Xavier-Do Feb 19, 2025
38f4ad3
[FIX] runbot: fix parse log action window
d-fence Feb 13, 2025
6fe8026
[IMP] runbot: add common and unique qualifiers on build error
d-fence Jan 23, 2025
53c2afa
[IMP] runbot: send status on dependencies
Xavier-Do Feb 24, 2025
bbd9d8d
[IMP] runbot: use reference batch to define reference builds
Xavier-Do Mar 12, 2024
34a92ac
[FIX] runbot: adapt upgrade test
Xavier-Do Mar 26, 2024
44a1956
[IMP] runbot: add host filter on load_info
Williambraecky Feb 24, 2025
1ed9278
[IMP] runbot: improve og data
Xavier-Do Feb 25, 2025
1c420c4
[IMP] runbot: add tracking on tags min/max version
Williambraecky Feb 27, 2025
77cd5c6
[IMP] runbot: add log metadata
Xavier-Do Mar 3, 2025
c2487f1
[ADD] runbot: smart button on build errors for build links list
lse-odoo Mar 3, 2025
9377df5
[IMP] runbot: improve min version management
Xavier-Do Dec 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 32 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This repository contains the source code of Odoo testing bot [runbot.odoo.com](h

**Runbot changes some default odoo behaviours** Runbot database may work with other modules, but without any guarantee.

**Runbot is not safe by itsefl** This tutorial describes the minimal way to deploy runbot, without too many security considerations. Only trusted code should be executed with this single machine setup. For more security the builder should be deployed separately with minimal access.
**Runbot is not safe by itself** This tutorial describes the minimal way to deploy runbot, without too many security considerations. Only trusted code should be executed with this single machine setup. For more security the builder should be deployed separately with minimal access.

## Glossary/models
Runbot use a set of concept in order to cover all the use cases we need
Expand Down Expand Up @@ -42,23 +42,23 @@ You may configure a DNS entry for your runbot domain as well as a CNAME for all
```
* IN CNAME runbot.domain.com.
```
This is mainly usefull to access running build but will also give more freedom for future configurations.
This is mainly useful to access running build but will also give more freedom for future configurations.
This is not needed but many features won't work without that.

### nginx

An exemple of config is given in the example_scripts folder.
An exemple of config is given in the `example_scripts` folder.

This may be adapted depending on your setup, mainly for domain names. This can be adapted during the install but serving at least the runbot frontend (proxy pass 80 to 8069) is the minimal config needed.
Note that runbot also has a dynamic nginx config listening on the 8080 port, mainly for running build.
This may be adapted depending on your setup, mainly for domain names. This can be adapted during the install but serving at least the runbot frontend (proxy pass `80` to `8069`) is the minimal config needed.
Note that runbot also has a dynamic nginx config listening on the `8080` port, mainly for running build.

This config is an ir_ui_view (runbot.nginx_config) and can be edited if needed. The config is applied and updated automatically after some time by the builder process.
This config is an `ir_ui_view` (runbot.nginx_config) and can be edited if needed. The config is applied and updated automatically after some time by the builder process.

It is also advised to adapt this config to work in https.
It is also advised to adapt this config to work in `https`.

### Requirements

Runbot is an addon for odoo, meaning that both odoo and runbot code are needed to run. Some tips to configure odoo are available in [odoo setup documentation](https://www.odoo.com/documentation/15.0/setup/install.html#setup-install-source) (requirements, postgres, ...) This page will mainly focus on runbot specificities.
Runbot is an addon for odoo, meaning that both odoo and runbot code are needed to run. Some tips to configure odoo are available in [odoo setup documentation](https://www.odoo.com/documentation/18.0/setup/install.html#setup-install-source) (requirements, postgres, ...) This page will mainly focus on runbot specificities.

You will also need to install docker and other requirements before running runbot.

Expand Down Expand Up @@ -90,8 +90,8 @@ cd odoo
```

You may [add valid ssh key linked to a github account](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account)
to this user in order to clone the different repositories. You could clone in https but this may be a problem latter to access your ptivate repositories.
It is important to clone the repo with the runbot user
to this user in order to clone the different repositories. You could clone in `https` but this may be a problem later to access your private repositories.
It is important to clone the repo with the runbot user:

```bash
git clone --depth=1 --branch=15.0 [email protected]:odoo/odoo.git
Expand All @@ -114,16 +114,16 @@ If it is not working, ensure you have the docker group and logout if needed.

### Install and start runbot

This parts only consist in configuring and starting the 3 services.
This part is only consist in configuring and starting the 3 services.

Some example scripts are given in `runbot/runbot/example_scripts`

```bash
mkdir ~/bin # if not exist
mkdir ~/bin # if does not exist
cp -r ~/odoo/runbot/runbot/example_scripts/runbot ~/bin/runbot
```

Scripts should be adapted, mainly forthe `--forced-host-name parameter` in builder.sh:
Scripts should be adapted, mainly for the `--forced-host-name parameter` in `builder.sh`:

```bash
sed -i "s/runbot.domain.com/runbot.my_real_domain.com/" ~/bin/runbot/builder.sh
Expand Down Expand Up @@ -164,16 +164,16 @@ You can now connect to your backend and preconfigure runbot.
- Connect as admin (default password: admin).

Check odoo documentation for other needed security configuration (master password). This is mainly needed for production purpose.
You can check that in the `/web/database/manager` page. [More info here](https://www.odoo.com/documentation/15.0/administration/install/deploy.html#security)
You can check that in the `/web/database/manager` page. ([more info here](https://www.odoo.com/documentation/18.0/administration/on_premise/deploy.html#reset-the-master-password)) \
Change your admin user login and password
You may want to check the runbot settings (`Runbot > Setting > setting`):
- Default number of workers should be the max number of parallel build, consider having max `#cpu - 1`
- Modify `Default odoorc for builds` to change the running build master password to something unique ([idealy a hashed one](https://github.com/odoo/odoo/blob/15.0/odoo/tools/config.py#L722)).
- Tweak the garbage collection settings if you have limited disk space
- Modify `Default odoorc for builds` to change the running build master password to something unique ([ideally a hashed one](https://github.com/odoo/odoo/blob/18.0/odoo/tools/config.py#L787)).
- Tweak the garbage collection settings, if you have limited disk space.
- The `number of running build` is the number of parallel running builds.
- `Max commit age (in days)` will limt the max age of commit to detect. Increase this limit to detect older branches.

Finally, start the two other services
Finally, start the two other services:

```bash
systemctl start leader
Expand Down Expand Up @@ -214,12 +214,12 @@ Access runbot app and go to the `Runbot>Setting>Repositories` menu
Create a new repo for odoo
![Odoo repo configuration](runbot/documentation/images/repo_odoo.png "Odoo repo configuration")

- **Name**: `odoo` It will be used as the directory name to export the sources
- **Identityfile** is only usefull if you want to use another ssh key to access a repo
- **Name**: `odoo` It will be used as the directory name to export the sources.
- **Identity File** is only useful if you want to use another ssh key to access a repo.
- **Project**: `R&D` by default.
- **Modules to install**: `-*` in order to remove them from the default `-i`. This will speed up installation. To install and test all modules, leave this space empty or use `*`. Some modules may be blacklisted individually, by using `*-module,-other_module, l10n_*`.
- **Server files**: `odoo-bin` will allow runbot to know the possible file to use to launch odoo. odoo-bin is the one to use for the last version, but you may want to add other server files for older versions (comma separated list). The same logic is used for manifest files.
- **Manifest files**: `__manifest__.py`. This field is only usefull to configure old versions of odoo.
- **Server files**: `odoo-bin` will allow runbot to know the possible file to use to launch odoo. `odoo-bin` is the one to use for the last version, but you may want to add other server files for older versions (comma separated list). The same logic is used for manifest files.
- **Manifest files**: `__manifest__.py`. This field is only useful to configure old versions of odoo.
- **Addons path**: `addons,odoo/addons`. The paths where addons are stored in this repository.
- **Mode**: `poll` since github won't hook your runbot instance. Poll mode is limited to one update every 5 minutes. *It is advised to set it in hook mode later and hook it manually of from a cron or automated action to have more control*.
- **Remotes**: `[email protected]:odoo/odoo.git` A single remote is added, the base odoo repo. Only branches will be fetched to limit disk usage and branches will be created in the backend. It is possible to add multiple remotes for forks.
Expand All @@ -232,11 +232,11 @@ Create a repo for your custom addons repo
![Odoo repo configuration](runbot/documentation/images/repo_runbot.png "Odoo repo configuration")
- **Name**: `runbot`
- **Project**: `runbot`.
- **Modules to install**: `-*,runbot` ton only install the runbot module.
- No addons_path given to use repo root as default.
- **Modules to install**: `-*,runbot` to only install the runbot module.
- **Addons path**: No `addons_path` given to use repo root as default.
- (optionnal) For your custom repo, it is advised to configure the repo in `hook` mode if possible, adding a webhook on `/runbot/hook`. Use `/runbot/hook/<repo_id>` to do it manually.
- **Remotes**: `[email protected]:odoo/runbot.git`
- The remote *PR* option can be checked if needed to fetch pull request too . Will only work if a github token is given for this repo.
- The remote *PR* option can be checked if needed to fetch pull request too. Will work only if a github token is given for this repo.

A config file with your remotes should be created for each repo. You can check the content in `/runbot/static/repo/(runbot|odoo)/config`. The repo will be fetched, this operation may take some time too. After that, you should start seeing empty batches in both projects on the frontend (`/` or `/runbot`)

Expand Down Expand Up @@ -272,7 +272,7 @@ Create a new trigger like this:
- *Project id*: `runbot` This is important since you can only chose repo triggering a new build in this project.
- *Triggers*: `runbot` A new build will be created int the project when pushing on this repo.
- *Dependencies*: `odoo` Runbot needs odoo to run
- *Config*: `Default no run` Will start a build but dont make it running at the end. You can still wake up a build.
- *Config*: `Default no run` Will start a build but don't make it running at the end. You can still wake up a build.

When a branch is pushed, a new batch will be created, and after one minute the new build will be created if no other change is detected.

Expand All @@ -282,22 +282,22 @@ You can either push, or go on the frontend bundle page and use the `Force new ba

#### Bundles

Bundles can be marked as `no_build`, so that new commit won't create batch creation and the bundle won't be displayed on the main page.
Bundles can be marked as `no_build`, so that new commit(s) won't create batch creation and the bundle won't be displayed on the main page.

#### Hosts
Runbot is able to share pending builds across multiple hosts. In the present case, there is only one. A new host will never assign a pending build to himself by default.
Go in the Build Hosts menu and choose yours. Uncheck *Only accept assigned build*. You can also tweak the number of parallel builds for this host.
Runbot is able to share pending builds across multiple hosts. In the present case, there is only one. A new host will never assign a pending build to itself by default.
Go to the "Build Hosts" menu and choose yours. Uncheck *Only accept assigned build*. You can also tweak the number of parallel builds for this host.

### Modules filters
Modules to install can be filtered by repo, and by config step. The first filter to be applied is the repo one, creating the default list for a config step.
Addon -module on a repo will remove the module from the default, it is advised to reflect the default case on repo. To test only a custom module, adding `-*` on odoo repo will disable all odoo addons. Only dependencies of custom modules will be installed. Some specific modules can also be filtered using `-module1,-module1` or somme specific modules can be kept using `-*,module1,module2`.
Module can also be filtered on a config step with the same logic as repo filter, except that repo's blacklist can be disabled to allow all modules by starting the list with `*` (all available modules)
Addon `-module` on a repo will remove the module from the default, it is advised to reflect the default case on repo. To test only a custom module, adding `-*` on odoo repo will disable all odoo addons. Only dependencies of custom modules will be installed. Some specific modules can also be filtered using `-module1,-module1` or somme specific modules can be kept using `-*,module1,module2`.
Modules can also be filtered on a config step with the same logic as repo filter, except that repo's blacklist can be disabled to allow all modules by starting the list with `*` (all available modules)
It is also possible to add test-tags to config step to allow more module to be installed but only testing some specific one. Test tags: `/module1,/module2`

### db template
Db creation will use template0 by default. It is possible to specify a specific template to use in runbot config *Postgresql template*. It is mainly used to add extensions. This will also avoid having issue if template0 is used when creating a new database.
Db creation will use `template0` by default. It is possible to specify a specific template to use in runbot config *Postgresql template*. It is mainly used to add extensions. This will also avoid having issue if `template0` is used when creating a new database.

It is recommended to generate a `template_runbot` database based on template0 and set this value in the runbot settings
It is recommended to generate a `template_runbot` database based on `template0` and set this value in the runbot settings

```
createdb template_runbot -T template0
Expand Down
3 changes: 2 additions & 1 deletion runbot/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
'author': "Odoo SA",
'website': "http://runbot.odoo.com",
'category': 'Website',
'version': '5.8',
'version': '5.9',
'application': True,
'depends': ['base', 'base_automation', 'website'],
'data': [
Expand Down Expand Up @@ -38,6 +38,7 @@
'templates/build_error.xml',

'views/branch_views.xml',
'views/build_error_link_views.xml',
'views/build_error_views.xml',
'views/build_views.xml',
'views/bundle_views.xml',
Expand Down
8 changes: 4 additions & 4 deletions runbot/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 +137,19 @@ def _docker_build(build_dir, image_tag):
return dm.result


def docker_push(image_tag):
return _docker_push(image_tag)
def docker_push(image_tag, push_url='127.0.0.1:5001'):
return _docker_push(image_tag, push_url)


def _docker_push(image_tag):
def _docker_push(image_tag, push_url):
"""Push a Docker image to the localy hosted docker registry
:param image_tag: the image tag (or id) to push
:return: tuple(success, msg) where success is a boolean and msg is the error message or None
"""

with DockerManager(image_tag) as dm:
image = dm.docker_client.images.get(image_tag)
push_tag = f'127.0.0.1:5001/{image_tag}'
push_tag = f'{push_url}/{image_tag}'
image.tag(push_tag)
for chunk in dm.consume(dm.docker_client.api.push(push_tag, stream=True)):
if not dm.log_progress and 'Pushing' in chunk.get('status', ''):
Expand Down
14 changes: 9 additions & 5 deletions runbot/controllers/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,13 @@ def bundle(self, bundle=None, page=1, limit=50, **kwargs):
'/runbot/bundle/<model("runbot.bundle"):bundle>/force',
'/runbot/bundle/<model("runbot.bundle"):bundle>/force/<int:auto_rebase>',
], type='http', auth="user", methods=['GET', 'POST'], csrf=False)
def force_bundle(self, bundle, auto_rebase=False, **_post):
def force_bundle(self, bundle, auto_rebase=False, use_base_commits=False,**_post):
if not request.env.user.has_group('runbot.group_runbot_advanced_user') and ':' not in bundle.name:
raise Forbidden("Only users with a specific group can do that. Please contact runbot administrators")
_logger.info('user %s forcing bundle %s', request.env.user.name, bundle.name) # user must be able to read bundle
batch = bundle.sudo()._force()
batch._log('Batch forced by %s', request.env.user.name)
batch._prepare(auto_rebase)
batch._prepare(auto_rebase=bool(auto_rebase), use_base_commits=bool(use_base_commits))
batch._process()
return werkzeug.utils.redirect('/runbot/batch/%s' % batch.id)

Expand Down Expand Up @@ -516,7 +516,7 @@ def team_dashboards(self, team=None, hide_empty=False, **kwargs):
qctx = {
'team': team,
'teams': teams,
'build_assignment_ids': request.env['runbot.build.error'].search(domain, order=order),
'assignment_ids': request.env['runbot.build.error'].search(domain, order=order),
'hide_empty': bool(hide_empty),
'searchbar_sortings': searchbar_sortings,
'sortby': sortby,
Expand Down Expand Up @@ -629,10 +629,14 @@ def list_config_categories(config):
return request.render("runbot.modules_stats", context)

@route(['/runbot/load_info'], type='http', auth="user", website=True, sitemap=False)
def load_infos(self, **post):
def load_infos(self, host: str | None = None, **post):
build_by_bundle = {}

for build in request.env['runbot.build'].search([('local_state', 'in', ('pending', 'testing'))], order='id'):
domain = [('local_state', 'in', ('pending', 'testing'))]
if host:
domain.append(('host', '=', host))

for build in request.env['runbot.build'].search(domain, order='id'):
build_by_bundle.setdefault(build.params_id.create_batch_id.bundle_id, []).append(build)

build_by_bundle = list(build_by_bundle.items())
Expand Down
13 changes: 11 additions & 2 deletions runbot/data/error_link.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<odoo>
<record model="ir.actions.server" id="action_link_build_errors">
<field name="name">Link build errors</field>
<field name="name">Merge build errors</field>
<field name="model_id" ref="runbot.model_runbot_build_error" />
<field name="binding_model_id" ref="runbot.model_runbot_build_error" />
<field name="type">ir.actions.server</field>
Expand Down Expand Up @@ -39,7 +39,7 @@
records.action_assign()
</field>
</record>
<record model="ir.actions.server" id="action_deduplicate">
<record model="ir.actions.server" id="action_deduplicate">
<field name="name">Deduplicate Error Contents</field>
<field name="model_id" ref="runbot.model_runbot_build_error_content" />
<field name="binding_model_id" ref="runbot.model_runbot_build_error_content" />
Expand All @@ -49,4 +49,13 @@
records.action_deduplicate()
</field>
</record>
<record model="ir.actions.server" id="action_view_build_errors">
<field name="name">View build errors</field>
<field name="model_id" ref="runbot.model_runbot_build"/>
<field name="type">ir.actions.server</field>
<field name="state">code</field>
<field name="code">
action = records.action_view_build_errors()
</field>
</record>
</odoo>
21 changes: 21 additions & 0 deletions runbot/migrations/18.0.5.9/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
def migrate(cr, version):
cr.execute("""
WITH helper AS
(
SELECT v.id,
(
SELECT v2.id
FROM runbot_version v2
WHERE Coalesce(v2.SEQUENCE, 9999) <= Coalesce(v.SEQUENCE, 9999)
AND v2.number < v.number
ORDER BY v2.SEQUENCE DESC,
v2.number DESC limit 1 ) AS v_excluded
FROM runbot_version v
ORDER BY v.SEQUENCE DESC,
v.NUMBER DESC )
UPDATE runbot_build_error
SET tags_min_version_excluded_id = h.v_excluded
FROM helper h
WHERE h.id = tags_min_version_id;
""")
cr.execute("""ALTER TABLE runbot_build_error DROP COLUMN tags_min_version_id;""")
1 change: 1 addition & 0 deletions runbot/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from . import upgrade
from . import user
from . import version
from . import website

# those imports have to be at the end otherwise the sql view cannot be initialised
from . import build_stat
Expand Down
Loading