def github_release(): msg = request.get_json() buffer = StringIO() logHandler = logging.StreamHandler(buffer) logHandler.setLevel(logging.INFO) formatter = logging.Formatter( "%(asctime)s - %(name)s - %(levelname)s - %(message)s" ) logHandler.setFormatter(formatter) logger.addHandler(logHandler) logger.debug( f"Received release event: " f"{msg['repository']['owner']}/{msg['repository']['name']} - {msg['release']['tag_name']}" ) config = Config() api = PackitBotAPI(config) # Using fedmsg since the fields are the same api.sync_upstream_release_with_fedmsg({"msg": msg}) logger.removeHandler(logHandler) buffer.flush() return buffer.getvalue()
def test_single_message(github_release_fedmsg, mock_upstream_remote_functionality): u, d = mock_upstream_remote_functionality conf = get_test_config() api = PackitBotAPI(conf) api.sync_upstream_release_with_fedmsg(github_release_fedmsg) assert (d / TARBALL_NAME).is_file() spec = SpecFile(str(d / "beer.spec"), None) assert spec.get_version() == "0.1.0"
def test_single_message(github_release_fedmsg, mock_remote_functionality_upstream): u, d = mock_remote_functionality_upstream conf = get_test_config() api = PackitBotAPI(conf) flexmock(Repo).should_receive("clone_from").and_return(git.Repo(str(u))) api.sync_upstream_release_with_fedmsg(github_release_fedmsg) assert (d / TARBALL_NAME).is_file() spec = get_specfile(str(d / "beer.spec")) assert spec.get_version() == "0.1.0"
def watch_releases(config, message_id): """ watch for activity on github and for every new upstream release, create a downstream pull request if MESSAGE-ID is specified, process only the selected fedmsg """ api = PackitBotAPI(config) if message_id: for msg_id in message_id: fedmsg_dict = api.consumerino.fetch_fedmsg_dict(msg_id) api.sync_upstream_release_with_fedmsg(fedmsg_dict) else: api.watch_upstream_release()