Beispiel #1
0
    async def get_config(
        self, pull_number: github_types.GitHubPullRequestNumber
    ) -> queue.PullQueueConfig:
        """Return merge config for a pull request.

        Do not use it for logic, just for displaying the queue summary.

        :param pull_number: The pull request number.
        """
        config_str = await self.repository.installation.redis.get(
            self._config_redis_queue_key(pull_number)
        )
        if config_str is None:
            self.log.error(
                "pull request queued without associated configuration",
                gh_pull=pull_number,
            )
            return queue.PullQueueConfig(
                {
                    "strict_method": "merge",
                    "priority": 2000,
                    "effective_priority": 2000,
                    "bot_account": None,
                    "update_bot_account": None,
                    "name": rules.QueueName(""),
                    "queue_config": rules.QueueConfig(
                        {"priority": 1, "speculative_checks": 1}
                    ),
                }
            )
        config: queue.PullQueueConfig = json.loads(config_str)
        return config
Beispiel #2
0
def test_embarked_pull_old_serialization() -> None:
    queue_config = rules.QueueConfig(
        priority=0,
        speculative_checks=5,
        batch_size=1,
        batch_max_wait_time=datetime.timedelta(seconds=0),
        allow_inplace_checks=True,
        disallow_checks_interruption_from_queues=[],
        checks_timeout=None,
        draft_bot_account=None,
    )
    config = queue.PullQueueConfig(
        name=rules.QueueName("foo"),
        strict_method="merge",
        update_method="merge",
        priority=0,
        effective_priority=0,
        bot_account=None,
        update_bot_account=None,
        queue_config=queue_config,
    )

    now = date.utcnow()
    old_typed = merge_train.EmbarkedPull.OldSerialized(
        github_types.GitHubPullRequestNumber(1234), config, now
    )
    old_untyped = json.loads(json.dumps(old_typed))
    ep = merge_train.EmbarkedPull.deserialize(mock.Mock(), old_untyped)
    assert ep.user_pull_request_number == 1234
    assert ep.config == config
    assert ep.queued_at == now
Beispiel #3
0
def get_config(queue_name: str, priority: int = 100) -> queue.PullQueueConfig:
    effective_priority = typing.cast(
        int,
        priority
        + QUEUE_RULES[queue_name].config["priority"] * queue.QUEUE_PRIORITY_OFFSET,
    )
    return queue.PullQueueConfig(
        name=rules.QueueName(queue_name),
        strict_method="merge",
        update_method="merge",
        priority=priority,
        effective_priority=effective_priority,
        bot_account=None,
        update_bot_account=None,
        queue_config=QUEUE_RULES[queue_name].config,
    )