mirror of
https://github.com/odoo/runbot.git
synced 2025-03-27 13:25:47 +07:00
[IMP] runbot: add websocket support
This commit is contained in:
parent
e91611b0f8
commit
70e8b15690
@ -42,6 +42,10 @@ def now():
|
|||||||
return time.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
|
return time.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
|
||||||
|
|
||||||
|
|
||||||
|
def findall(filename, pattern):
|
||||||
|
return set(re.findall(pattern, open(filename).read()))
|
||||||
|
|
||||||
|
|
||||||
def grep(filename, string):
|
def grep(filename, string):
|
||||||
if os.path.isfile(filename):
|
if os.path.isfile(filename):
|
||||||
return find(filename, string) != -1
|
return find(filename, string) != -1
|
||||||
|
@ -8,7 +8,7 @@ import subprocess
|
|||||||
import time
|
import time
|
||||||
import datetime
|
import datetime
|
||||||
import hashlib
|
import hashlib
|
||||||
from ..common import dt2time, fqdn, now, grep, local_pgadmin_cursor, s2human, dest_reg, os, list_local_dbs, pseudo_markdown, RunbotException
|
from ..common import dt2time, fqdn, now, grep, local_pgadmin_cursor, s2human, dest_reg, os, list_local_dbs, pseudo_markdown, RunbotException, findall
|
||||||
from ..container import docker_stop, docker_state, Command, docker_run
|
from ..container import docker_stop, docker_state, Command, docker_run
|
||||||
from ..fields import JsonDictField
|
from ..fields import JsonDictField
|
||||||
from odoo import models, fields, api
|
from odoo import models, fields, api
|
||||||
@ -1171,3 +1171,6 @@ class BuildResult(models.Model):
|
|||||||
commit = build_commit.commit_id
|
commit = build_commit.commit_id
|
||||||
if 'base_' not in build_commit.match_type and commit.repo_id in trigger.repo_ids:
|
if 'base_' not in build_commit.match_type and commit.repo_id in trigger.repo_ids:
|
||||||
commit._github_status(build, trigger.ci_context, state, target_url, desc)
|
commit._github_status(build, trigger.ci_context, state, target_url, desc)
|
||||||
|
|
||||||
|
def parse_config(self):
|
||||||
|
return set(findall(self._server("tools/config.py"), '--[\w-]+', ))
|
||||||
|
@ -343,13 +343,21 @@ class ConfigStep(models.Model):
|
|||||||
build._log('run', 'Start running build %s' % build.dest)
|
build._log('run', 'Start running build %s' % build.dest)
|
||||||
# run server
|
# run server
|
||||||
cmd = build._cmd(local_only=False)
|
cmd = build._cmd(local_only=False)
|
||||||
if os.path.exists(build._get_server_commit()._source_path('addons/im_livechat')):
|
|
||||||
|
available_options = build.parse_config()
|
||||||
|
|
||||||
|
if "--workers" in available_options:
|
||||||
cmd += ["--workers", "2"]
|
cmd += ["--workers", "2"]
|
||||||
|
|
||||||
|
if "--gevent-port" in available_options:
|
||||||
|
cmd += ["--gevent-port", "8070"]
|
||||||
|
|
||||||
|
elif "--longpolling-port" in available_options:
|
||||||
cmd += ["--longpolling-port", "8070"]
|
cmd += ["--longpolling-port", "8070"]
|
||||||
|
|
||||||
|
if "--max-cron-threads" in available_options:
|
||||||
cmd += ["--max-cron-threads", "1"]
|
cmd += ["--max-cron-threads", "1"]
|
||||||
else:
|
|
||||||
# not sure, to avoid old server to check other dbs
|
|
||||||
cmd += ["--max-cron-threads", "0"]
|
|
||||||
|
|
||||||
install_steps = [step.db_name for step in build.params_id.config_id.step_ids() if step.job_type == 'install_odoo']
|
install_steps = [step.db_name for step in build.params_id.config_id.step_ids() if step.job_type == 'install_odoo']
|
||||||
db_name = build.params_id.config_data.get('db_name') or 'all' in install_steps and 'all' or install_steps[0]
|
db_name = build.params_id.config_data.get('db_name') or 'all' in install_steps and 'all' or install_steps[0]
|
||||||
@ -357,15 +365,16 @@ class ConfigStep(models.Model):
|
|||||||
cmd += ['-d', '%s-%s' % (build.dest, db_name)]
|
cmd += ['-d', '%s-%s' % (build.dest, db_name)]
|
||||||
|
|
||||||
icp = self.env['ir.config_parameter'].sudo()
|
icp = self.env['ir.config_parameter'].sudo()
|
||||||
if grep(build._server("tools/config.py"), "proxy-mode"):
|
if "--proxy-mode" in available_options:
|
||||||
cmd += ["--proxy-mode"]
|
cmd += ["--proxy-mode"]
|
||||||
|
|
||||||
if grep(build._server("tools/config.py"), "db-filter"):
|
if "--db-filter" in available_options:
|
||||||
cmd += ['--db-filter', '%d.*$']
|
cmd += ['--db-filter', '%d.*$']
|
||||||
|
|
||||||
smtp_host = docker_get_gateway_ip()
|
if "--smtp" in available_options:
|
||||||
if smtp_host:
|
smtp_host = docker_get_gateway_ip()
|
||||||
cmd += ['--smtp', smtp_host]
|
if smtp_host:
|
||||||
|
cmd += ['--smtp', smtp_host]
|
||||||
|
|
||||||
extra_params = self.extra_params or ''
|
extra_params = self.extra_params or ''
|
||||||
if extra_params:
|
if extra_params:
|
||||||
@ -406,14 +415,16 @@ class ConfigStep(models.Model):
|
|||||||
if mods and '-i' not in extra_params:
|
if mods and '-i' not in extra_params:
|
||||||
cmd += ['-i', mods]
|
cmd += ['-i', mods]
|
||||||
config_path = build._server("tools/config.py")
|
config_path = build._server("tools/config.py")
|
||||||
|
|
||||||
|
available_options = build.parse_config()
|
||||||
if self.test_enable:
|
if self.test_enable:
|
||||||
if grep(config_path, "test-enable"):
|
if "--test-enable" in available_options:
|
||||||
cmd.extend(['--test-enable'])
|
cmd.extend(['--test-enable'])
|
||||||
else:
|
else:
|
||||||
build._log('test_all', 'Installing modules without testing', level='WARNING')
|
build._log('test_all', 'Installing modules without testing', level='WARNING')
|
||||||
test_tags_in_extra = '--test-tags' in extra_params
|
test_tags_in_extra = '--test-tags' in extra_params
|
||||||
if self.test_tags or test_tags_in_extra:
|
if self.test_tags or test_tags_in_extra:
|
||||||
if grep(config_path, "test-tags"):
|
if "--test-tags" in available_options:
|
||||||
if not test_tags_in_extra:
|
if not test_tags_in_extra:
|
||||||
test_tags = self.test_tags.replace(' ', '')
|
test_tags = self.test_tags.replace(' ', '')
|
||||||
if self.enable_auto_tags:
|
if self.enable_auto_tags:
|
||||||
@ -429,10 +440,10 @@ class ConfigStep(models.Model):
|
|||||||
test_tags = ','.join(auto_tags)
|
test_tags = ','.join(auto_tags)
|
||||||
cmd.extend(['--test-tags', test_tags])
|
cmd.extend(['--test-tags', test_tags])
|
||||||
|
|
||||||
if grep(config_path, "--screenshots"):
|
if "--screenshots" in available_options:
|
||||||
cmd.add_config_tuple('screenshots', '/data/build/tests')
|
cmd.add_config_tuple('screenshots', '/data/build/tests')
|
||||||
|
|
||||||
if grep(config_path, "--screencasts") and self.env['ir.config_parameter'].sudo().get_param('runbot.enable_screencast', False):
|
if "--screencasts" in available_options and self.env['ir.config_parameter'].sudo().get_param('runbot.enable_screencast', False):
|
||||||
cmd.add_config_tuple('screencasts', '/data/build/tests')
|
cmd.add_config_tuple('screencasts', '/data/build/tests')
|
||||||
|
|
||||||
cmd.append('--stop-after-init') # install job should always finish
|
cmd.append('--stop-after-init') # install job should always finish
|
||||||
|
@ -55,6 +55,14 @@ server {
|
|||||||
server_name ~^<t t-out="re_escape(build.dest)"/>(-[a-z0-9_]+)?\.<t t-esc="re_escape(build.host)"/>$;
|
server_name ~^<t t-out="re_escape(build.dest)"/>(-[a-z0-9_]+)?\.<t t-esc="re_escape(build.host)"/>$;
|
||||||
location / { proxy_pass http://127.0.0.1:<t t-esc="build.port"/>; }
|
location / { proxy_pass http://127.0.0.1:<t t-esc="build.port"/>; }
|
||||||
location /longpolling { proxy_pass http://127.0.0.1:<t t-esc="build.port + 1"/>; }
|
location /longpolling { proxy_pass http://127.0.0.1:<t t-esc="build.port + 1"/>; }
|
||||||
|
location /websocket {
|
||||||
|
proxy_pass http://127.0.0.1:<t t-esc="build.port + 1"/>;
|
||||||
|
proxy_set_header X-Forwarded-Host $host;
|
||||||
|
proxy_set_header X-Forwarded-Proto $real_scheme;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "Upgrade";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</t>
|
</t>
|
||||||
server {
|
server {
|
||||||
|
@ -22,6 +22,7 @@ class TestBuildConfigStep(RunbotCase):
|
|||||||
'params_id': self.base_params.copy({'commit_link_ids': [(0, 0, {'commit_id': server_commit.id})]}).id,
|
'params_id': self.base_params.copy({'commit_link_ids': [(0, 0, {'commit_id': server_commit.id})]}).id,
|
||||||
})
|
})
|
||||||
self.start_patcher('find_patcher', 'odoo.addons.runbot.common.find', 0)
|
self.start_patcher('find_patcher', 'odoo.addons.runbot.common.find', 0)
|
||||||
|
self.start_patcher('findall_patcher', 'odoo.addons.runbot.models.build.BuildResult.parse_config', {})
|
||||||
|
|
||||||
def test_config_step_create_results(self):
|
def test_config_step_create_results(self):
|
||||||
""" Test child builds are taken into account"""
|
""" Test child builds are taken into account"""
|
||||||
|
Loading…
Reference in New Issue
Block a user