5
0
mirror of https://github.com/odoo/runbot.git synced 2025-03-17 08:25:46 +07:00
runbot/runbot_cla/runbot.py
Xavier Morel 8c73e6a901 [IMP] runbot: add a job_type on branch and build
Since the runbot_merge module, some branches does not need to be built.
For example the tmp.* branches.
Some other branches does need to be tested but it could be useless to
keep them running. For example the staging branches.
Finally, some builds are generated by server actions during the night.
Those builds does not need to be kept running despite the branch configuration.

For example, the master branch can be configured to create builds with
testing and running but nightly multiple builds can be generated with
testing only.

For that purpose, this commit adds a job_type selection field on the
branch. That way, a branch can be configured by selecting the type of
jobs wanted.
A same kind of job_type was also added on the build that uses the
branch's value if nothing is specified at build creation.

A decorator is used on the job_ methods to specify their job types.
For example, a job method decorated by 'testing' will run if the
branch/build job_type is 'testing' or 'all'.
2019-01-22 14:18:58 +01:00

46 lines
1.6 KiB
Python

# -*- encoding: utf-8 -*-
import glob
import io
import logging
import re
from odoo.addons.runbot.models.build import runbot_job
from odoo import models
_logger = logging.getLogger(__name__)
class runbot_build(models.Model):
_inherit = "runbot.build"
@runbot_job('testing')
def _job_05_check_cla(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