From 968a50ed8ffa438f44dd8c06643d3c94a1c1403f Mon Sep 17 00:00:00 2001 From: Jan Kaluža Date: Oct 24 2017 05:21:21 +0000 Subject: Merge #114 `Skip 'createiso' phase when 'iso' compose_result is not set` --- diff --git a/server/conf/pungi.conf b/server/conf/pungi.conf index fe6ba73..dcb35d8 100644 --- a/server/conf/pungi.conf +++ b/server/conf/pungi.conf @@ -63,7 +63,14 @@ createrepo_checksum = 'sha256' media_checksums = ['sha256'] create_jigdo = False -skip_phases = ["buildinstall", "live_media", "live_images", "ostree"] +skip_phases = [ +{%- if "iso" not in config.results %} + "createiso", +{%- endif %} + "buildinstall", + "live_media", + "live_images", + "ostree"] translate_paths = [ ('/mnt/koji/compose/', 'http://kojipkgs.fedoraproject.org/compose/'), diff --git a/server/odcs/server/backend.py b/server/odcs/server/backend.py index 63a7e2d..0d1f524 100644 --- a/server/odcs/server/backend.py +++ b/server/odcs/server/backend.py @@ -415,7 +415,8 @@ def generate_pungi_compose(compose): # Generate PungiConfig and run Pungi pungi_cfg = PungiConfig(compose.name, "1", compose.source_type, compose.source, packages=packages, - sigkeys=compose.sigkeys) + sigkeys=compose.sigkeys, + results=compose.results) if compose.flags & COMPOSE_FLAGS["no_deps"]: pungi_cfg.gather_method = "nodeps" diff --git a/server/odcs/server/pungi.py b/server/odcs/server/pungi.py index 87f4c3e..00ec110 100644 --- a/server/odcs/server/pungi.py +++ b/server/odcs/server/pungi.py @@ -29,12 +29,12 @@ import jinja2 import odcs.server.utils from odcs.server import conf, log from odcs.server import comps -from odcs.common.types import PungiSourceType +from odcs.common.types import PungiSourceType, COMPOSE_RESULTS class PungiConfig(object): def __init__(self, release_name, release_version, source_type, source, - packages=None, arches=None, sigkeys=None): + packages=None, arches=None, sigkeys=None, results=0): self.release_name = release_name self.release_version = release_version self.bootable = False @@ -51,6 +51,13 @@ class PungiConfig(object): self.arches = conf.arches self.packages = packages or [] + # Store results as list of strings, so it can be used by jinja2 + # templates. + self.results = [] + for k, v in COMPOSE_RESULTS.items(): + if results & v: + self.results.append(k) + if source_type == PungiSourceType.KOJI_TAG: self.koji_tag = source self.gather_source = "comps" diff --git a/server/tests/test_pungi.py b/server/tests/test_pungi.py index b6a4c43..d9d0afb 100644 --- a/server/tests/test_pungi.py +++ b/server/tests/test_pungi.py @@ -26,9 +26,11 @@ import tempfile import unittest from mock import patch +from kobo.conf import PyConfigParser import odcs.server -from odcs.server.pungi import Pungi, PungiConfig, PungiSourceType +from odcs.server.pungi import (Pungi, PungiConfig, PungiSourceType, + COMPOSE_RESULTS) test_dir = os.path.abspath(os.path.dirname(__file__)) @@ -47,6 +49,11 @@ class TestPungiConfig(unittest.TestCase): super(TestPungiConfig, self).tearDown() self.patch_pungi_conf_path.stop() + def _load_pungi_cfg(self, cfg): + conf = PyConfigParser() + conf.load_from_string(cfg) + return conf + def test_pungi_config_module(self): pungi_cfg = PungiConfig("MBS-512", "1", PungiSourceType.MODULE, "testmodule-master") @@ -78,10 +85,11 @@ class TestPungiConfig(unittest.TestCase): pungi_cfg = PungiConfig("MBS-512", "1", PungiSourceType.MODULE, "testmodule-master") template = pungi_cfg.get_pungi_config() - self.assertTrue(len(template)) - self.assertTrue("release_name = 'MBS-512'" in template) - self.assertTrue("release_short = 'MBS-512'" in template) - self.assertTrue("release_version = '1'" in template) + cfg = self._load_pungi_cfg(template) + self.assertEqual(cfg["release_name"], "MBS-512") + self.assertEqual(cfg["release_short"], "MBS-512") + self.assertEqual(cfg["release_version"], "1") + self.assertTrue("createiso" in cfg["skip_phases"]) @patch("odcs.server.pungi.log") def test_get_pungi_conf_exception(self, log): @@ -92,6 +100,20 @@ class TestPungiConfig(unittest.TestCase): pungi_cfg.get_pungi_config() log.exception.assert_called_once() + def test_get_pungi_conf_iso(self): + _, mock_path = tempfile.mkstemp() + template_path = os.path.abspath(os.path.join(test_dir, + "../conf/pungi.conf")) + shutil.copy2(template_path, mock_path) + + with patch("odcs.server.pungi.conf.pungi_conf_path", mock_path): + pungi_cfg = PungiConfig("MBS-512", "1", PungiSourceType.MODULE, + "testmodule-master", + results=COMPOSE_RESULTS["iso"]) + template = pungi_cfg.get_pungi_config() + cfg = self._load_pungi_cfg(template) + self.assertTrue("createiso" not in cfg["skip_phases"]) + class TestPungi(unittest.TestCase): diff --git a/test-requirements.txt b/test-requirements.txt index f65fcac..1137b1e 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -2,3 +2,4 @@ pytest responses tox freezegun +kobo