mirror of
https://github.com/odoo/runbot.git
synced 2025-03-25 20:35:52 +07:00

This commit aims to replace static jobs by fully configurable build config. Each build has a config (custom or inherited from repo or branch). Each config has a list of steps. For now, a step can test/run odoo or create a new child build. A python job is also available. The mimic the previous behaviour of runbot, a default config is available with three steps, an install of base, an install+test of all modules, and a last step for run. Multibuilds are replace by a config containing cretaion steps. The created builds are not displayed in main views, but are available on parent build log page. The result of a parent takes the result of all children into account. This new mechanics will help to create some custom behaviours for specifics use cases, and latter help to parallelise work.
51 lines
1.8 KiB
Python
51 lines
1.8 KiB
Python
# -*- encoding: utf-8 -*-
|
|
|
|
import glob
|
|
import io
|
|
import logging
|
|
import re
|
|
|
|
from odoo import models, fields
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
|
class Job(models.Model):
|
|
_inherit = "runbot.build.config.step"
|
|
|
|
job_type = fields.Selection(selection_add=[('cla_check', 'Check cla')])
|
|
|
|
def _run_step(self, build, log_path):
|
|
if self.job_type != 'cla_check':
|
|
return self._runbot_cla_check(build, log_path)
|
|
return super(Job, self)._run_step(build, log_path)
|
|
|
|
def _runbot_cla_check(self, build, log_path):
|
|
cla_glob = glob.glob(build._path("doc/cla/*/*.md"))
|
|
if cla_glob:
|
|
description = "%s Odoo CLA signature check" % build.author
|
|
mo = re.search('[^ <@]+@[^ @>]+', build.author_email or '')
|
|
state = "failure"
|
|
if mo:
|
|
email = mo.group(0).lower()
|
|
if re.match('.*@(odoo|openerp|tinyerp)\.com$', email):
|
|
state = "success"
|
|
else:
|
|
try:
|
|
cla = ''.join(io.open(f, encoding='utf-8').read() for f in cla_glob)
|
|
if cla.lower().find(email) != -1:
|
|
state = "success"
|
|
except UnicodeDecodeError:
|
|
description = 'Invalid CLA encoding (must be utf-8)'
|
|
_logger.info('CLA build:%s email:%s result:%s', build.dest, email, state)
|
|
status = {
|
|
"state": state,
|
|
"target_url": "https://www.odoo.com/sign-cla",
|
|
"description": description,
|
|
"context": "legal/cla"
|
|
}
|
|
build._log('check_cla', 'CLA %s' % state)
|
|
build._github_status_notify_all(status)
|
|
# 0 is myself, -1 is everybody else, -2 nothing
|
|
return -2
|