Ejemplo n.º 1
0
def create_tc_task(event, task, taskgroup_id, depends_on_ids, env_extra=None):
    command = build_full_command(event, task)
    task_id = taskcluster.slugId()
    task_data = {
        "taskGroupId": taskgroup_id,
        "created": taskcluster.fromNowJSON(""),
        "deadline": taskcluster.fromNowJSON(task["deadline"]),
        "provisionerId": task["provisionerId"],
        "schedulerId": task["schedulerId"],
        "workerType": task["workerType"],
        "metadata": {
            "name": task["name"],
            "description": task.get("description", ""),
            "owner": get_owner(event),
            "source": event["repository"]["clone_url"]
        },
        "payload": {
            "artifacts": task.get("artifacts"),
            "command": command,
            "image": task.get("image"),
            "maxRunTime": task.get("maxRunTime"),
            "env": task.get("env", {}),
        },
        "extra": {
            "github_event": json.dumps(event)
        }
    }
    if env_extra:
        task_data["payload"]["env"].update(env_extra)
    if depends_on_ids:
        task_data["dependencies"] = depends_on_ids
        task_data["requires"] = "all-completed"
    return task_id, task_data
Ejemplo n.º 2
0
def test_try_push_expiration(git_gecko, git_wpt, pull_request, set_pr_status,
                             MockTryCls, hg_gecko_try):
    pr = pull_request([("Test commit", {
        "README": "Example change\n"
    })], "Test PR")
    today = datetime.today().date()
    downstream.new_wpt_pr(git_gecko, git_wpt, pr)
    sync = set_pr_status(pr, "success")
    try_push = sync.latest_valid_try_push
    created_date = datetime.strptime(try_push.created, tc._DATE_FMT)
    assert today == created_date.date()
    assert not try_push.expired()
    try_push.created = taskcluster.fromNowJSON("-15 days")
    assert try_push.expired()
    try_push.created = None
    with patch("sync.trypush.tc.get_task",
               return_value={"created": taskcluster.fromNowJSON("-5 days")}):
        assert not try_push.expired()
Ejemplo n.º 3
0
    def create(cls, lock, sync, affected_tests=None, stability=False, hacks=True,
               try_cls=TryFuzzyCommit, rebuild_count=None, check_open=True, **kwargs):
        logger.info("Creating try push for PR %s" % sync.pr)
        if check_open and not tree.is_open("try"):
            logger.info("try is closed")
            raise RetryableError(AbortError("Try is closed"))

        # Ensure the required indexes exist
        TaskGroupIndex.get_or_create(sync.git_gecko)
        try_idx = TryCommitIndex.get_or_create(sync.git_gecko)

        git_work = sync.gecko_worktree.get()

        if rebuild_count is None:
            rebuild_count = 0 if not stability else env.config['gecko']['try']['stability_count']
            if not isinstance(rebuild_count, (int, long)):
                logger.error("Could not find config for Stability rebuild count, using default 5")
                rebuild_count = 5
        with try_cls(sync.git_gecko, git_work, affected_tests, rebuild_count, hacks=hacks,
                     **kwargs) as c:
            try_rev = c.push()

        data = {
            "try-rev": try_rev,
            "stability": stability,
            "gecko-head": sync.gecko_commits.head.sha1,
            "wpt-head": sync.wpt_commits.head.sha1,
            "status": "open",
            "bug": sync.bug,
        }
        process_name = base.ProcessName.with_seq_id(sync.git_gecko,
                                                    cls.obj_type,
                                                    sync.sync_type,
                                                    getattr(sync, sync.obj_id))
        rv = super(TryPush, cls).create(lock, sync.git_gecko, process_name, data)
        # Add to the index
        if try_rev:
            try_idx.insert(try_idx.make_key(try_rev), process_name)

        with rv.as_mut(lock):
            rv.created = taskcluster.fromNowJSON("0 days")

        env.bz.comment(sync.bug,
                       "Pushed to try%s %s" %
                       (" (stability)" if stability else "",
                        rv.treeherder_url))

        return rv
Ejemplo n.º 4
0
    def create(cls,
               sync,
               affected_tests=None,
               stability=False,
               hacks=True,
               try_cls=TrySyntaxCommit,
               rebuild_count=None,
               check_open=True,
               **kwargs):
        logger.info("Creating try push for PR %s" % sync.pr)
        if check_open and not tree.is_open("try"):
            logger.info("try is closed")
            raise RetryableError(AbortError("Try is closed"))

        git_work = sync.gecko_worktree.get()

        if rebuild_count is None:
            rebuild_count = 0 if not stability else 10
        with try_cls(sync.git_gecko,
                     git_work,
                     affected_tests,
                     rebuild_count,
                     hacks=hacks,
                     **kwargs) as c:
            try_rev = c.push()

        data = {
            "try-rev": try_rev,
            "stability": stability,
            "gecko-head": sync.gecko_commits.head.sha1,
            "wpt-head": sync.wpt_commits.head.sha1,
        }
        process_name = base.ProcessName.with_seq_id(sync.git_gecko, "syncs",
                                                    cls.obj_type,
                                                    sync.sync_type, "open",
                                                    getattr(sync, sync.obj_id))
        rv = super(TryPush, cls).create(sync.git_gecko, process_name, data)
        rv.created = taskcluster.fromNowJSON("0 days")

        env.bz.comment(
            sync.bug, "Pushed to try%s %s" %
            (" (stability)" if stability else "", cls.treeherder_url(try_rev)))

        return rv