[IMP] runbot: deterministic order

This commit is contained in:
Xavier-Do 2024-05-02 10:43:08 +02:00
parent 2a18cd7f3d
commit 1644253c94
4 changed files with 22 additions and 3 deletions

View File

@ -6,7 +6,7 @@
'author': "Odoo SA",
'website': "http://runbot.odoo.com",
'category': 'Website',
'version': '5.6',
'version': '5.7',
'application': True,
'depends': ['base', 'base_automation', 'website'],
'data': [

View File

@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
import logging
def migrate(cr, version):
cr.execute('ALTER TABLE runbot_commit_link ADD COLUMN repo_id INT')
cr.execute('ALTER TABLE runbot_commit_link ADD COLUMN sequence INT')
cr.execute('''
UPDATE runbot_commit_link
SET repo_id=commit.repo_id, sequence = repo.sequence
FROM runbot_commit commit
JOIN runbot_repo repo ON commit.repo_id=repo.id
WHERE commit.id = runbot_commit_link.commit_id
''')

View File

@ -195,12 +195,16 @@ class Commit(models.Model):
class CommitLink(models.Model):
_name = 'runbot.commit.link'
_description = "Build commit"
_order = 'sequence,repo_id,id'
commit_id = fields.Many2one('runbot.commit', 'Commit', required=True, index=True)
# Link info
match_type = fields.Selection([('new', 'New head of branch'), ('head', 'Head of branch'), ('base_head', 'Found on base branch'), ('base_match', 'Found on base branch')]) # HEAD, DEFAULT
branch_id = fields.Many2one('runbot.branch', string='Found in branch') # Shouldn't be use for anything else than display
repo_id = fields.Many2one('runbot.repo', related='commit_id.repo_id', store=True)
sequence = fields.Integer('runbot.repo', related='commit_id.repo_id.sequence', store=True)
base_commit_id = fields.Many2one('runbot.commit', 'Base head commit', index=True)
merge_base_commit_id = fields.Many2one('runbot.commit', 'Merge Base commit', index=True)
base_behind = fields.Integer('# commits behind base')

View File

@ -461,8 +461,8 @@ class TestUpgradeFlow(RunbotCase):
self.assertTrue(ro_volumes.pop(f'/home/{user}/.odoorc').startswith(self.env['runbot.runbot']._path('build')))
self.assertEqual(
list(ro_volumes.keys()), [
'/data/build/addons',
'/data/build/server',
'/data/build/addons',
'/data/build/upgrade',
],
"other commit should have been added automaticaly"
@ -470,7 +470,7 @@ class TestUpgradeFlow(RunbotCase):
self.assertEqual(
str(cmd),
'python3 server/server.py {addons_path} --no-xmlrpcs --no-netrpc -u all -d {db_name} --stop-after-init --max-cron-threads=0'.format(
addons_path='--addons-path addons,server/addons,server/core/addons',
addons_path='--addons-path server/addons,server/core/addons,addons',
db_name=f'{current_build.dest}-{suffix}')
)
self.patchers['docker_run'].side_effect = docker_run_upgrade