def run_builds(self,
                   curpage=None,
                   total_pages=None,
                   base_profile_name=None):
        if len(self.named_builds) > 0 and len(self.items) > 0:
            raise Exception(
                "Both bulk and named builds are set. Only one is allowed.")

        self.builds_in_current_page = []
        if len(self.items) > 0:
            curpage = curpage or int(self.curpage)
            total_pages = total_pages or int(self.total_pages)
            for index, build in enumerate(self.items):
                if curpage is None or total_pages is None or (
                        index % total_pages) + 1 == curpage:
                    self.builds_in_current_page.append(build)
        elif len(self.named_builds) > 0:
            curpage = curpage or self.curpage
            if curpage not in self.named_builds:
                raise Exception("No builds set for page %s" % curpage)
            for build in self.named_builds[curpage]:
                self.builds_in_current_page.append(build)

        self.printer.print_current_page(curpage, total_pages)
        self.printer.print_jobs(self.builds_in_current_page)

        pulled_docker_images = defaultdict(lambda: False)
        skip_recipe_export = False

        # FIXME: Remove in Conan 1.3, https://github.com/conan-io/conan/issues/2787
        for index, build in enumerate(self.builds_in_current_page):
            self.printer.print_message(
                "Build: %s/%s" % (index + 1, len(self.builds_in_current_page)))
            base_profile_name = base_profile_name or os.getenv(
                "CONAN_BASE_PROFILE")
            if base_profile_name:
                self.printer.print_message(
                    "**************************************************")
                self.printer.print_message("Using specified default "
                                           "base profile: %s" %
                                           base_profile_name)
                self.printer.print_message(
                    "**************************************************")

            profile_text, base_profile_text = get_profiles(
                self.client_cache, build, base_profile_name)
            if not self.use_docker:
                profile_abs_path = save_profile_to_tmp(profile_text)
                r = CreateRunner(
                    profile_abs_path,
                    build.reference,
                    self.conan_api,
                    self.uploader,
                    exclude_vcvars_precommand=self.exclude_vcvars_precommand,
                    build_policy=self.build_policy,
                    runner=self.runner,
                    cwd=self.cwd,
                    printer=self.printer,
                    upload=self._upload_enabled(),
                    upload_only_recipe=self.upload_only_recipe,
                    test_folder=self.test_folder,
                    config_url=self.config_url,
                    config_args=self.config_args,
                    upload_dependencies=self.upload_dependencies,
                    conanfile=self.conanfile,
                    lockfile=self.lockfile,
                    skip_recipe_export=skip_recipe_export,
                    update_dependencies=self.update_dependencies)
                r.run()
                self._packages_summary.append({
                    "configuration": build,
                    "package": r.results
                })
            else:
                docker_image = self._get_docker_image(build)
                r = DockerCreateRunner(
                    profile_text,
                    base_profile_text,
                    base_profile_name,
                    build.reference,
                    conan_pip_package=self.conan_pip_package,
                    docker_image=docker_image,
                    sudo_docker_command=self.sudo_docker_command,
                    sudo_pip_command=self.sudo_pip_command,
                    docker_image_skip_update=self._docker_image_skip_update,
                    docker_image_skip_pull=self._docker_image_skip_pull,
                    build_policy=self.build_policy,
                    always_update_conan_in_docker=self._update_conan_in_docker,
                    upload=self._upload_enabled(),
                    upload_retry=self.upload_retry,
                    upload_only_recipe=self.upload_only_recipe,
                    runner=self.runner,
                    docker_shell=self.docker_shell,
                    docker_conan_home=self.docker_conan_home,
                    docker_platform_param=self.docker_platform_param,
                    docker_run_options=self.docker_run_options,
                    lcow_user_workaround=self.lcow_user_workaround,
                    test_folder=self.test_folder,
                    pip_install=self.pip_install,
                    docker_pip_command=self.docker_pip_command,
                    config_url=self.config_url,
                    config_args=self.config_args,
                    printer=self.printer,
                    upload_dependencies=self.upload_dependencies,
                    conanfile=self.conanfile,
                    lockfile=self.lockfile,
                    force_selinux=self.force_selinux,
                    skip_recipe_export=skip_recipe_export,
                    update_dependencies=self.update_dependencies)

                r.run(pull_image=not pulled_docker_images[docker_image],
                      docker_entry_script=self.docker_entry_script)
                pulled_docker_images[docker_image] = True

            skip_recipe_export = self.skip_recipe_export
Exemple #2
0
    def run_builds(self,
                   curpage=None,
                   total_pages=None,
                   base_profile_name=None):
        if len(self.named_builds) > 0 and len(self.items) > 0:
            raise Exception(
                "Both bulk and named builds are set. Only one is allowed.")

        self.builds_in_current_page = []
        if len(self.items) > 0:
            curpage = curpage or int(self.curpage)
            total_pages = total_pages or int(self.total_pages)
            for index, build in enumerate(self.items):
                if curpage is None or total_pages is None or (
                        index % total_pages) + 1 == curpage:
                    self.builds_in_current_page.append(build)
        elif len(self.named_builds) > 0:
            curpage = curpage or self.curpage
            if curpage not in self.named_builds:
                raise Exception("No builds set for page %s" % curpage)
            for build in self.named_builds[curpage]:
                self.builds_in_current_page.append(build)

        self.printer.print_current_page(curpage, total_pages)
        self.printer.print_jobs(self.builds_in_current_page)

        pulled_docker_images = defaultdict(lambda: False)

        # FIXME: Remove in Conan 1.3, https://github.com/conan-io/conan/issues/2787
        abs_folder = os.path.realpath(os.getcwd())
        for build in self.builds_in_current_page:
            base_profile_name = base_profile_name or os.getenv(
                "CONAN_BASE_PROFILE")
            if base_profile_name:
                self.printer.print_message(
                    "**************************************************")
                self.printer.print_message("Using specified default "
                                           "base profile: %s" %
                                           base_profile_name)
                self.printer.print_message(
                    "**************************************************")

            profile_text, base_profile_text = get_profiles(
                self.client_cache, build, base_profile_name)
            if not self.use_docker:
                profile_abs_path = save_profile_to_tmp(profile_text)
                r = CreateRunner(
                    profile_abs_path,
                    build.reference,
                    self.conan_api,
                    self.uploader,
                    args=self.args,
                    exclude_vcvars_precommand=self.exclude_vcvars_precommand,
                    build_policy=self.build_policy,
                    runner=self.runner,
                    abs_folder=abs_folder,
                    printer=self.printer,
                    upload=self._upload_enabled())
                r.run()
            else:
                docker_image = self._get_docker_image(build)
                r = DockerCreateRunner(
                    profile_text,
                    base_profile_text,
                    base_profile_name,
                    build.reference,
                    args=self.args,
                    conan_pip_package=self.conan_pip_package,
                    docker_image=docker_image,
                    sudo_docker_command=self.sudo_docker_command,
                    sudo_pip_command=self.sudo_pip_command,
                    docker_image_skip_update=self._docker_image_skip_update,
                    docker_image_skip_pull=self._docker_image_skip_pull,
                    build_policy=self.build_policy,
                    always_update_conan_in_docker=self._update_conan_in_docker,
                    upload=self._upload_enabled(),
                    runner=self.runner,
                    docker_shell=self.docker_shell,
                    docker_conan_home=self.docker_conan_home)

                r.run(pull_image=not pulled_docker_images[docker_image],
                      docker_entry_script=self.docker_entry_script)
                pulled_docker_images[docker_image] = True