def test_valid_config(self): manager = ConfigManager(self.api, Printer()) profiles = self.api.profile_list() self.assertEquals(len(profiles), 0) manager.install("https://github.com/bincrafters/bincrafters-config.git", "-b main") profiles = self.api.profile_list() self.assertGreater(len(profiles), 3)
def test_invalid_config(self): manager = ConfigManager(self.api, Printer()) profiles = self.api.profile_list() self.assertEquals(len(profiles), 0) try: manager.install("https://github.com/") self.fail("Could not accept wrong URL") except ConanException: pass
def run(self): client_version = get_client_version() if self._config_url: ConfigManager(self._conan_api, self.printer).install(url=self._config_url, args=self._config_args) context = tools.no_op() compiler = self.settings.get("compiler", None) if not self._exclude_vcvars_precommand: if compiler == "Visual Studio" and "compiler.version" in self.settings: compiler_set = namedtuple("compiler", "version")( self.settings["compiler.version"]) mock_sets = namedtuple( "mock_settings", "arch compiler get_safe")( self.settings["arch"], compiler_set, lambda x: self.settings.get(x, None)) context = tools.vcvars(mock_sets) with context: self.printer.print_rule() self.printer.print_profile(tools.load(self._profile_abs_path)) with self.printer.foldable_output("conan_create"): if client_version < Version("1.10.0"): name, version, user, channel = self._reference else: name, version, user, channel, _ = self._reference if self._build_policy: self._build_policy = [] if self._build_policy == "all" else [ self._build_policy ] # https://github.com/conan-io/conan-package-tools/issues/184 with tools.environment_append({"_CONAN_CREATE_COMMAND_": "1"}): params = { "name": name, "version": version, "user": user, "channel": channel, "build_modes": self._build_policy, "profile_name": self._profile_abs_path } self.printer.print_message("Calling 'conan create'") self.printer.print_dict(params) with tools.chdir(self._cwd): if Version(client_version) >= "1.8.0": from conans.errors import ConanInvalidConfiguration exc_class = ConanInvalidConfiguration else: exc_class = None try: if client_version < Version("1.12.0"): self._results = self._conan_api.create( self._conanfile, name=name, version=version, user=user, channel=channel, build_modes=self._build_policy, profile_name=self._profile_abs_path, test_folder=self._test_folder, not_export=self.skip_recipe_export, update=self._update_dependencies) else: self._results = self._conan_api.create( self._conanfile, name=name, version=version, user=user, channel=channel, build_modes=self._build_policy, profile_names=[self._profile_abs_path], test_folder=self._test_folder, not_export=self.skip_recipe_export, update=self._update_dependencies) except exc_class as e: self.printer.print_rule() self.printer.print_message( "Skipped configuration by the recipe: " "%s" % str(e)) self.printer.print_rule() return for installed in self._results['installed']: reference = installed["recipe"]["id"] if client_version >= Version("1.10.0"): reference = ConanFileReference.loads(reference) reference = str(reference.copy_clear_rev()) if ((reference == str(self._reference)) or \ (reference in self._upload_dependencies) or \ ("all" in self._upload_dependencies)) and \ installed['packages']: package_id = installed['packages'][0]['id'] if installed['packages'][0]["built"]: if "@" not in reference: reference += "@" if self._upload_only_recipe: self._uploader.upload_recipe( reference, self._upload) else: self._uploader.upload_packages( reference, self._upload, package_id) else: self.printer.print_message( "Skipping upload for %s, " "it hasn't been built" % package_id)
def test_valid_config_with_args(self): manager = ConfigManager(self.conan_api, Printer()) manager.install('https://github.com/bincrafters/conan-config.git', '-b master')
def test_valid_config(self): manager = ConfigManager(self.conan_api, Printer()) manager.install('https://github.com/bincrafters/bincrafters-config.git')
def run_builds(self, curpage=None, total_pages=None, base_profile_name=None, base_profile_build_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 base_profile_build_name = base_profile_build_name or os.getenv( "CONAN_BASE_PROFILE_BUILD") if base_profile_build_name is not None: if get_client_version() < Version("1.24.0"): raise Exception("Conan Profile Build requires >= 1.24") self.printer.print_message( "**************************************************") self.printer.print_message("Using specified " "build profile: %s" % base_profile_build_name) self.printer.print_message( "**************************************************") # 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( "**************************************************") if self.config_url: ConfigManager(self.conan_api, self.printer).install(url=self.config_url, args=self.config_args) profile_text, base_profile_text = get_profiles( self.client_cache, build, base_profile_name) _, base_profile_build_text = get_profiles(self.client_cache, build, base_profile_build_name) if not self.use_docker: profile_abs_path = save_profile_to_tmp(profile_text) if base_profile_build_text: profile_build_abs_path = save_profile_to_tmp( base_profile_build_text) else: profile_build_abs_path = None 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, profile_build_abs_path=profile_build_abs_path) 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, upload_force=self.upload_force, 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, profile_build_text=base_profile_build_text, cwd=self.cwd) 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