Skip to content

Commit

Permalink
[IMP] replace buildout_default with a default buildout linked on repo
Browse files Browse the repository at this point in the history
  • Loading branch information
hbrunn committed May 14, 2020
1 parent c517b21 commit cf0607b
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 9 deletions.
2 changes: 1 addition & 1 deletion runbot_buildout/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ To configure this module, you need to:
#. turn on `Use buildouts` on a repository
#. fill in a regex that allows to differentiate a normal branch name: For runbot, branches should be named ``$version-$sometext`` anyways, so this module's suggestion is to call buildout branches ``buildout-$version-$sometext``
#. check the value of the field `Buildout section`, this must be the name you use in your buildouts
#. if you use multiple buildouts for the same version to implement some kind of DTAP scenario (you should), you can mark some buildout branch as the one to be used for tests by navigating to the branch and checking `Default for this version`
#. if you use multiple buildouts for the same version to implement some kind of DTAP scenario (you should), you can mark some buildout branch as the one to be used for tests by navigating to the repository and selecting a default buildout branch. In case you deal with multiple versions, set the default to a buildout from your current version, and set the buildout branch for branches of the new version manually
#. when converting a repository to use buildouts, be sure to remove all dependency branches first. Otherwise, runbot will copy all of them unnecessarily. Then, rebuild some buildout branch, and when it is green, rebuild another branch that is supposed to use the buildout

Background
Expand Down
2 changes: 1 addition & 1 deletion runbot_buildout/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Buildout for runbot",
"version": "11.0.1.0.0",
"version": "11.0.1.1.0",
"author": "Therp BV,Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "Runbot",
Expand Down
11 changes: 11 additions & 0 deletions runbot_buildout/migrations/11.0.1.1.0/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright 2020 Therp BV <https://therp.nl>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).


def migrate(cr, version=None):
cr.execute(
"""update runbot_repo set buildout_branch_id=runbot_branch.id
from runbot_branch where
runbot_branch.repo_id=runbot_repo.id and runbot_branch.buildout_default
"""
)
3 changes: 1 addition & 2 deletions runbot_buildout/models/runbot_branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
class RunbotBranch(models.Model):
_inherit = 'runbot.branch'

buildout_default = fields.Boolean('Default buildout')
buildout_version = fields.Char(
compute='_compute_buildout_version', store=True,
)
Expand All @@ -22,7 +21,7 @@ class RunbotBranch(models.Model):
)
buildout_branch_id = fields.Many2one(
'runbot.branch', help='Default buildout branch',
domain='[("repo_id", "=", repo_id)]',
domain="[('repo_id', '=', repo_id), ('buildout_version', '!=', False)]"
)

@api.multi
Expand Down
7 changes: 3 additions & 4 deletions runbot_buildout/models/runbot_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@ def _get_buildout_environment(self, log_build=False):
@api.multi
def _get_buildout_build(self):
self.ensure_one()
buildout_branch = self.branch_id.buildout_branch_id
buildout_branch = self.branch_id.buildout_branch_id or\
self.branch_id.repo_id.buildout_branch_id
version = None
if not buildout_branch:
pi = self.branch_id._get_pull_info()
Expand All @@ -296,9 +297,7 @@ def _get_buildout_build(self):
buildout_branch = self.env['runbot.branch'].search([
('repo_id', '=', self.repo_id.id),
('buildout_version', '=', version),
], order='buildout_default desc, name asc')
if buildout_branch.filtered('buildout_default'):
buildout_branch = buildout_branch.filtered('buildout_default')
], order='name asc', limit=1)
buildout_build = self.search([
('repo_id', '=', self.repo_id.id),
('state', '=', 'done'),
Expand Down
8 changes: 8 additions & 0 deletions runbot_buildout/models/runbot_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,11 @@ class RunbotRepo(models.Model):
default='odoo',
help='The buildout section you use to create your odoo instance'
)
buildout_branch_id = fields.Many2one(
'runbot.branch', 'Default buildout branch',
domain="[('repo_id', '=', id), ('buildout_version', '!=', False)]",
help='Set this to use the latest green build of this branch for '
'buildouts. Note you can set a specific buildout branch on branch '
'level too, so you should configure your testing buildout branch here,'
' and configure the production buildout for your production branch.',
)
1 change: 0 additions & 1 deletion runbot_buildout/views/runbot_branch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<field name="inherit_id" ref="runbot.branch_form" />
<field name="arch" type="xml">
<field name="sticky" position="after">
<field name="buildout_default" attrs="{'invisible': [('buildout_version', '=', False)]}" />
<field name="buildout_branch_id" attrs="{'invisible': [('buildout_version', '=', True)]}" />
<field name="buildout_section" />
</field>
Expand Down
1 change: 1 addition & 0 deletions runbot_buildout/views/runbot_repo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<field name="uses_buildout" />
<field name="buildout_branch_pattern" attrs="{'invisible': [('uses_buildout', '=', False)]}" />
<field name="buildout_section" attrs="{'invisible': [('uses_buildout', '=', False)]}" />
<field name="buildout_branch_id" attrs="{'invisible': [('uses_buildout', '=', False)]}" />
</field>
<field name="dependency_ids" position="attributes">
<attribute name="attrs">{'invisible': [('uses_buildout', '=', True)]}</attribute>
Expand Down

0 comments on commit cf0607b

Please sign in to comment.