def run():
    # Get all from environ
    conan_api, client_cache, _ = Conan.factory()
    printer = Printer()
    if os.path.exists(client_cache.default_profile_path):
        os.remove(client_cache.default_profile_path)

    remotes_manager = RemotesManager(conan_api, printer)
    default_username = os.getenv("CONAN_USERNAME", None)
    auth_manager = AuthManager(conan_api, printer, default_username=default_username)

    uploader = Uploader(conan_api, remotes_manager, auth_manager, printer)
    args = os.getenv("CPT_ARGS", "")
    build_policy = unscape_env(os.getenv("CPT_BUILD_POLICY"))
    reference = ConanFileReference.loads(os.getenv("CONAN_REFERENCE"))

    profile_text = unscape_env(os.getenv("CPT_PROFILE"))
    abs_profile_path = save_profile_to_tmp(profile_text)
    base_profile_text = unscape_env(os.getenv("CPT_BASE_PROFILE"))
    if base_profile_text:
        base_profile_name = unscape_env(os.getenv("CPT_BASE_PROFILE_NAME"))
        tools.save(os.path.join(client_cache.profiles_path, base_profile_name),
                   base_profile_text)

    upload = os.getenv("CPT_UPLOAD_ENABLED", None)
    runner = CreateRunner(abs_profile_path, reference, conan_api, uploader,
                          args=args,
                          build_policy=build_policy, printer=printer, upload=upload)
    runner.run()
Esempio n. 2
0
def run():
    # Get all from environ
    conan_api, client_cache, _ = Conan.factory()
    printer = Printer()

    remotes_manager = RemotesManager(conan_api, printer)
    remotes_manager.add_remotes_to_conan()
    default_username = os.getenv("CONAN_USERNAME")
    auth_manager = AuthManager(conan_api, printer, default_username=default_username)

    upload_retry = os.getenv("CPT_UPLOAD_RETRY")
    upload_only_recipe = os.getenv("CPT_UPLOAD_ONLY_RECIPE")
    uploader = Uploader(conan_api, remotes_manager, auth_manager, printer, upload_retry)
    build_policy = unscape_env(os.getenv("CPT_BUILD_POLICY"))
    test_folder = unscape_env(os.getenv("CPT_TEST_FOLDER"))
    reference = ConanFileReference.loads(os.getenv("CONAN_REFERENCE"))

    profile_text = unscape_env(os.getenv("CPT_PROFILE"))
    abs_profile_path = save_profile_to_tmp(profile_text)
    base_profile_text = unscape_env(os.getenv("CPT_BASE_PROFILE"))
    config_url = unscape_env(os.getenv("CPT_CONFIG_URL"))
    upload_dependencies = unscape_env(os.getenv("CPT_UPLOAD_DEPENDENCIES"))
    conanfile = unscape_env(os.getenv("CPT_CONANFILE"))
    if base_profile_text:
        base_profile_name = unscape_env(os.getenv("CPT_BASE_PROFILE_NAME"))
        tools.save(os.path.join(client_cache.profiles_path, base_profile_name),
                   base_profile_text)

    upload = os.getenv("CPT_UPLOAD_ENABLED")
    runner = CreateRunner(abs_profile_path, reference, conan_api, uploader,
                          build_policy=build_policy, printer=printer, upload=upload,
                          upload_only_recipe=upload_only_recipe,
                          test_folder=test_folder, config_url=config_url,
                          upload_dependencies=upload_dependencies, conanfile=conanfile)
    runner.run()
Esempio n. 3
0
def run():
    conan_version = get_client_version()
    if conan_version < Version("1.18.0"):
        conan_api, client_cache, _ = Conan.factory()
    else:
        conan_api, _, _ = Conan.factory()
        conan_api.create_app()
        client_cache = conan_api.app.cache

    printer = Printer()

    remotes_manager = RemotesManager(conan_api, printer)
    remotes_manager.add_remotes_to_conan()
    default_username = os.getenv("CONAN_USERNAME")
    auth_manager = AuthManager(conan_api,
                               printer,
                               default_username=default_username)

    upload_retry = os.getenv("CPT_UPLOAD_RETRY")
    upload_only_recipe = os.getenv("CPT_UPLOAD_ONLY_RECIPE")
    upload_force = os.getenv("CPT_UPLOAD_FORCE")
    uploader = Uploader(conan_api, remotes_manager, auth_manager, printer,
                        upload_retry, upload_force)
    build_policy = unscape_env(os.getenv("CPT_BUILD_POLICY"))
    test_folder = unscape_env(os.getenv("CPT_TEST_FOLDER"))
    reference = ConanFileReference.loads(os.getenv("CONAN_REFERENCE"))

    profile_text = unscape_env(os.getenv("CPT_PROFILE"))
    abs_profile_path = save_profile_to_tmp(profile_text)
    base_profile_text = unscape_env(os.getenv("CPT_BASE_PROFILE"))
    config_url = unscape_env(os.getenv("CPT_CONFIG_URL"))
    config_args = unscape_env(os.getenv("CPT_CONFIG_ARGS"))
    upload_dependencies = unscape_env(os.getenv("CPT_UPLOAD_DEPENDENCIES"))
    update_dependencies = unscape_env(os.getenv("CPT_UPDATE_DEPENDENCIES"))
    conanfile = unscape_env(os.getenv("CPT_CONANFILE"))
    lockfile = unscape_env(os.getenv("CPT_LOCKFILE"))
    skip_recipe_export = unscape_env(os.getenv("CPT_SKIP_RECIPE_EXPORT"))
    if base_profile_text:
        base_profile_name = unscape_env(os.getenv("CPT_BASE_PROFILE_NAME"))
        tools.save(os.path.join(client_cache.profiles_path, base_profile_name),
                   base_profile_text)

    upload = os.getenv("CPT_UPLOAD_ENABLED")
    runner = CreateRunner(abs_profile_path,
                          reference,
                          conan_api,
                          uploader,
                          build_policy=build_policy,
                          printer=printer,
                          upload=upload,
                          upload_only_recipe=upload_only_recipe,
                          test_folder=test_folder,
                          config_url=config_url,
                          config_args=config_args,
                          upload_dependencies=upload_dependencies,
                          conanfile=conanfile,
                          skip_recipe_export=skip_recipe_export,
                          update_dependencies=update_dependencies,
                          lockfile=lockfile)
    runner.run()
Esempio n. 4
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)
        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
Esempio n. 5
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