mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-05-11 10:34:30 +08:00
Fix #41 - Tag builds only in the end of the badge to not regen repository all the time.
This commit is contained in:
@@ -78,6 +78,8 @@ class TestModuleBuilder(GenericBuilder):
|
||||
|
||||
on_build_cb = None
|
||||
on_cancel_cb = None
|
||||
on_buildroot_add_artifacts_cb = None
|
||||
on_tag_artifacts_cb = None
|
||||
|
||||
def __init__(self, owner, module, config, tag_name):
|
||||
self.module_str = module
|
||||
@@ -90,6 +92,8 @@ class TestModuleBuilder(GenericBuilder):
|
||||
TestModuleBuilder.INSTANT_COMPLETE = False
|
||||
TestModuleBuilder.on_build_cb = None
|
||||
TestModuleBuilder.on_cancel_cb = None
|
||||
TestModuleBuilder.on_buildroot_add_artifacts_cb = None
|
||||
TestModuleBuilder.on_tag_artifacts_cb = None
|
||||
|
||||
def buildroot_connect(self, groups):
|
||||
pass
|
||||
@@ -107,11 +111,16 @@ class TestModuleBuilder(GenericBuilder):
|
||||
pass
|
||||
|
||||
def buildroot_add_artifacts(self, artifacts, install=False):
|
||||
pass
|
||||
if TestModuleBuilder.on_buildroot_add_artifacts_cb:
|
||||
TestModuleBuilder.on_buildroot_add_artifacts_cb(self, artifacts, install)
|
||||
|
||||
def buildroot_add_repos(self, dependencies):
|
||||
pass
|
||||
|
||||
def tag_artifacts(self, artifacts):
|
||||
if TestModuleBuilder.on_tag_artifacts_cb:
|
||||
TestModuleBuilder.on_tag_artifacts_cb(self, artifacts)
|
||||
|
||||
@property
|
||||
def module_build_tag(self):
|
||||
return {"name": self.tag_name + "-build"}
|
||||
@@ -130,7 +139,7 @@ class TestModuleBuilder(GenericBuilder):
|
||||
msg_id='a faked internal message',
|
||||
build_id=build_id,
|
||||
task_id=build_id,
|
||||
build_name="name",
|
||||
build_name=path.basename(source),
|
||||
build_new_state=state,
|
||||
build_release="1",
|
||||
build_version="1"
|
||||
@@ -211,7 +220,30 @@ class TestBuild(unittest.TestCase):
|
||||
data = json.loads(rv.data)
|
||||
module_build_id = data['id']
|
||||
|
||||
msgs = [RidaModule("fake msg", 1, 1)]
|
||||
# Check that components are tagged after the batch is built.
|
||||
tag_groups = []
|
||||
tag_groups.append([u'module-build-macros-0.1-1.module_testmodule_teststream_1.src.rpm-1-1'])
|
||||
tag_groups.append([u'perl-Tangerine?#f25-1-1', u'perl-List-Compare?#f25-1-1'])
|
||||
tag_groups.append([u'tangerine?#f25-1-1'])
|
||||
|
||||
def on_tag_artifacts_cb(cls, artifacts):
|
||||
self.assertEqual(tag_groups.pop(0), artifacts)
|
||||
|
||||
TestModuleBuilder.on_tag_artifacts_cb = on_tag_artifacts_cb
|
||||
|
||||
# Check that the components are added to buildroot after the batch
|
||||
# is built.
|
||||
buildroot_groups = []
|
||||
buildroot_groups.append([u'module-build-macros-0.1-1.module_testmodule_teststream_1.src.rpm-1-1'])
|
||||
buildroot_groups.append([u'perl-Tangerine?#f25-1-1', u'perl-List-Compare?#f25-1-1'])
|
||||
buildroot_groups.append([u'tangerine?#f25-1-1'])
|
||||
|
||||
def on_buildroot_add_artifacts_cb(cls, artifacts, install):
|
||||
self.assertEqual(buildroot_groups.pop(0), artifacts)
|
||||
|
||||
TestModuleBuilder.on_buildroot_add_artifacts_cb = on_buildroot_add_artifacts_cb
|
||||
|
||||
msgs = []
|
||||
stop = module_build_service.scheduler.make_simple_stop_condition(db.session)
|
||||
module_build_service.scheduler.main(msgs, stop)
|
||||
|
||||
@@ -221,6 +253,10 @@ class TestBuild(unittest.TestCase):
|
||||
self.assertEqual(build.state, koji.BUILD_STATES['COMPLETE'])
|
||||
self.assertTrue(build.module_build.state in [models.BUILD_STATES["done"], models.BUILD_STATES["ready"]] )
|
||||
|
||||
# All components has to be tagged, so tag_groups and buildroot_groups are empty...
|
||||
self.assertEqual(tag_groups, [])
|
||||
self.assertEqual(buildroot_groups, [])
|
||||
|
||||
@timed(30)
|
||||
@patch('module_build_service.auth.get_username', return_value='Homer J. Simpson')
|
||||
@patch('module_build_service.auth.assert_is_packager')
|
||||
@@ -257,7 +293,7 @@ class TestBuild(unittest.TestCase):
|
||||
TestModuleBuilder.on_build_cb = on_build_cb
|
||||
TestModuleBuilder.on_cancel_cb = on_cancel_cb
|
||||
|
||||
msgs = [RidaModule("fake msg", 1, 1)]
|
||||
msgs = []
|
||||
stop = module_build_service.scheduler.make_simple_stop_condition(db.session)
|
||||
module_build_service.scheduler.main(msgs, stop)
|
||||
|
||||
@@ -296,7 +332,7 @@ class TestBuild(unittest.TestCase):
|
||||
TestModuleBuilder.BUILD_STATE = "BUILDING"
|
||||
TestModuleBuilder.INSTANT_COMPLETE = True
|
||||
|
||||
msgs = [RidaModule("fake msg", 1, 1)]
|
||||
msgs = []
|
||||
stop = module_build_service.scheduler.make_simple_stop_condition(db.session)
|
||||
module_build_service.scheduler.main(msgs, stop)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user