mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-05 03:38:12 +08:00
Merge #644 Add 'mbs-build local [[--add-local-build n:s:v], ...]' to use local builds as dependency.
This commit is contained in:
@@ -282,7 +282,7 @@ def submit_module_build(scm_url, branch, server, id_provider, pyrpkg, verify=Tru
|
||||
return -3, None
|
||||
|
||||
|
||||
def do_local_build(scm_url, branch, skiptests, log_flag=None):
|
||||
def do_local_build(scm_url, branch, skiptests, local_builds_nsvs, log_flag=None):
|
||||
"""
|
||||
Starts the local build using the 'mbs-manager build_module_locally'
|
||||
command. Returns exit code of that command or None when scm_url or
|
||||
@@ -301,6 +301,11 @@ def do_local_build(scm_url, branch, skiptests, log_flag=None):
|
||||
if skiptests:
|
||||
command.append('--skiptests')
|
||||
logging.info("Tests will be skipped due to --skiptests option.")
|
||||
|
||||
if local_builds_nsvs:
|
||||
for build_id in local_builds_nsvs:
|
||||
command += ['--add-local-build', build_id]
|
||||
|
||||
command.extend([scm_url, branch])
|
||||
|
||||
process = subprocess.Popen(command)
|
||||
@@ -451,6 +456,8 @@ def main():
|
||||
"repository with a module.")
|
||||
parser_local.add_argument("scm_url", nargs='?')
|
||||
parser_local.add_argument("branch", nargs='?')
|
||||
parser_local.add_argument("--add-local-build", "-l", action='append',
|
||||
dest="local_builds_nsvs", metavar='BUILD_ID')
|
||||
parser_local.add_argument('--skiptests', dest='skiptests', action='store_true',
|
||||
help="add macro for skipping check section/phase")
|
||||
|
||||
@@ -496,7 +503,7 @@ def main():
|
||||
print("Submitted module build %r" % build_id)
|
||||
elif args.cmd_name == "local":
|
||||
sys.exit(do_local_build(args.scm_url, args.branch, args.skiptests,
|
||||
log_flag))
|
||||
args.local_builds_nsvs, log_flag))
|
||||
elif args.cmd_name == "watch":
|
||||
# Watch the module build.
|
||||
try:
|
||||
|
||||
@@ -293,11 +293,20 @@ mdpolicy=group:primary
|
||||
# extended to Copr in the future.
|
||||
self._load_mock_config()
|
||||
for tag in dependencies:
|
||||
repo_dir = os.path.join(self.config.cache_dir, "koji_tags", tag)
|
||||
create_local_repo_from_koji_tag(self.config, tag, repo_dir,
|
||||
[self.arch, "noarch"])
|
||||
# If tag starts with mock_resultdir, it means it is path to local
|
||||
# module build repository.
|
||||
if tag.startswith(conf.mock_resultsdir):
|
||||
repo_name = os.path.basename(tag)
|
||||
if repo_name.startswith("module-"):
|
||||
repo_name = name[7:]
|
||||
repo_dir = tag
|
||||
else:
|
||||
repo_name = tag
|
||||
repo_dir = os.path.join(self.config.cache_dir, "koji_tags", tag)
|
||||
create_local_repo_from_koji_tag(self.config, tag, repo_dir,
|
||||
[self.arch, "noarch"])
|
||||
baseurl = "file://" + repo_dir
|
||||
self._add_repo(tag, baseurl)
|
||||
self._add_repo(repo_name, baseurl)
|
||||
self._write_mock_config()
|
||||
|
||||
def _send_build_change(self, state, source, build_id):
|
||||
|
||||
@@ -32,8 +32,8 @@ import six
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from requests.exceptions import ConnectionError
|
||||
|
||||
from module_build_service import conf, log
|
||||
from module_build_service import pdc
|
||||
from module_build_service import conf, log, db
|
||||
from module_build_service import pdc, models
|
||||
import module_build_service.scm
|
||||
import module_build_service.utils
|
||||
|
||||
@@ -277,10 +277,31 @@ class GenericBuilder(six.with_metaclass(ABCMeta)):
|
||||
@classmethod
|
||||
@module_build_service.utils.retry(wait_on=(ConnectionError))
|
||||
def default_buildroot_groups(cls, session, module):
|
||||
local_modules = models.ModuleBuild.local_modules(db.session)
|
||||
local_modules = {m.name + "-" + m.stream: m for m in local_modules}
|
||||
|
||||
try:
|
||||
mmd = module.mmd()
|
||||
pdc_session = pdc.get_pdc_client_session(conf)
|
||||
pdc_groups = pdc.resolve_profiles(pdc_session, module.mmd(),
|
||||
('buildroot', 'srpm-buildroot'))
|
||||
|
||||
# Resolve default buildroot groups using the PDC, but only for
|
||||
# non-local modules.
|
||||
pdc_groups = pdc.resolve_profiles(pdc_session, mmd,
|
||||
('buildroot', 'srpm-buildroot'),
|
||||
exclude=local_modules)
|
||||
|
||||
# For local modules, resolve the buildroot groups using local
|
||||
# modulemd metadata.
|
||||
for module_name, module_info in mmd.xmd['mbs']['buildrequires'].items():
|
||||
key = module_name + "-" + module_info['stream']
|
||||
if key in local_modules:
|
||||
local_build = local_modules[key]
|
||||
local_mmd = local_build.mmd()
|
||||
if 'buildroot' in local_mmd.profiles:
|
||||
pdc_groups['buildroot'] |= local_mmd.profiles['buildroot'].rpms
|
||||
if 'srpm-buildroot' in local_mmd.profiles:
|
||||
pdc_groups['srpm-buildroot'] |= local_mmd.profiles['srpm-buildroot'].rpms
|
||||
|
||||
groups = {
|
||||
'build': pdc_groups['buildroot'],
|
||||
'srpm-build': pdc_groups['srpm-buildroot'],
|
||||
|
||||
@@ -34,6 +34,7 @@ from module_build_service import app, conf, db, create_app
|
||||
from module_build_service import models
|
||||
from module_build_service.utils import (
|
||||
submit_module_build_from_scm,
|
||||
load_local_builds,
|
||||
)
|
||||
import module_build_service.messaging
|
||||
import module_build_service.scheduler.consumer
|
||||
@@ -115,11 +116,14 @@ def cleardb():
|
||||
models.ComponentBuild.query.delete()
|
||||
|
||||
|
||||
@manager.command
|
||||
def build_module_locally(url, branch, skiptests=False):
|
||||
@manager.option('branch')
|
||||
@manager.option('url')
|
||||
@manager.option('skiptests', action='store_true')
|
||||
@manager.option('-l', '--add-local-build', action='append', default=None, dest='local_build_nsvs')
|
||||
def build_module_locally(url, branch, local_build_nsvs=None, skiptests=False):
|
||||
""" Performs local module build using Mock
|
||||
"""
|
||||
if 'SERVER_NAME' not in app.config:
|
||||
if 'SERVER_NAME' not in app.config or not app.config['SERVER_NAME']:
|
||||
app.config["SERVER_NAME"] = 'localhost'
|
||||
|
||||
with app.app_context():
|
||||
@@ -136,15 +140,8 @@ def build_module_locally(url, branch, skiptests=False):
|
||||
if os.path.exists(dbpath):
|
||||
os.remove(dbpath)
|
||||
|
||||
# Create the database and insert fake base-runtime module there. This is
|
||||
# normally done by the flask_migrate.upgrade(), but I (jkaluza) do not
|
||||
# call it here, because after that call, all the logged messages are not
|
||||
# printed to stdout/stderr and are ignored... I did not find a way how to
|
||||
# fix that.
|
||||
#
|
||||
# In the future, we should use PDC to get what we need from the fake module,
|
||||
# so it's probably not big problem.
|
||||
db.create_all()
|
||||
load_local_builds(local_build_nsvs)
|
||||
|
||||
username = getpass.getuser()
|
||||
submit_module_build_from_scm(username, url, branch, allow_local_url=True,
|
||||
|
||||
@@ -34,7 +34,7 @@ from sqlalchemy.orm import validates, scoped_session, sessionmaker
|
||||
from flask import has_app_context
|
||||
import modulemd as _modulemd
|
||||
|
||||
from module_build_service import db, log, get_url_for, app
|
||||
from module_build_service import db, log, get_url_for, app, conf
|
||||
import module_build_service.messaging
|
||||
|
||||
from sqlalchemy.orm import lazyload
|
||||
@@ -83,7 +83,7 @@ def make_session(conf):
|
||||
Yields new SQLAlchemy database sesssion.
|
||||
"""
|
||||
# Needs to be set to create app_context.
|
||||
if 'SERVER_NAME' not in app.config:
|
||||
if 'SERVER_NAME' not in app.config or not app.config['SERVER_NAME']:
|
||||
app.config['SERVER_NAME'] = 'localhost'
|
||||
|
||||
# If there is no app_context, we have to create one before creating
|
||||
@@ -214,7 +214,7 @@ class ModuleBuild(MBSBase):
|
||||
owner=username,
|
||||
time_submitted=now,
|
||||
copr_owner=copr_owner,
|
||||
copr_project=copr_project,
|
||||
copr_project=copr_project
|
||||
)
|
||||
session.add(module)
|
||||
session.commit()
|
||||
@@ -254,6 +254,35 @@ class ModuleBuild(MBSBase):
|
||||
conf=conf,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def local_modules(cls, session, name=None, stream=None):
|
||||
"""
|
||||
Returns list of local module builds added by
|
||||
utils.load_local_builds(...). When `name` or `stream` is set,
|
||||
it is used to further limit the result set.
|
||||
|
||||
If conf.system is not set to "mock" or "test", returns empty
|
||||
list everytime, because local modules make sense only when
|
||||
building using Mock backend or during tests.
|
||||
"""
|
||||
if conf.system in ["koji", "copr"]:
|
||||
return []
|
||||
|
||||
filters = {}
|
||||
if name:
|
||||
filters["name"] = name
|
||||
if stream:
|
||||
filters["stream"] = stream
|
||||
local_modules = session.query(ModuleBuild).filter_by(
|
||||
**filters).all()
|
||||
if not local_modules:
|
||||
return []
|
||||
|
||||
local_modules = [m for m in local_modules
|
||||
if m.koji_tag
|
||||
and m.koji_tag.startswith(conf.mock_resultsdir)]
|
||||
return local_modules
|
||||
|
||||
@classmethod
|
||||
def by_state(cls, session, state):
|
||||
return session.query(ModuleBuild).filter_by(state=BUILD_STATES[state]).all()
|
||||
|
||||
@@ -237,12 +237,14 @@ def _extract_modulemd(yaml, strict=False):
|
||||
return mmd
|
||||
|
||||
|
||||
def resolve_profiles(session, mmd, keys):
|
||||
def resolve_profiles(session, mmd, keys, exclude=None):
|
||||
"""
|
||||
:param session : PDCClient instance
|
||||
:param mmd: ModuleMetadata instance of module
|
||||
:param keys: list of modulemd installation profiles to include in
|
||||
the result.
|
||||
:param exclude: a set or map with the keys being $name-$stream
|
||||
to not look up in the PDC
|
||||
:return: Dictionary with keys set according to `keys` param and values
|
||||
set to union of all components defined in all installation
|
||||
profiles matching the key using the buildrequires.
|
||||
@@ -250,10 +252,15 @@ def resolve_profiles(session, mmd, keys):
|
||||
https://pagure.io/fm-orchestrator/issue/181
|
||||
"""
|
||||
|
||||
exclude = exclude or []
|
||||
|
||||
results = {}
|
||||
for key in keys:
|
||||
results[key] = set()
|
||||
for module_name, module_info in mmd.xmd['mbs']['buildrequires'].items():
|
||||
if module_name + "-" + module_info['stream'] in exclude:
|
||||
continue
|
||||
|
||||
# Find the dep in the built modules in PDC
|
||||
module_info = {
|
||||
'variant_id': module_name,
|
||||
|
||||
@@ -168,6 +168,16 @@ def wait(config, session, msg):
|
||||
str(module_info['stream']), str(module_info['version'])])
|
||||
|
||||
for name, stream in build.mmd().buildrequires.items():
|
||||
# Try to load local module if it is loaded by
|
||||
# utils.load_local_modules(...). Such modules have koji_tag set to
|
||||
# path to repository with built RPMs.
|
||||
local_modules = models.ModuleBuild.local_modules(session, name, stream)
|
||||
if local_modules:
|
||||
local_module = local_modules[0]
|
||||
log.info("Using local module %r as a dependency.",
|
||||
local_module)
|
||||
dependencies.append(local_module.koji_tag)
|
||||
continue
|
||||
|
||||
pdc_session = module_build_service.pdc.get_pdc_client_session(config)
|
||||
pdc_query = {
|
||||
|
||||
@@ -34,6 +34,7 @@ import inspect
|
||||
import hashlib
|
||||
|
||||
import modulemd
|
||||
import yaml
|
||||
|
||||
from flask import request, url_for
|
||||
from datetime import datetime
|
||||
@@ -572,6 +573,90 @@ def _scm_get_latest(pkg):
|
||||
}
|
||||
|
||||
|
||||
def load_local_builds(local_build_nsvs):
|
||||
"""
|
||||
Loads previously finished local module builds from conf.mock_resultsdir
|
||||
and imports them to database.
|
||||
|
||||
:param local_build_nsvs: List of NSV separated by ':' defining the modules
|
||||
to load from the mock_resultsdir.
|
||||
"""
|
||||
if not local_build_nsvs:
|
||||
return
|
||||
|
||||
if type(local_build_nsvs) != list:
|
||||
local_build_nsvs = [local_build_nsvs]
|
||||
|
||||
# Get the list of all available local module builds.
|
||||
builds = []
|
||||
try:
|
||||
for d in os.listdir(conf.mock_resultsdir):
|
||||
m = re.match('^module-(.*)-([^-]*)-([0-9]+)$', d)
|
||||
if m:
|
||||
builds.append((m.group(1), m.group(2), int(m.group(3)), d))
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
# Sort with the biggest version first
|
||||
builds.sort(lambda a, b: -cmp(a[2], b[2]))
|
||||
|
||||
for build_id in local_build_nsvs:
|
||||
parts = build_id.split(':')
|
||||
if len(parts) < 1 or len(parts) > 3:
|
||||
raise RuntimeError(
|
||||
'The local build "{0}" couldn\'t be be parsed into '
|
||||
'NAME[:STREAM[:VERSION]]'.format(build_id))
|
||||
|
||||
name = parts[0]
|
||||
stream = parts[1] if len(parts) > 1 else None
|
||||
version = int(parts[2]) if len(parts) > 2 else None
|
||||
|
||||
found_build = None
|
||||
for build in builds:
|
||||
if name != build[0]:
|
||||
continue
|
||||
if stream is not None and stream != build[1]:
|
||||
continue
|
||||
if version is not None and version != build[2]:
|
||||
continue
|
||||
|
||||
found_build = build
|
||||
break
|
||||
|
||||
if not found_build:
|
||||
raise RuntimeError(
|
||||
'The local build "{0}" couldn\'t be found in "{1}"'.format(
|
||||
build_id, conf.mock_resultsdir))
|
||||
|
||||
# Load the modulemd metadata.
|
||||
path = os.path.join(conf.mock_resultsdir, found_build[3], 'results')
|
||||
mmd_path = os.path.join(path, 'modules.yaml')
|
||||
with open(mmd_path, 'r') as f:
|
||||
mmd_data = yaml.safe_load(f)
|
||||
mmd = modulemd.ModuleMetadata()
|
||||
mmd.loadd(mmd_data)
|
||||
|
||||
# Create ModuleBuild in database.
|
||||
module = models.ModuleBuild.create(
|
||||
db.session,
|
||||
conf,
|
||||
name=mmd.name,
|
||||
stream=mmd.stream,
|
||||
version=str(mmd.version),
|
||||
modulemd=mmd.dumps(),
|
||||
scmurl="",
|
||||
username="mbs")
|
||||
module.koji_tag = path
|
||||
db.session.commit()
|
||||
|
||||
if (found_build[0] != module.name
|
||||
or found_build[1] != module.stream
|
||||
or str(found_build[2]) != module.version):
|
||||
raise RuntimeError(
|
||||
'Parsed metadata results for "{0}" don\'t match the directory name'.format(found_build[3]))
|
||||
log.info("Loaded local module build %r", module)
|
||||
|
||||
|
||||
def format_mmd(mmd, scmurl):
|
||||
"""
|
||||
Prepares the modulemd for the MBS. This does things such as replacing the
|
||||
@@ -586,6 +671,9 @@ def format_mmd(mmd, scmurl):
|
||||
|
||||
mmd.xmd['mbs'] = {'scmurl': scmurl, 'commit': None}
|
||||
|
||||
local_modules = models.ModuleBuild.local_modules(db.session)
|
||||
local_modules = {m.name + "-" + m.stream: m for m in local_modules}
|
||||
|
||||
# If module build was submitted via yaml file, there is no scmurl
|
||||
if scmurl:
|
||||
scm = SCM(scmurl)
|
||||
@@ -609,6 +697,20 @@ def format_mmd(mmd, scmurl):
|
||||
pdc = module_build_service.pdc.get_pdc_client_session(conf)
|
||||
for module_name, module_stream in \
|
||||
mmd.xmd['mbs']['buildrequires'].items():
|
||||
|
||||
# Try to find out module dependency in the local module builds
|
||||
# added by utils.load_local_builds(...).
|
||||
local_modules = models.ModuleBuild.local_modules(
|
||||
db.session, module_name, module_stream)
|
||||
if local_modules:
|
||||
local_build = local_modules[0]
|
||||
mmd.xmd['mbs']['buildrequires'][module_name] = {
|
||||
# The commit ID isn't currently saved in modules.yaml
|
||||
'stream': local_build.stream,
|
||||
'version': local_build.version
|
||||
}
|
||||
continue
|
||||
|
||||
# Assumes that module_stream is the stream and not the commit hash
|
||||
module_info = {
|
||||
'name': module_name,
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
---
|
||||
data:
|
||||
api:
|
||||
rpms: [ed, mksh]
|
||||
artifacts:
|
||||
rpms: [ed-debuginfo-1.14.1-4.module_92fc48de.x86_64, ed-1.14.1-4.module_92fc48de.x86_64,
|
||||
module-build-macros-0.1-1.module_92fc48de.src, module-build-macros-0.1-1.module_92fc48de.noarch,
|
||||
ed-1.14.1-4.module_92fc48de.src]
|
||||
components:
|
||||
rpms:
|
||||
ed: {cache: 'http://pkgs.fedoraproject.org/repo/pkgs/ed', rationale: A build
|
||||
dependency of mksh., ref: master, repository: 'git://pkgs.fedoraproject.org/rpms/ed'}
|
||||
dependencies:
|
||||
buildrequires: {base-runtime: master}
|
||||
requires: {base-runtime: master}
|
||||
description: This module demonstrates how to write simple modulemd files And can
|
||||
be used for testing the build and release pipeline.
|
||||
license:
|
||||
module: [MIT]
|
||||
name: base-runtime
|
||||
profiles:
|
||||
default:
|
||||
rpms: [mksh]
|
||||
buildroot:
|
||||
rpms:
|
||||
- foo
|
||||
srpm-buildroot:
|
||||
rpms:
|
||||
- bar
|
||||
references: {community: 'https://docs.pagure.org/modularity/', documentation: 'https://fedoraproject.org/wiki/Fedora_Packaging_Guidelines_for_Modules'}
|
||||
stream: master
|
||||
summary: A test module in all its beautiful beauty
|
||||
version: 20170816080815
|
||||
xmd:
|
||||
mbs:
|
||||
buildrequires:
|
||||
base-runtime: {ref: 147dca4ca65aa9a1ac51f71b7e687f9178ffa5df, stream: master,
|
||||
version: '20170616125652'}
|
||||
commit: 722fd739fd6cf66faf29f6fb95dd64f60ba3e39a
|
||||
rpms:
|
||||
ed: {ref: 01bf8330812fea798671925cc537f2f29b0bd216}
|
||||
scmurl: file:///home/hanzz/modules/testmodule/
|
||||
document: modulemd
|
||||
version: 1
|
||||
@@ -0,0 +1,38 @@
|
||||
---
|
||||
data:
|
||||
api:
|
||||
rpms: [ed, mksh]
|
||||
artifacts:
|
||||
rpms: [ed-debuginfo-1.14.1-4.module_92fc48de.x86_64, ed-1.14.1-4.module_92fc48de.x86_64,
|
||||
module-build-macros-0.1-1.module_92fc48de.src, module-build-macros-0.1-1.module_92fc48de.noarch,
|
||||
ed-1.14.1-4.module_92fc48de.src]
|
||||
components:
|
||||
rpms:
|
||||
ed: {cache: 'http://pkgs.fedoraproject.org/repo/pkgs/ed', rationale: A build
|
||||
dependency of mksh., ref: master, repository: 'git://pkgs.fedoraproject.org/rpms/ed'}
|
||||
dependencies:
|
||||
buildrequires: {base-runtime: master}
|
||||
requires: {base-runtime: master}
|
||||
description: This module demonstrates how to write simple modulemd files And can
|
||||
be used for testing the build and release pipeline.
|
||||
license:
|
||||
module: [MIT]
|
||||
name: testmodule
|
||||
profiles:
|
||||
default:
|
||||
rpms: [mksh]
|
||||
references: {community: 'https://docs.pagure.org/modularity/', documentation: 'https://fedoraproject.org/wiki/Fedora_Packaging_Guidelines_for_Modules'}
|
||||
stream: master
|
||||
summary: A test module in all its beautiful beauty
|
||||
version: 20170816080815
|
||||
xmd:
|
||||
mbs:
|
||||
buildrequires:
|
||||
base-runtime: {ref: 147dca4ca65aa9a1ac51f71b7e687f9178ffa5df, stream: master,
|
||||
version: '20170616125652'}
|
||||
commit: 722fd739fd6cf66faf29f6fb95dd64f60ba3e39a
|
||||
rpms:
|
||||
ed: {ref: 01bf8330812fea798671925cc537f2f29b0bd216}
|
||||
scmurl: file:///home/hanzz/modules/testmodule/
|
||||
document: modulemd
|
||||
version: 1
|
||||
@@ -0,0 +1,38 @@
|
||||
---
|
||||
data:
|
||||
api:
|
||||
rpms: [ed, mksh]
|
||||
artifacts:
|
||||
rpms: [ed-debuginfo-1.14.1-4.module_92fc48de.x86_64, ed-1.14.1-4.module_92fc48de.x86_64,
|
||||
module-build-macros-0.1-1.module_92fc48de.src, module-build-macros-0.1-1.module_92fc48de.noarch,
|
||||
ed-1.14.1-4.module_92fc48de.src]
|
||||
components:
|
||||
rpms:
|
||||
ed: {cache: 'http://pkgs.fedoraproject.org/repo/pkgs/ed', rationale: A build
|
||||
dependency of mksh., ref: master, repository: 'git://pkgs.fedoraproject.org/rpms/ed'}
|
||||
dependencies:
|
||||
buildrequires: {base-runtime: master}
|
||||
requires: {base-runtime: master}
|
||||
description: This module demonstrates how to write simple modulemd files And can
|
||||
be used for testing the build and release pipeline.
|
||||
license:
|
||||
module: [MIT]
|
||||
name: testmodule
|
||||
profiles:
|
||||
default:
|
||||
rpms: [mksh]
|
||||
references: {community: 'https://docs.pagure.org/modularity/', documentation: 'https://fedoraproject.org/wiki/Fedora_Packaging_Guidelines_for_Modules'}
|
||||
stream: master
|
||||
summary: A test module in all its beautiful beauty
|
||||
version: 20170816080816
|
||||
xmd:
|
||||
mbs:
|
||||
buildrequires:
|
||||
base-runtime: {ref: 147dca4ca65aa9a1ac51f71b7e687f9178ffa5df, stream: master,
|
||||
version: '20170616125652'}
|
||||
commit: 722fd739fd6cf66faf29f6fb95dd64f60ba3e39a
|
||||
rpms:
|
||||
ed: {ref: 01bf8330812fea798671925cc537f2f29b0bd216}
|
||||
scmurl: file:///home/hanzz/modules/testmodule/
|
||||
document: modulemd
|
||||
version: 1
|
||||
@@ -0,0 +1,46 @@
|
||||
---
|
||||
data:
|
||||
api:
|
||||
rpms: [ed, mksh]
|
||||
artifacts:
|
||||
rpms: [mksh-56-1.module_92fc48de.src, module-build-macros-0.1-1.module_b7b9441a.src,
|
||||
mksh-debuginfo-56-1.module_92fc48de.x86_64, module-build-macros-0.1-1.module_b7b9441a.noarch,
|
||||
mksh-56-1.module_92fc48de.x86_64]
|
||||
buildopts:
|
||||
rpms: {macros: '
|
||||
|
||||
|
||||
%check exit 0
|
||||
|
||||
'}
|
||||
components:
|
||||
rpms:
|
||||
mksh: {cache: 'http://pkgs.fedoraproject.org/repo/pkgs/mksh', rationale: A build
|
||||
dependency of mksh., ref: master, repository: 'git://pkgs.fedoraproject.org/rpms/mksh'}
|
||||
dependencies:
|
||||
buildrequires: {base-runtime: master, testmodule: master}
|
||||
requires: {base-runtime: master}
|
||||
description: This module demonstrates how to write simple modulemd files And can
|
||||
be used for testing the build and release pipeline.
|
||||
license:
|
||||
module: [MIT]
|
||||
name: testmodule2
|
||||
profiles:
|
||||
default:
|
||||
rpms: [mksh]
|
||||
references: {community: 'https://docs.pagure.org/modularity/', documentation: 'https://fedoraproject.org/wiki/Fedora_Packaging_Guidelines_for_Modules'}
|
||||
stream: master
|
||||
summary: A test module in all its beautiful beauty
|
||||
version: 20170816093656
|
||||
xmd:
|
||||
mbs:
|
||||
buildrequires:
|
||||
base-runtime: {ref: 147dca4ca65aa9a1ac51f71b7e687f9178ffa5df, stream: master,
|
||||
version: '20170616125652'}
|
||||
testmodule: {stream: master, version: '20170816080815'}
|
||||
commit: null
|
||||
rpms:
|
||||
mksh: {ref: 7df6f444cd19c4af97dee8529f35c02f0cedc4fa}
|
||||
scmurl: ''
|
||||
document: modulemd
|
||||
version: 1
|
||||
@@ -95,6 +95,7 @@ class TestModuleBuilder(GenericBuilder):
|
||||
|
||||
BUILD_STATE = "COMPLETE"
|
||||
INSTANT_COMPLETE = False
|
||||
DEFAULT_GROUPS = None
|
||||
|
||||
on_build_cb = None
|
||||
on_cancel_cb = None
|
||||
@@ -115,9 +116,10 @@ class TestModuleBuilder(GenericBuilder):
|
||||
TestModuleBuilder.on_cancel_cb = None
|
||||
TestModuleBuilder.on_buildroot_add_artifacts_cb = None
|
||||
TestModuleBuilder.on_tag_artifacts_cb = None
|
||||
TestModuleBuilder.DEFAULT_GROUPS = None
|
||||
|
||||
def buildroot_connect(self, groups):
|
||||
default_groups = {
|
||||
default_groups = TestModuleBuilder.DEFAULT_GROUPS or {
|
||||
'srpm-build':
|
||||
set(['shadow-utils', 'fedora-release', 'redhat-rpm-config',
|
||||
'rpm-build', 'fedpkg-minimal', 'gnupg2', 'bash']),
|
||||
@@ -793,3 +795,83 @@ class TestBuild(unittest.TestCase):
|
||||
for build in models.ComponentBuild.query.filter_by(module_id=module_build_id).all():
|
||||
self.assertEqual(build.state, koji.BUILD_STATES['COMPLETE'])
|
||||
self.assertTrue(build.module_build.state in [models.BUILD_STATES["done"], models.BUILD_STATES["ready"]])
|
||||
|
||||
@patch("module_build_service.config.Config.system",
|
||||
new_callable=PropertyMock, return_value="test")
|
||||
class TestLocalBuild(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
GenericBuilder.register_backend_class(TestModuleBuilder)
|
||||
self.client = app.test_client()
|
||||
|
||||
init_data()
|
||||
models.ModuleBuild.query.delete()
|
||||
models.ComponentBuild.query.delete()
|
||||
|
||||
filename = cassette_dir + self.id()
|
||||
self.vcr = vcr.use_cassette(filename)
|
||||
self.vcr.__enter__()
|
||||
|
||||
def tearDown(self):
|
||||
TestModuleBuilder.reset()
|
||||
|
||||
# Necessary to restart the twisted reactor for the next test.
|
||||
import sys
|
||||
del sys.modules['twisted.internet.reactor']
|
||||
del sys.modules['moksha.hub.reactor']
|
||||
del sys.modules['moksha.hub']
|
||||
import moksha.hub.reactor
|
||||
self.vcr.__exit__()
|
||||
for i in range(20):
|
||||
try:
|
||||
os.remove(build_logs.path(i))
|
||||
except:
|
||||
pass
|
||||
|
||||
@timed(30)
|
||||
@patch('module_build_service.auth.get_user', return_value=user)
|
||||
@patch('module_build_service.scm.SCM')
|
||||
@patch("module_build_service.config.Config.mock_resultsdir",
|
||||
new_callable=PropertyMock,
|
||||
return_value=path.join(
|
||||
base_dir, 'staged_data', "local_builds"))
|
||||
def test_submit_build_local_dependency(
|
||||
self, resultsdir, mocked_scm, mocked_get_user, conf_system):
|
||||
"""
|
||||
Tests local module build dependency.
|
||||
"""
|
||||
with app.app_context():
|
||||
module_build_service.utils.load_local_builds(["base-runtime"])
|
||||
MockedSCM(mocked_scm, 'testmodule', 'testmodule.yaml',
|
||||
'620ec77321b2ea7b0d67d82992dda3e1d67055b4')
|
||||
|
||||
rv = self.client.post(
|
||||
'/module-build-service/1/module-builds/', data=json.dumps(
|
||||
{'branch': 'master',
|
||||
'scmurl': 'git://pkgs.stg.fedoraproject.org/modules/'
|
||||
'testmodule.git?#68932c90de214d9d13feefbd35246a81b6cb8d49'}))
|
||||
|
||||
data = json.loads(rv.data)
|
||||
module_build_id = data['id']
|
||||
|
||||
# Local base-runtime has changed profiles, so we can detect we use
|
||||
# the local one and not the main one.
|
||||
TestModuleBuilder.DEFAULT_GROUPS = {
|
||||
'srpm-build':
|
||||
set(['bar']),
|
||||
'build':
|
||||
set(['foo'])}
|
||||
|
||||
msgs = []
|
||||
stop = module_build_service.scheduler.make_simple_stop_condition(
|
||||
db.session)
|
||||
module_build_service.scheduler.main(msgs, stop)
|
||||
|
||||
# All components should be built and module itself should be in "done"
|
||||
# or "ready" state.
|
||||
for build in models.ComponentBuild.query.filter_by(
|
||||
module_id=module_build_id).all():
|
||||
self.assertEqual(build.state, koji.BUILD_STATES['COMPLETE'])
|
||||
self.assertTrue(build.module_build.state in [
|
||||
models.BUILD_STATES["done"], models.BUILD_STATES["ready"]])
|
||||
|
||||
|
||||
@@ -114,3 +114,20 @@ class TestPDCModule(unittest.TestCase):
|
||||
'bash'])
|
||||
}
|
||||
self.assertEqual(result, expected)
|
||||
|
||||
def test_resolve_profiles_exclude(self):
|
||||
current_dir = os.path.dirname(__file__)
|
||||
yaml_path = os.path.join(
|
||||
current_dir, 'staged_data', 'formatted_testmodule.yaml')
|
||||
mmd = modulemd.ModuleMetadata()
|
||||
mmd.load(yaml_path)
|
||||
result = mbs_pdc.resolve_profiles(self.pdc, mmd,
|
||||
('buildroot', 'srpm-buildroot'),
|
||||
exclude=("base-runtime-master",))
|
||||
expected = {
|
||||
'buildroot':
|
||||
set(),
|
||||
'srpm-buildroot':
|
||||
set()
|
||||
}
|
||||
self.assertEqual(result, expected)
|
||||
|
||||
@@ -650,3 +650,81 @@ class TestBatches(unittest.TestCase):
|
||||
|
||||
# Batch number should not increase.
|
||||
self.assertEqual(module_build.batch, 1)
|
||||
|
||||
|
||||
@patch("module_build_service.config.Config.mock_resultsdir",
|
||||
new_callable=mock.PropertyMock,
|
||||
return_value=path.join(
|
||||
BASE_DIR, '..', 'staged_data', "local_builds"))
|
||||
@patch("module_build_service.config.Config.system",
|
||||
new_callable=mock.PropertyMock, return_value="mock")
|
||||
class TestLocalBuilds(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
init_data()
|
||||
|
||||
def tearDown(self):
|
||||
init_data()
|
||||
|
||||
def test_load_local_builds_name(self, conf_system, conf_resultsdir):
|
||||
with app.app_context():
|
||||
module_build_service.utils.load_local_builds("testmodule")
|
||||
local_modules = models.ModuleBuild.local_modules(db.session)
|
||||
|
||||
self.assertEqual(len(local_modules), 1)
|
||||
self.assertTrue(local_modules[0].koji_tag.endswith(
|
||||
"/module-testmodule-master-20170816080816/results"))
|
||||
|
||||
def test_load_local_builds_name_stream(
|
||||
self, conf_system, conf_resultsdir):
|
||||
with app.app_context():
|
||||
module_build_service.utils.load_local_builds("testmodule:master")
|
||||
local_modules = models.ModuleBuild.local_modules(db.session)
|
||||
|
||||
self.assertEqual(len(local_modules), 1)
|
||||
self.assertTrue(local_modules[0].koji_tag.endswith(
|
||||
"/module-testmodule-master-20170816080816/results"))
|
||||
|
||||
def test_load_local_builds_name_stream_non_existing(
|
||||
self, conf_system, conf_resultsdir):
|
||||
with app.app_context():
|
||||
with self.assertRaises(RuntimeError):
|
||||
module_build_service.utils.load_local_builds("testmodule:x")
|
||||
local_modules = models.ModuleBuild.local_modules(db.session)
|
||||
|
||||
def test_load_local_builds_name_stream_version(
|
||||
self, conf_system, conf_resultsdir):
|
||||
with app.app_context():
|
||||
module_build_service.utils.load_local_builds("testmodule:master:20170816080815")
|
||||
local_modules = models.ModuleBuild.local_modules(db.session)
|
||||
|
||||
self.assertEqual(len(local_modules), 1)
|
||||
self.assertTrue(local_modules[0].koji_tag.endswith(
|
||||
"/module-testmodule-master-20170816080815/results"))
|
||||
|
||||
def test_load_local_builds_name_stream_version_non_existing(
|
||||
self, conf_system, conf_resultsdir):
|
||||
with app.app_context():
|
||||
with self.assertRaises(RuntimeError):
|
||||
module_build_service.utils.load_local_builds("testmodule:master:123")
|
||||
local_modules = models.ModuleBuild.local_modules(db.session)
|
||||
|
||||
def test_load_local_builds_base_runtime(
|
||||
self, conf_system, conf_resultsdir):
|
||||
with app.app_context():
|
||||
module_build_service.utils.load_local_builds("base-runtime")
|
||||
local_modules = models.ModuleBuild.local_modules(db.session)
|
||||
|
||||
self.assertEqual(len(local_modules), 1)
|
||||
self.assertTrue(local_modules[0].koji_tag.endswith(
|
||||
"/module-base-runtime-master-20170816080815/results"))
|
||||
|
||||
def test_load_local_builds_base_runtime_master(
|
||||
self, conf_system, conf_resultsdir):
|
||||
with app.app_context():
|
||||
module_build_service.utils.load_local_builds("base-runtime:master")
|
||||
local_modules = models.ModuleBuild.local_modules(db.session)
|
||||
|
||||
self.assertEqual(len(local_modules), 1)
|
||||
self.assertTrue(local_modules[0].koji_tag.endswith(
|
||||
"/module-base-runtime-master-20170816080815/results"))
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user