mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-02-09 08:13:21 +08:00
Merge #464 Do not create new batch for included module if it is not requested by its buildorder.
This commit is contained in:
@@ -585,7 +585,8 @@ def format_mmd(mmd, scmurl):
|
||||
if err_msg:
|
||||
raise UnprocessableEntity(err_msg)
|
||||
|
||||
def record_component_builds(scm, mmd, module, initial_batch = 1):
|
||||
def record_component_builds(mmd, module, initial_batch = 1,
|
||||
previous_buildorder = None):
|
||||
import koji # Placed here to avoid py2/py3 conflicts...
|
||||
|
||||
# Format the modulemd by putting in defaults and replacing streams that
|
||||
@@ -610,7 +611,6 @@ def record_component_builds(scm, mmd, module, initial_batch = 1):
|
||||
|
||||
components = mmd.components.all
|
||||
components.sort(key=lambda x: x.buildorder)
|
||||
previous_buildorder = None
|
||||
|
||||
# We do not start with batch = 0 here, because the first batch is
|
||||
# reserved for module-build-macros. First real components must be
|
||||
@@ -618,6 +618,11 @@ def record_component_builds(scm, mmd, module, initial_batch = 1):
|
||||
batch = initial_batch
|
||||
|
||||
for pkg in components:
|
||||
# Increment the batch number when buildorder increases.
|
||||
if previous_buildorder != pkg.buildorder:
|
||||
previous_buildorder = pkg.buildorder
|
||||
batch += 1
|
||||
|
||||
# If the pkg is another module, we fetch its modulemd file
|
||||
# and record its components recursively with the initial_batch
|
||||
# set to our current batch, so the components of this module
|
||||
@@ -627,13 +632,10 @@ def record_component_builds(scm, mmd, module, initial_batch = 1):
|
||||
# It is OK to whitelist all URLs here, because the validity
|
||||
# of every URL have been already checked in format_mmd(...).
|
||||
mmd = _fetch_mmd(full_url, whitelist_url=True)[0]
|
||||
batch = record_component_builds(scm, mmd, module, batch)
|
||||
batch = record_component_builds(mmd, module, batch,
|
||||
previous_buildorder)
|
||||
continue
|
||||
|
||||
if previous_buildorder != pkg.buildorder:
|
||||
previous_buildorder = pkg.buildorder
|
||||
batch += 1
|
||||
|
||||
full_url = pkg.repository + "?#" + pkg.ref
|
||||
|
||||
existing_build = models.ComponentBuild.query.filter_by(
|
||||
@@ -708,7 +710,7 @@ def submit_module_build(username, url, mmd, scm, yaml, optional_params=None):
|
||||
**(optional_params or {})
|
||||
)
|
||||
|
||||
record_component_builds(scm, mmd, module)
|
||||
record_component_builds(mmd, module)
|
||||
|
||||
module.modulemd = mmd.dumps()
|
||||
module.transition(conf, models.BUILD_STATES["wait"])
|
||||
|
||||
@@ -24,6 +24,9 @@ data:
|
||||
rationale: It's here to test the whole thing!
|
||||
ref: 70fa7516b83768595a4f3280ae890a7ac957e0c7
|
||||
buildorder: 10
|
||||
ed:
|
||||
rationale: ed
|
||||
ref: 123
|
||||
modules:
|
||||
fakemodule:
|
||||
rationale: foobar
|
||||
|
||||
@@ -486,7 +486,7 @@ class TestViews(unittest.TestCase):
|
||||
data = json.loads(rv.data)
|
||||
|
||||
assert 'component_builds' in data, data
|
||||
self.assertEquals(data['component_builds'], [61, 62, 63, 64])
|
||||
self.assertEquals(data['component_builds'], [61, 62, 63, 64, 65])
|
||||
self.assertEquals(data['name'], 'includedmodules')
|
||||
self.assertEquals(data['scmurl'],
|
||||
('git://pkgs.stg.fedoraproject.org/modules/testmodule'
|
||||
@@ -505,6 +505,7 @@ class TestViews(unittest.TestCase):
|
||||
for build in ComponentBuild.query.filter_by(module_id=31).all():
|
||||
batches[build.package] = build.batch
|
||||
|
||||
self.assertEquals(batches['ed'], 2)
|
||||
self.assertEquals(batches['perl-List-Compare'], 2)
|
||||
self.assertEquals(batches['perl-Tangerine'], 2)
|
||||
self.assertEquals(batches['tangerine'], 3)
|
||||
|
||||
Reference in New Issue
Block a user