1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-11-19 21:30:10 +01: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',
# }
# Uncomment this option if you want to publish build logs to your repository
# server(s). Logs get published to all servers configured in 'serverwebroot'.
# This feature only supports publishing logs from build-jobs running
# inside a buildserver VM.
# Uncomment this option if you want to logs of builds and other processes to
# your repository server(s). Logs get published to all servers configured in
# 'serverwebroot'. For builds, only logs from build-jobs running inside a
# buildserver VM are supported.
#
# publish_build_logs = True
# deploy_process_logs = True
# The full URL to a git remote repository. You can include
# 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,
'make_current_version_link': True,
'current_version_name_source': 'Name',
'publish_build_logs': False,
'deploy_process_logs': False,
'update_stats': False,
'stats_ignore': [],
'stats_server': None,
@ -3072,8 +3072,8 @@ def local_rsync(options, fromdir, todir):
raise FDroidException()
def publish_build_log_with_rsync(appid, vercode, log_content,
timestamp=int(time.time())):
def deploy_build_log_with_rsync(appid, vercode, log_content,
timestamp=int(time.time())):
"""Upload build log of one individual app build to an fdroid repository.
: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.
"""
# check if publishing logs is enabled in config
if not config.get('publish_build_logs', False):
logging.debug('skip publishing full build logs: not enabled in config')
# check if deploying logs is enabled in config
if not config.get('deploy_process_logs', False):
logging.debug(_('skip deploying full build logs: not enabled in config'))
return
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
if not (isinstance(timestamp, int) or isinstance(timestamp, float)):
raise ValueError("supplied timestamp '{}' is not a unix timestamp"
.format(timestamp))
raise ValueError(_("supplied timestamp value '{timestamp}' is not a unix timestamp"
.format(timestamp=timestamp)))
with tempfile.TemporaryDirectory() as tmpdir:
# 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 += [log_gz_path, dest_path]
# TODO: also publish signature file if present
# TODO: also deploy signature file if present
retcode = subprocess.call(cmd)
if retcode:
logging.warning("failded publishing build logs to '{}'".format(webroot))
logging.warning(_("failed deploying build logs to '{path}'").format(path=webroot))
else:
logging.info("published build logs to '{}'".format(webroot))
logging.info(_("deployeded build logs to '{path}'").format(path=webroot))
def get_per_app_repos():

View File

@ -791,7 +791,7 @@ class CommonTest(unittest.TestCase):
with self.assertRaises(SyntaxError):
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("""\
build started
@ -806,7 +806,7 @@ class CommonTest(unittest.TestCase):
fdroidserver.common.config['serverwebroot'] = [
'example.com:/var/www/fdroid/repo/',
'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'
assert_subprocess_call_iteration = 0
@ -848,7 +848,7 @@ class CommonTest(unittest.TestCase):
with mock.patch('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)