Beispiel #1
0
    def setUp(self):
        self.tmp_dir = tempfile.TemporaryDirectory()

        self.render_step = step_def('update_component_deps')

        self.update_component_deps_trait = update_component_deps.UpdateComponentDependenciesTrait(
            name='update_component_dependencies',
            variant_name='don\'t_care',
            raw_dict={
                'set_dependency_version_script': 'some_path',
                'upstream_component_name': 'don\'t_care',
            },
        )

        self.main_repo = test_utils.repository()

        repo_dir = pathlib.Path(self.tmp_dir.name,
                                self.main_repo.resource_name())
        repo_dir.mkdir()

        self.job_variant = test_utils.job(self.main_repo)
        self.job_variant._traits_dict = {
            'update_component_deps': self.update_component_deps_trait
        }

        self.old_cwd = os.getcwd()
Beispiel #2
0
    def setUp(self):
        self.tmp_dir = tempfile.TemporaryDirectory()

        self.component_descriptor_trait = component_descriptor.ComponentDescriptorTrait(
            name='component_descriptor',
            variant_name='don\'t_care',
            raw_dict={
                'component_name': 'github.com/org/repo_name',
            },
        )
        self.component_descriptor_transformer = self.component_descriptor_trait.transformer()
        self.render_step = step_def('component_descriptor')

        self.main_repo = test_utils.repository()

        repo_dir = pathlib.Path(self.tmp_dir.name, self.main_repo.resource_name())
        repo_dir.mkdir()

        self.job_variant = test_utils.job(self.main_repo)

        self.job_variant._traits_dict = {'component_descriptor': self.component_descriptor_trait}

        for step in self.component_descriptor_transformer.inject_steps():
            self.job_variant._steps_dict[step.name] = step

        self.component_descriptor_step = self.job_variant.step('component_descriptor')
        self.component_descriptor_step.add_input('version_path', 'version_path')

        self.old_cwd = os.getcwd()
Beispiel #3
0
    def setUp(self):
        self.tmp_dir = tempfile.TemporaryDirectory()
        self.meta_dir = os.path.join(self.tmp_dir.name, 'meta')
        os.mkdir(self.meta_dir)
        test_utils.populate_meta_dir(self.meta_dir)
        self.on_error_dir = os.path.join(self.tmp_dir.name, 'on_error_dir')
        os.mkdir(self.on_error_dir)

        self.job_step = PipelineStep(
            name='step1',
            is_synthetic=False,
            notification_policy=StepNotificationPolicy.NOTIFY_PULL_REQUESTS,
            script_type=ScriptType.BOURNE_SHELL,
            raw_dict={},
        )
        self.job_step._notifications_cfg = NotificationCfgSet('default', {})
        resource_registry = ResourceRegistry()
        meta_resource_identifier = ResourceIdentifier(type_name='meta',
                                                      base_name='a_job')
        meta_resource = Resource(resource_identifier=meta_resource_identifier,
                                 raw_dict={})
        resource_registry.add_resource(meta_resource)
        self.job_variant = JobVariant(name='a_job',
                                      raw_dict={},
                                      resource_registry=resource_registry)

        # Set a main repository manually
        test_repo_logical_name = 'test-repository'
        self.job_variant._repos_dict = {}
        self.job_variant._repos_dict[
            test_repo_logical_name] = RepositoryConfig(
                raw_dict={
                    'branch': 'master',
                    'hostname': 'github.foo.bar',
                    'path': 'test/repo'
                },
                logical_name=test_repo_logical_name,
                qualifier=None,
                is_main_repo=True)
        self.job_variant._main_repository_name = test_repo_logical_name

        self.job_variant._traits_dict = {}
        self.cfg_set = MagicMock()
        self.github_cfg = MagicMock()
        self.github_cfg.name = MagicMock(return_value='github_cfg')
        self.email_cfg = MagicMock()
        self.email_cfg.name = MagicMock(return_value='email_cfg')
        self.cfg_set.github = MagicMock(return_value=self.github_cfg)
        self.cfg_set.email = MagicMock(return_value=self.email_cfg)
        ctx_repo_mock = MagicMock(return_value='repo_url')
        ctx_repo_mock.base_url = MagicMock(return_value='repo_url')
        self.cfg_set.ctx_repository = MagicMock(return_value=ctx_repo_mock)

        self.render_step = step_def('notification')

        self.old_cwd = os.getcwd()
        os.chdir(self.tmp_dir.name)
Beispiel #4
0
    def setUp(self):
        self.tmp_dir = tempfile.TemporaryDirectory()
        self.version_outdir = pathlib.Path(self.tmp_dir.name,
                                           'managed-version')
        self.version_outdir.mkdir()

        self.version_trait = version_trait.VersionTrait(
            name='version',
            variant_name='don\'t_care',
            raw_dict={
                'versionfile': 'version',
                'preprocess': 'finalize',
            },
        )
        self.version_trait_transformer = self.version_trait.transformer()
        self.render_step = step_def('version')

        self.main_repo = test_utils.repository()

        repo_dir = pathlib.Path(self.tmp_dir.name,
                                self.main_repo.resource_name())
        repo_dir.mkdir()

        # create fake git dir
        os.mkdir(repo_dir.joinpath('.git'))
        repo_dir.joinpath('.git', 'HEAD').touch()

        self.version_file = repo_dir.joinpath('version')
        self.version_file.write_text('1.2.3-xxx')

        self.job_variant = test_utils.job(self.main_repo)

        self.job_variant._traits_dict = {'version': self.version_trait}

        for step in self.version_trait_transformer.inject_steps():
            self.job_variant._steps_dict[step.name] = step

        self.old_cwd = os.getcwd()
    def setUp(self):
        self.tmp_dir = tempfile.TemporaryDirectory()

        self.render_step = step_def('update_component_deps')

        self.update_component_deps_trait = update_component_deps.UpdateComponentDependenciesTrait(
            name='update_component_dependencies',
            variant_name='don\'t_care',
            raw_dict={
                'set_dependency_version_script':'some_path',
                'upstream_component_name':'don\'t_care',
            },
        )

        self.component_descriptor_trait = component_descriptor.ComponentDescriptorTrait(
            name='component_descriptor',
            variant_name='don\'t_care',
            raw_dict={
                'component_name': 'github.com/org/repo_name',
            },
        )
        self.component_descriptor_trait.ctx_repository = lambda: cm.OciRepositoryContext(
            baseUrl='dummy-base-url',
        )

        self.main_repo = test_utils.repository()

        repo_dir = pathlib.Path(self.tmp_dir.name, self.main_repo.resource_name())
        repo_dir.mkdir()

        self.job_variant = test_utils.job(self.main_repo)
        self.job_variant._traits_dict = {
            'update_component_deps': self.update_component_deps_trait,
            'component_descriptor': self.component_descriptor_trait,
        }

        self.old_cwd = os.getcwd()