示例#1
0
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()
示例#2
0
def test_loop(mock_upstream_remote_functionality, github_release_fedmsg):
    def mocked_iter_releases():
        msg = copy.deepcopy(github_release_fedmsg)
        yield msg["topic"], msg

    flexmock(Consumerino, iterate_releases=mocked_iter_releases)
    conf = get_test_config()
    api = PackitBotAPI(conf)
    api.watch_upstream_release()
示例#3
0
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"
示例#4
0
def test_loop(mock_remote_functionality_upstream, github_release_fedmsg):
    u, d = mock_remote_functionality_upstream

    def mocked_iter_releases():
        msg = copy.deepcopy(github_release_fedmsg)
        yield msg["topic"], msg

    flexmock(Repo).should_receive("clone_from").and_return(git.Repo(str(u)))
    flexmock(Consumerino, iterate_releases=mocked_iter_releases)
    conf = get_test_config()
    api = PackitBotAPI(conf)
    api.watch_upstream_release()
示例#5
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"
示例#6
0
def watch_pr(config, message_id):
    """
    Watch for activity on github and create/update a downstream PR

    :return: int, retcode
    """
    api = PackitBotAPI(config)
    if message_id:
        for msg_id in message_id:
            fedmsg_dict = api.consumerino.fetch_fedmsg_dict(msg_id)
            api.sync_upstream_pull_request_with_fedmsg(fedmsg_dict)
    else:
        api.watch_upstream_pull_request()
示例#7
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()