aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorgy Redkozubov <georgy.redkozubov@linaro.org>2013-04-23 16:30:41 +0400
committerGeorgy Redkozubov <georgy.redkozubov@linaro.org>2013-04-23 16:30:41 +0400
commit6af9211a06b09b07221d586c6a09a7cd02a2311e (patch)
tree4e198b22ee3f00aefd8ef65dd20ab16b974f59a0
parente9e3068ef3a392ba5d59ce85e0eadcae33f951c9 (diff)
Fix for bug 1146220 to reinstate BUILD-INFO.txt support.
Script checks if BUILD-INFO.txt is present among artifacts being published or among artifacts already published for the same build. Otherwise error is thrown and no artifacts are published.
-rwxr-xr-xscripts/publish_to_snapshots.py21
-rw-r--r--tests/test_publish_to_snapshots.py56
2 files changed, 77 insertions, 0 deletions
diff --git a/scripts/publish_to_snapshots.py b/scripts/publish_to_snapshots.py
index 5276751..c1d5662 100755
--- a/scripts/publish_to_snapshots.py
+++ b/scripts/publish_to_snapshots.py
@@ -15,6 +15,7 @@ staging_target_path = '/srv/staging.snapshots.linaro.org/www/'
product_dir_path = 'target/product'
PASS = 0
FAIL = 1
+buildinfo = 'BUILD-INFO.txt'
acceptable_job_types = [
'android',
'prebuilt',
@@ -367,6 +368,22 @@ class SnapshotsPublisher(object):
print "Failed to move files destination path", target_dir_path
return FAIL
+ def check_buildinfo(self, build_dir_path, target_dir_path):
+ bi_dirs = []
+ for path, subdirs, files in os.walk(build_dir_path):
+ for filename in files:
+ if buildinfo in filename:
+ bi_dirs.append(path)
+ for path, subdirs, files in os.walk(target_dir_path):
+ for filename in files:
+ if buildinfo in filename:
+ bi_dirs.append(path)
+
+ if not bi_dirs:
+ return FAIL
+
+ return PASS
+
def main():
global uploads_path
@@ -387,6 +404,10 @@ def main():
if build_dir_path is None or target_dir_path is None:
print "Problem with build/target path, move failed"
return FAIL
+ ret = publisher.check_buildinfo(build_dir_path, target_dir_path)
+ if ret != PASS:
+ print "BUILD-INFO.txt is not present for build being published"
+ return FAIL
ret = publisher.move_artifacts(args, build_dir_path, target_dir_path)
if ret != PASS:
print "Move Failed"
diff --git a/tests/test_publish_to_snapshots.py b/tests/test_publish_to_snapshots.py
index 1cecff0..0f48800 100644
--- a/tests/test_publish_to_snapshots.py
+++ b/tests/test_publish_to_snapshots.py
@@ -11,6 +11,9 @@ from scripts.publish_to_snapshots import (
SnapshotsPublisher,
setup_parser,
product_dir_path,
+ FAIL,
+ PASS,
+ buildinfo
)
@@ -726,3 +729,56 @@ class TestSnapshotsPublisher(TestCase):
self.assertEqual(content, open(resulting_file).read())
self.assertEqual(howto_content, open(resulting_howto_file).read())
shutil.rmtree(source_dir)
+
+ def test_check_buildinfo_upload_dir(self):
+ self.publisher = SnapshotsPublisher()
+ param = self.parser.parse_args(
+ ['-t', 'prebuilt', '-j', 'precise-armhf-ubuntu-desktop',
+ '-n', '1'])
+ self.publisher.validate_args(param)
+ build_dir = '/'.join([param.job_name, str(param.build_num)])
+ build_path = os.path.join(self.uploads_path, build_dir)
+ os.makedirs(build_path)
+ www_path = os.path.join(self.target_path, build_dir)
+ os.makedirs(www_path)
+
+ file_name = os.path.join(build_path, buildinfo)
+ file = open(file_name, "w")
+ file.close()
+
+ self.assertEqual(PASS,
+ self.publisher.check_buildinfo(build_path, www_path))
+
+ def test_check_buildinfo_target_dir(self):
+ self.publisher = SnapshotsPublisher()
+ param = self.parser.parse_args(
+ ['-t', 'prebuilt', '-j', 'precise-armhf-ubuntu-desktop',
+ '-n', '1'])
+ self.publisher.validate_args(param)
+ build_dir = '/'.join([param.job_name, str(param.build_num)])
+ build_path = os.path.join(self.uploads_path, build_dir)
+ os.makedirs(build_path)
+ www_path = os.path.join(self.target_path, build_dir)
+ os.makedirs(www_path)
+
+ file_name = os.path.join(www_path, buildinfo)
+ file = open(file_name, "w")
+ file.close()
+
+ self.assertEqual(PASS,
+ self.publisher.check_buildinfo(build_path, www_path))
+
+ def test_check_buildinfo_no_file(self):
+ self.publisher = SnapshotsPublisher()
+ param = self.parser.parse_args(
+ ['-t', 'prebuilt', '-j', 'precise-armhf-ubuntu-desktop',
+ '-n', '1'])
+ self.publisher.validate_args(param)
+ build_dir = '/'.join([param.job_name, str(param.build_num)])
+ build_path = os.path.join(self.uploads_path, build_dir)
+ os.makedirs(build_path)
+ www_path = os.path.join(self.target_path, build_dir)
+ os.makedirs(www_path)
+
+ self.assertEqual(FAIL,
+ self.publisher.check_buildinfo(build_path, www_path))