예제 #1
0
def trigger_action_callback(task_group_id,
                            task_id,
                            input,
                            callback,
                            parameters,
                            root,
                            test=False):
    """
    Trigger action callback with the given inputs. If `test` is true, then run
    the action callback in testing mode, without actually creating tasks.
    """
    graph_config = load_graph_config(root)
    graph_config.register()
    callbacks = _get_callbacks(graph_config)
    cb = callbacks.get(callback, None)
    if not cb:
        raise Exception("Unknown callback: {}. Known callbacks: {}".format(
            callback, ", ".join(callbacks)))

    if test:
        create.testing = True
        taskcluster.testing = True

    if not test:
        sanity_check_task_scope(callback, parameters, graph_config)

    cb(Parameters(**parameters), graph_config, input, task_group_id, task_id)
예제 #2
0
def config():
    graph_config = load_graph_config(os.path.join(GECKO, "taskcluster", "ci"))
    params = FakeParameters({
        "base_repository": "http://hg.example.com",
        "head_repository": "http://hg.example.com",
        "head_rev": "abcdef",
        "level": 1,
    })
    return TransformConfig("job_test",
                           here, {},
                           params, {},
                           graph_config,
                           write_artifacts=False)
예제 #3
0
    def try_config(self, worker_overrides, worker_suffixes, **kwargs):
        from gecko_taskgraph.config import load_graph_config
        from gecko_taskgraph.util.workertypes import get_worker_type

        overrides = {}
        if worker_overrides:
            for override in worker_overrides:
                alias, worker_pool = override.split("=", 1)
                if alias in overrides:
                    print(
                        "Can't override worker alias {alias} more than once. "
                        "Already set to use {previous}, but also asked to use {new}."
                        .format(alias=alias,
                                previous=overrides[alias],
                                new=worker_pool))
                    sys.exit(1)
                overrides[alias] = worker_pool

        if worker_suffixes:
            root = build.topsrcdir
            root = os.path.join(root, "taskcluster", "ci")
            graph_config = load_graph_config(root)
            for worker_suffix in worker_suffixes:
                alias, suffix = worker_suffix.split("=", 1)
                if alias in overrides:
                    print(
                        "Can't override worker alias {alias} more than once. "
                        "Already set to use {previous}, but also asked "
                        "to add suffix {suffix}.".format(
                            alias=alias,
                            previous=overrides[alias],
                            suffix=suffix))
                    sys.exit(1)
                provisioner, worker_type = get_worker_type(
                    graph_config,
                    alias,
                    level="1",
                    release_level="staging",
                )
                overrides[
                    alias] = "{provisioner}/{worker_type}{suffix}".format(
                        provisioner=provisioner,
                        worker_type=worker_type,
                        suffix=suffix)

        if overrides:
            return {"worker-overrides": overrides}
예제 #4
0
def test_action_callback(options):
    import gecko_taskgraph.parameters
    import gecko_taskgraph.actions
    from taskgraph.util import yaml
    from gecko_taskgraph.config import load_graph_config

    def load_data(filename):
        with open(filename) as f:
            if filename.endswith(".yml"):
                return yaml.load_stream(f)
            elif filename.endswith(".json"):
                return json.load(f)
            else:
                raise Exception(f"unknown filename {filename}")

    try:
        task_id = options["task_id"]

        if options["input"]:
            input = load_data(options["input"])
        else:
            input = None

        root = options["root"]
        graph_config = load_graph_config(root)
        trust_domain = graph_config["trust-domain"]
        graph_config.register()

        parameters = gecko_taskgraph.parameters.load_parameters_file(
            options["parameters"], strict=False, trust_domain=trust_domain
        )
        parameters.check()

        return gecko_taskgraph.actions.trigger_action_callback(
            task_group_id=options["task_group_id"],
            task_id=task_id,
            input=input,
            callback=options["callback"],
            parameters=parameters,
            root=root,
            test=True,
        )
    except Exception:
        traceback.print_exc()
        sys.exit(1)
예제 #5
0
def graph_config():
    return load_graph_config(os.path.join(GECKO, "taskcluster", "ci"))