mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-16 16:02:33 +03:00
Merge branch 'rsync-buildslogs-to-webroot-repo' into 'master'
build: rsync buildlogs to <webroot>/repo See merge request fdroid/fdroidserver!651
This commit is contained in:
commit
26af94974a
3 changed files with 13 additions and 20 deletions
|
@ -173,8 +173,8 @@ The repository of older versions of applications from the main demo repository.
|
||||||
|
|
||||||
# Uncomment this option if you want to logs of builds and other processes to
|
# 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
|
# your repository server(s). Logs get published to all servers configured in
|
||||||
# 'serverwebroot'. For builds, only logs from build-jobs running inside a
|
# 'serverwebroot'. The name scheme is: .../repo/$APPID_$VERCODE.log.gz
|
||||||
# buildserver VM are supported.
|
# Only logs from build-jobs running inside a buildserver VM are supported.
|
||||||
#
|
#
|
||||||
# deploy_process_logs = True
|
# deploy_process_logs = True
|
||||||
|
|
||||||
|
|
|
@ -3232,8 +3232,7 @@ def local_rsync(options, fromdir, todir):
|
||||||
raise FDroidException()
|
raise FDroidException()
|
||||||
|
|
||||||
|
|
||||||
def deploy_build_log_with_rsync(appid, vercode, log_content,
|
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.
|
"""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.
|
||||||
|
@ -3241,7 +3240,6 @@ def deploy_build_log_with_rsync(appid, vercode, log_content,
|
||||||
:param log_content: Content of the log which is about to be posted.
|
:param log_content: Content of the log which is about to be posted.
|
||||||
Should be either a string or bytes. (bytes will
|
Should be either a string or bytes. (bytes will
|
||||||
be decoded as 'utf-8')
|
be decoded as 'utf-8')
|
||||||
:param timestamp: timestamp for avoiding logfile name collisions.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# check if deploying logs is enabled in config
|
# check if deploying logs is enabled in config
|
||||||
|
@ -3253,16 +3251,11 @@ def deploy_build_log_with_rsync(appid, vercode, log_content,
|
||||||
logging.warning(_('skip deploying 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)):
|
|
||||||
raise ValueError(_("supplied timestamp value '{timestamp}' is not a unix timestamp"
|
|
||||||
.format(timestamp=timestamp)))
|
|
||||||
|
|
||||||
with tempfile.TemporaryDirectory() as tmpdir:
|
with tempfile.TemporaryDirectory() as tmpdir:
|
||||||
# gzip compress log file
|
# gzip compress log file
|
||||||
log_gz_path = os.path.join(
|
log_gz_path = os.path.join(
|
||||||
tmpdir, '{pkg}_{ver}_{ts}.log.gz'.format(pkg=appid,
|
tmpdir, '{pkg}_{ver}.log.gz'.format(pkg=appid,
|
||||||
ver=vercode,
|
ver=vercode))
|
||||||
ts=int(timestamp)))
|
|
||||||
with gzip.open(log_gz_path, 'wb') as f:
|
with gzip.open(log_gz_path, 'wb') as f:
|
||||||
if isinstance(log_content, str):
|
if isinstance(log_content, str):
|
||||||
f.write(bytes(log_content, 'utf-8'))
|
f.write(bytes(log_content, 'utf-8'))
|
||||||
|
@ -3272,7 +3265,7 @@ def deploy_build_log_with_rsync(appid, vercode, log_content,
|
||||||
# TODO: sign compressed log file, if a signing key is configured
|
# TODO: sign compressed log file, if a signing key is configured
|
||||||
|
|
||||||
for webroot in config.get('serverwebroot', []):
|
for webroot in config.get('serverwebroot', []):
|
||||||
dest_path = os.path.join(webroot, "buildlogs")
|
dest_path = os.path.join(webroot, "repo")
|
||||||
if not dest_path.endswith('/'):
|
if not dest_path.endswith('/'):
|
||||||
dest_path += '/' # make sure rsync knows this is a directory
|
dest_path += '/' # make sure rsync knows this is a directory
|
||||||
cmd = ['rsync',
|
cmd = ['rsync',
|
||||||
|
|
|
@ -951,8 +951,8 @@ class CommonTest(unittest.TestCase):
|
||||||
fdroidserver.common.options.quiet = False
|
fdroidserver.common.options.quiet = False
|
||||||
fdroidserver.common.config = {}
|
fdroidserver.common.config = {}
|
||||||
fdroidserver.common.config['serverwebroot'] = [
|
fdroidserver.common.config['serverwebroot'] = [
|
||||||
'example.com:/var/www/fdroid/repo/',
|
'example.com:/var/www/fdroid/',
|
||||||
'example.com:/var/www/fdroid/archive/']
|
'example.com:/var/www/fbot/']
|
||||||
fdroidserver.common.config['deploy_process_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'
|
||||||
|
|
||||||
|
@ -969,9 +969,9 @@ class CommonTest(unittest.TestCase):
|
||||||
'-e',
|
'-e',
|
||||||
'ssh -oBatchMode=yes -oIdentitiesOnly=yes -i ssh/id_rsa',
|
'ssh -oBatchMode=yes -oIdentitiesOnly=yes -i ssh/id_rsa',
|
||||||
cmd[6],
|
cmd[6],
|
||||||
'example.com:/var/www/fdroid/repo/buildlogs/'],
|
'example.com:/var/www/fdroid/repo/'],
|
||||||
cmd)
|
cmd)
|
||||||
self.assertTrue(cmd[6].endswith('/com.example.app_4711_1.log.gz'))
|
self.assertTrue(cmd[6].endswith('/com.example.app_4711.log.gz'))
|
||||||
with gzip.open(cmd[6], 'r') as f:
|
with gzip.open(cmd[6], 'r') as f:
|
||||||
self.assertTrue(f.read(), mocklogcontent)
|
self.assertTrue(f.read(), mocklogcontent)
|
||||||
elif assert_subprocess_call_iteration == 1:
|
elif assert_subprocess_call_iteration == 1:
|
||||||
|
@ -982,9 +982,9 @@ class CommonTest(unittest.TestCase):
|
||||||
'-e',
|
'-e',
|
||||||
'ssh -oBatchMode=yes -oIdentitiesOnly=yes -i ssh/id_rsa',
|
'ssh -oBatchMode=yes -oIdentitiesOnly=yes -i ssh/id_rsa',
|
||||||
cmd[6],
|
cmd[6],
|
||||||
'example.com:/var/www/fdroid/archive/buildlogs/'],
|
'example.com:/var/www/fbot/repo/'],
|
||||||
cmd)
|
cmd)
|
||||||
self.assertTrue(cmd[6].endswith('/com.example.app_4711_1.log.gz'))
|
self.assertTrue(cmd[6].endswith('/com.example.app_4711.log.gz'))
|
||||||
with gzip.open(cmd[6], 'r') as f:
|
with gzip.open(cmd[6], 'r') as f:
|
||||||
self.assertTrue(f.read(), mocklogcontent)
|
self.assertTrue(f.read(), mocklogcontent)
|
||||||
else:
|
else:
|
||||||
|
@ -996,7 +996,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.deploy_build_log_with_rsync(
|
fdroidserver.common.deploy_build_log_with_rsync(
|
||||||
'com.example.app', '4711', mocklogcontent, 1.1)
|
'com.example.app', '4711', mocklogcontent)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue