1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-10-02 09:10:11 +02:00

applied review suggestions for deploying (build) logs

This commit is contained in:
Michael Pöhn 2018-06-19 15:18:13 +02:00
parent 763768989b
commit 752f6a4ba2
3 changed files with 20 additions and 20 deletions

View File

@ -163,12 +163,12 @@ The repository of older versions of applications from the main demo repository.
# 'bar.info:/var/www/fdroid', # 'bar.info:/var/www/fdroid',
# } # }
# Uncomment this option if you want to publish build logs to your repository # Uncomment this option if you want to logs of builds and other processes to
# server(s). Logs get published to all servers configured in 'serverwebroot'. # your repository server(s). Logs get published to all servers configured in
# This feature only supports publishing logs from build-jobs running # 'serverwebroot'. For builds, only logs from build-jobs running inside a
# inside a buildserver VM. # buildserver VM are supported.
# #
# publish_build_logs = True # deploy_process_logs = True
# The full URL to a git remote repository. You can include # The full URL to a git remote repository. You can include
# multiple servers to mirror to by wrapping the whole thing in {} or [], and # multiple servers to mirror to by wrapping the whole thing in {} or [], and

View File

@ -101,7 +101,7 @@ default_config = {
'per_app_repos': False, 'per_app_repos': False,
'make_current_version_link': True, 'make_current_version_link': True,
'current_version_name_source': 'Name', 'current_version_name_source': 'Name',
'publish_build_logs': False, 'deploy_process_logs': False,
'update_stats': False, 'update_stats': False,
'stats_ignore': [], 'stats_ignore': [],
'stats_server': None, 'stats_server': None,
@ -3072,8 +3072,8 @@ def local_rsync(options, fromdir, todir):
raise FDroidException() raise FDroidException()
def publish_build_log_with_rsync(appid, vercode, log_content, def deploy_build_log_with_rsync(appid, vercode, log_content,
timestamp=int(time.time())): timestamp=int(time.time())):
"""Upload build log of one individual app build to an fdroid repository. """Upload build log of one individual app build to an fdroid repository.
:param appid: package name for dientifying to which app this log belongs. :param appid: package name for dientifying to which app this log belongs.
@ -3084,18 +3084,18 @@ def publish_build_log_with_rsync(appid, vercode, log_content,
:param timestamp: timestamp for avoiding logfile name collisions. :param timestamp: timestamp for avoiding logfile name collisions.
""" """
# check if publishing logs is enabled in config # check if deploying logs is enabled in config
if not config.get('publish_build_logs', False): if not config.get('deploy_process_logs', False):
logging.debug('skip publishing full build logs: not enabled in config') logging.debug(_('skip deploying full build logs: not enabled in config'))
return return
if not log_content: if not log_content:
logging.warning('skip publishing full build logs: log content is empty') logging.warning(_('skip deploying full build logs: log content is empty'))
return return
if not (isinstance(timestamp, int) or isinstance(timestamp, float)): if not (isinstance(timestamp, int) or isinstance(timestamp, float)):
raise ValueError("supplied timestamp '{}' is not a unix timestamp" raise ValueError(_("supplied timestamp value '{timestamp}' is not a unix timestamp"
.format(timestamp)) .format(timestamp=timestamp)))
with tempfile.TemporaryDirectory() as tmpdir: with tempfile.TemporaryDirectory() as tmpdir:
# gzip compress log file # gzip compress log file
@ -3127,13 +3127,13 @@ def publish_build_log_with_rsync(appid, vercode, log_content,
cmd += ['-e', 'ssh -oBatchMode=yes -oIdentitiesOnly=yes -i ' + config['identity_file']] cmd += ['-e', 'ssh -oBatchMode=yes -oIdentitiesOnly=yes -i ' + config['identity_file']]
cmd += [log_gz_path, dest_path] cmd += [log_gz_path, dest_path]
# TODO: also publish signature file if present # TODO: also deploy signature file if present
retcode = subprocess.call(cmd) retcode = subprocess.call(cmd)
if retcode: if retcode:
logging.warning("failded publishing build logs to '{}'".format(webroot)) logging.warning(_("failed deploying build logs to '{path}'").format(path=webroot))
else: else:
logging.info("published build logs to '{}'".format(webroot)) logging.info(_("deployeded build logs to '{path}'").format(path=webroot))
def get_per_app_repos(): def get_per_app_repos():

View File

@ -791,7 +791,7 @@ class CommonTest(unittest.TestCase):
with self.assertRaises(SyntaxError): with self.assertRaises(SyntaxError):
fdroidserver.common.calculate_math_string('1-1 # no comment') fdroidserver.common.calculate_math_string('1-1 # no comment')
def test_publish_build_log_with_rsync_with_id_file(self): def test_deploy_build_log_with_rsync_with_id_file(self):
mocklogcontent = bytes(textwrap.dedent("""\ mocklogcontent = bytes(textwrap.dedent("""\
build started build started
@ -806,7 +806,7 @@ class CommonTest(unittest.TestCase):
fdroidserver.common.config['serverwebroot'] = [ fdroidserver.common.config['serverwebroot'] = [
'example.com:/var/www/fdroid/repo/', 'example.com:/var/www/fdroid/repo/',
'example.com:/var/www/fdroid/archive/'] 'example.com:/var/www/fdroid/archive/']
fdroidserver.common.config['publish_build_logs'] = True fdroidserver.common.config['deploy_process_logs'] = True
fdroidserver.common.config['identity_file'] = 'ssh/id_rsa' fdroidserver.common.config['identity_file'] = 'ssh/id_rsa'
assert_subprocess_call_iteration = 0 assert_subprocess_call_iteration = 0
@ -848,7 +848,7 @@ class CommonTest(unittest.TestCase):
with mock.patch('subprocess.call', with mock.patch('subprocess.call',
side_effect=assert_subprocess_call): side_effect=assert_subprocess_call):
fdroidserver.common.publish_build_log_with_rsync( fdroidserver.common.deploy_build_log_with_rsync(
'com.example.app', '4711', mocklogcontent, 1.1) 'com.example.app', '4711', mocklogcontent, 1.1)