def test_cancel_windows(self): docker_host = os.environ.get("WINDOWS_DOCKER_HOST", "") parameters = get_build_parameters("windows-debug") parameters["path"] = "packages/deadlock/conanfile.py" with environment("DOCKER_HOST", docker_host), Builder("Windows", "uboot/msvc15:latest") as builder: canceller = cancel_build(builder, 3) builder.pull(parameters) builder.setup(parameters) builder.run() canceller.join()
def test_cancel_linux(self): docker_host = os.environ.get("LINUX_DOCKER_HOST", "") parameters = get_build_parameters("linux-debug") parameters["path"] = "packages/deadlock/conanfile.py" with environment("DOCKER_HOST", docker_host), Builder("Linux", "uboot/gcc9:latest") as builder: canceller = cancel_build(builder, 3) builder.pull(parameters) builder.setup(parameters) builder.run() canceller.join()
def test_run_linux_https(self): docker_host = os.environ.get("LINUX_DOCKER_HOST", "") parameters = get_build_parameters("linux-debug", https=True) with environment("DOCKER_HOST", docker_host), Builder("Linux", "uboot/gcc9:latest") as builder: builder.pull(parameters) builder.setup(parameters) builder.run() logs = [line for line in builder.get_log_lines()] self.assertGreater(len(logs), 0) self.assertTrue("create" in builder.build_output.keys()) self.assertTrue("info" in builder.build_output.keys())
def test_run_windows(self): docker_host = os.environ.get("WINDOWS_DOCKER_HOST", "") parameters = get_build_parameters("windows-debug") with environment("DOCKER_HOST", docker_host), Builder("Windows", "uboot/msvc15:latest") as builder: builder.pull(parameters) builder.setup(parameters) builder.run() logs = [line for line in builder.get_log_lines()] self.assertGreater(len(logs), 0) self.assertTrue("create" in builder.build_output.keys()) self.assertTrue("info" in builder.build_output.keys())
async def __process_builds(self): # database.populate_database() # return logger.info("Start processing builds") platform = database.Platform.linux if sonja_os == "Linux" else database.Platform.windows with database.session_scope() as session: build = session\ .query(database.Build)\ .join(database.Build.profile)\ .filter(database.Profile.platform == platform,\ database.Build.status == database.BuildStatus.new)\ .populate_existing()\ .with_for_update(skip_locked=True, of=database.Build)\ .first() if not build: logger.info("Stop processing builds with *no* builds processed") return False logger.info("Set status of build '%d' to 'active'", build.id) self.__build_id = build.id build.status = database.BuildStatus.active build.log.logs = '' container = build.profile.container parameters = { "conan_config_url": build.profile.ecosystem.conan_config_url, "conan_config_path": build.profile.ecosystem.conan_config_path, "conan_config_branch": build.profile.ecosystem.conan_config_branch, "conan_remote": build.profile.ecosystem.conan_remote, "conan_user": build.profile.ecosystem.conan_user, "conan_password": build.profile.ecosystem.conan_password, "conan_profile": build.profile.conan_profile, "conan_options": " ".join(["-o {0}={1}".format(option.key, option.value) for option in build.commit.repo.options]), "git_url": build.commit.repo.url, "git_sha": build.commit.sha, "git_credentials": [ { "url": c.url, "username": c.username, "password": c.password } for c in build.profile.ecosystem.credentials ], "sonja_user": build.profile.ecosystem.user, "channel": build.commit.channel.conan_channel, "path": "./{0}/{1}".format(build.commit.repo.path, "conanfile.py") if build.commit.repo.path != "" else "./conanfile.py", "ssh_key": build.profile.ecosystem.ssh_key, "known_hosts": build.profile.ecosystem.known_hosts, "docker_user": build.profile.docker_user, "docker_password": build.profile.docker_password, "mtu": os.environ.get("SONJA_MTU", "1500") } try: with Builder(sonja_os, container) as builder: builder_task = asyncio.create_task(_run_build(builder, parameters)) while True: # wait 10 seconds done, _ = await asyncio.wait({builder_task}, timeout=10) self.__update_logs(builder) # if finished exit if done: builder_task.result() break # check if the build was stopped and cancel it # if necessary if self.__cancel_stopping_build(builder): return True logger.info("Process build output") result = manager.process_success(self.__build_id, builder.build_output) if result.get("new_builds", False): self.__trigger_scheduler() logger.info("Set status of build '%d' to 'success'", self.__build_id) self.__set_build_status(database.BuildStatus.success) self.__build_id = None except Exception as e: logger.info(e) manager.process_failure(self.__build_id, builder.build_output) logger.info("Set status of build '%d' to 'error'", self.__build_id) self.__set_build_status(database.BuildStatus.error) self.__build_id = None return True