Beispiel #1
0
def start():
    env = os.environ
    input = Input(dict(env))  # pylint: disable=redefined-builtin
    task_params_file = env.get("INPUT_TASK_PARAMS_FILE")
    config = TaskConfig(task_params_file)
    config.set_repository(env["GITHUB_REPOSITORY"])
    config.set(
        **input.as_dict(),
        group=config.repository,
        startedBy=env.get("GITHUB_ACTOR", "UNKNOWN"),
    )
    config.task_count = int(env.get("INPUT_TASK_COUNT", 1))

    logger.info(
        f"Start task execution with definition '{config.task_definition}' on cluster '{config.cluster}'"
    )
    config.set_container_env({
        "GITHUB_PERSONAL_TOKEN": input["githubPat"],
        "GITHUB_OWNER": env["GITHUB_REPOSITORY_OWNER"],
        "GITHUB_REPOSITORY": config.repository,
        "RUNNER_NAME": env["GITHUB_JOB"],
    })
    config.set_capacity_provider(input.get("capacityProvider"))
    logger.info("Ready to execute with config:")
    logger.info(config.as_dict())

    task = Task(config)
    task.run()
    if input.should_wait:
        task.wait()
        newline = "\n"
        logger.info(
            f"The following tasks were launched: \n{newline.join(task.task_arns)}"
        )

    logger.info("Task(s) successfuly created.")
    logger.info(f"You can follow it on: {task.url}")
Beispiel #2
0
def test_empty_capacity_provider():
    config = TaskConfig()
    config.set_capacity_provider(None)
    assert "capacityProviderStrategy" not in config.as_dict()
Beispiel #3
0
def test_capacity_provider():
    config = TaskConfig()
    config.set_capacity_provider("abc")
    assert config.as_dict()["capacityProviderStrategy"][0]["capacityProvider"] == "abc"