mirror of
https://src.fedoraproject.org/rpms/module-build-service.git
synced 2026-11-02 22:23:41 +08:00
Add patch to fix scratch build suffix bug
This commit is contained in:
153
mbs-PR1709-fix-scratch-build-suffix.patch
Normal file
153
mbs-PR1709-fix-scratch-build-suffix.patch
Normal file
@@ -0,0 +1,153 @@
|
||||
From 13d00928acf86f49fcced6cc034f663e8f2bbf64 Mon Sep 17 00:00:00 2001
|
||||
From: Martin Curlej <mcurlej@redhat.com>
|
||||
Date: Jun 04 2021 13:16:38 +0000
|
||||
Subject: Fixed scratch build suffix bug
|
||||
|
||||
|
||||
When building a scratch build of a module with static context
|
||||
the scratch suffix was added twice.
|
||||
|
||||
Signed-off-by: Martin Curlej <mcurlej@redhat.com>
|
||||
|
||||
---
|
||||
|
||||
diff --git a/module_build_service/web/submit.py b/module_build_service/web/submit.py
|
||||
index b4343e1..57fcb3d 100644
|
||||
--- a/module_build_service/web/submit.py
|
||||
+++ b/module_build_service/web/submit.py
|
||||
@@ -707,11 +707,13 @@ def submit_module_build(db_session, username, stream_or_packager, params, module
|
||||
module.build_context, module.runtime_context, module.context, \
|
||||
module.build_context_no_bms = module.contexts_from_mmd(module.modulemd)
|
||||
|
||||
- xmd = mmd.get_xmd()
|
||||
- if xmd["mbs"].get("static_context"):
|
||||
+ if static_context:
|
||||
+ # if the static_context is True we use the context from defined in the mmd
|
||||
+ # and discard the computed one.
|
||||
module.context = mmd.get_context()
|
||||
-
|
||||
- module.context += context_suffix
|
||||
+ else:
|
||||
+ # if the context is defined by MSE, we need to add a context_suffix if it exists.
|
||||
+ module.context += context_suffix
|
||||
|
||||
if not conf.allow_dashes_in_svc:
|
||||
if '-' in module.stream:
|
||||
@@ -786,10 +788,15 @@ def process_module_context_configuration(stream_or_packager):
|
||||
return streams, static_context
|
||||
else:
|
||||
xmd = stream_or_packager.get_xmd()
|
||||
- # check if we are handling rebuild of a static context module
|
||||
+
|
||||
+ # check if the static format is defined through `static_context` field
|
||||
+ if stream_or_packager.is_static_context():
|
||||
+ static_context = True
|
||||
+ return [stream_or_packager], static_context
|
||||
+
|
||||
+ # check if we are handling rebuild of a static context module defined in xmd
|
||||
if "mbs" in xmd:
|
||||
- # check if it is a static context
|
||||
- if "static_context" in xmd["mbs"] or stream_or_packager.is_static_context():
|
||||
+ if "static_context" in xmd["mbs"]:
|
||||
static_context = True
|
||||
return [stream_or_packager], static_context
|
||||
|
||||
diff --git a/tests/test_web/test_submit.py b/tests/test_web/test_submit.py
|
||||
index a2f548f..b5e3869 100644
|
||||
--- a/tests/test_web/test_submit.py
|
||||
+++ b/tests/test_web/test_submit.py
|
||||
@@ -25,10 +25,15 @@ from tests import (
|
||||
make_module,
|
||||
read_staged_data,
|
||||
init_data,
|
||||
+ clean_database,
|
||||
)
|
||||
|
||||
|
||||
class TestSubmit:
|
||||
+
|
||||
+ def teardown_method(self, tested_method):
|
||||
+ clean_database()
|
||||
+
|
||||
def test_get_prefixed_version_f28(self):
|
||||
scheduler_init_data(1)
|
||||
build_one = models.ModuleBuild.get_by_id(db_session, 2)
|
||||
@@ -144,6 +149,77 @@ class TestSubmit:
|
||||
assert "mbs_options" not in xmd
|
||||
assert xmd["mbs"]["static_context"]
|
||||
|
||||
+ def test_submit_build_module_scratch_v3_static_context(self):
|
||||
+ """
|
||||
+ Test if the static context in the v3 metadata format will contain the correct suffix
|
||||
+ during a scratch build
|
||||
+ """
|
||||
+ init_data(multiple_stream_versions=True)
|
||||
+ yaml_str = read_staged_data("v3/mmd_packager")
|
||||
+ mmd = load_mmd(yaml_str)
|
||||
+ ux_timestamp = "1613048427"
|
||||
+ version = provide_module_stream_version_from_timestamp(ux_timestamp)
|
||||
+ params = {"scratch": True}
|
||||
+
|
||||
+ builds = submit_module_build(db_session, "foo", mmd, params, version)
|
||||
+
|
||||
+ assert len(builds) == 2
|
||||
+
|
||||
+ expected_contexts = {"CTX1_1": {}, "CTX2_1": {}}
|
||||
+
|
||||
+ for build in builds:
|
||||
+ mmd = build.mmd()
|
||||
+ context = mmd.get_context()
|
||||
+ assert context in expected_contexts
|
||||
+
|
||||
+ def test_submit_build_module_scratch_v2_static_context(self):
|
||||
+ """
|
||||
+ Test if the static context in the v2 metadata format will contain
|
||||
+ the correct suffix during a scratch build
|
||||
+ """
|
||||
+ scheduler_init_data(1)
|
||||
+ yaml_str = read_staged_data("static_context_v2")
|
||||
+ mmd = load_mmd(yaml_str)
|
||||
+ ux_timestamp = "1613048427"
|
||||
+ version = provide_module_stream_version_from_timestamp(ux_timestamp)
|
||||
+ params = {"scratch": True}
|
||||
+
|
||||
+ builds = submit_module_build(db_session, "app", mmd, params, version)
|
||||
+
|
||||
+ assert len(builds) == 2
|
||||
+
|
||||
+ expected_contexts = {"context1_1": {}, "context2_1": {}}
|
||||
+
|
||||
+ for build in builds:
|
||||
+ mmd = build.mmd()
|
||||
+ context = mmd.get_context()
|
||||
+ assert context in expected_contexts
|
||||
+
|
||||
+ def test_submit_build_module_scratch_increment(self):
|
||||
+ """
|
||||
+ Test if the context suffix is incremented correctly during a repeated scratch build.
|
||||
+ """
|
||||
+ init_data(multiple_stream_versions=True)
|
||||
+ yaml_str = read_staged_data("v3/mmd_packager")
|
||||
+ mmd = load_mmd(yaml_str)
|
||||
+ ux_timestamp = "1613048427"
|
||||
+ version = provide_module_stream_version_from_timestamp(ux_timestamp)
|
||||
+ params = {"scratch": True}
|
||||
+
|
||||
+ builds = submit_module_build(db_session, "foo", mmd, params, version)
|
||||
+
|
||||
+ assert len(builds) == 2
|
||||
+
|
||||
+ builds = submit_module_build(db_session, "foo", mmd, params, version)
|
||||
+
|
||||
+ assert len(builds) == 2
|
||||
+
|
||||
+ expected_contexts = {"CTX1_2": {}, "CTX2_2": {}}
|
||||
+ for build in builds:
|
||||
+ mmd = build.mmd()
|
||||
+ context = mmd.get_context()
|
||||
+ assert context in expected_contexts
|
||||
+
|
||||
|
||||
class TestProcessModuleContextConfiguration:
|
||||
"""
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
Name: module-build-service
|
||||
Version: 3.6.1
|
||||
Release: 2%{?dist}
|
||||
Release: 3%{?dist}
|
||||
Summary: The Module Build Service for Modularity
|
||||
|
||||
License: MIT
|
||||
URL: https://pagure.io/fm-orchestrator
|
||||
Source0: https://files.pythonhosted.org/packages/source/m/%{name}/%{name}-%{version}.tar.gz
|
||||
Patch0: mbs-PR1729-dont-filter-runtime-deps.patch
|
||||
Patch1: mbs-PR1709-fix-scratch-build-suffix.patch
|
||||
|
||||
BuildArch: noarch
|
||||
ExclusiveArch: %{ix86} x86_64 noarch
|
||||
@@ -66,6 +67,7 @@ for a number of tasks:
|
||||
%prep
|
||||
%setup -q
|
||||
%patch0 -p1
|
||||
%patch1 -p1
|
||||
|
||||
# Workaround because python2-koji has no egg-info file at the momement
|
||||
sed -i '/koji/d' requirements.txt
|
||||
@@ -97,6 +99,9 @@ sed -i '/koji/d' requirements.txt
|
||||
|
||||
|
||||
%changelog
|
||||
* Wed Nov 17 2021 Brendan Reilly <breilly@redhat.com> - 3.6.1-3
|
||||
- Add patch to fix scratch build suffix bug
|
||||
|
||||
* Thu Sep 02 2021 Brendan Reilly <breilly@redhat.com> - 3.6.1-2
|
||||
- Add patch to stop filtering runtime deps for packagerv3
|
||||
|
||||
|
||||
Reference in New Issue
Block a user