Example #1
0
def pipeline(config: Config) -> None:
    import germanium_docker.steps

    if "images" not in config:
        config = {"images": cast(ImagesDict, config)}

    config = cast(ConfigDict, config)

    if "push" not in config:
        config["push"] = True
    """
    Builds the docker images
    """
    adhesive.build(initial_data={"build": config})
Example #2
0

# Test labels picked from labels
@adhesive.usertask("Pick The Right Button")
def pick_right_button(context, ui) -> None:
    ui.add_default_button("button", title="Left", value="left")
    ui.add_default_button("button", title="Right", value="right")


@adhesive.task("Validate Right Button Was Pressed")
def validate_right_button(context) -> None:
    assert context.data.button == "right"


# Test labels picked from names
@adhesive.usertask("Pick The Middle Button")
def pick_middle_button(context, ui) -> None:
    ui.add_default_button("left", value=True)
    ui.add_default_button("middle", value=True)
    ui.add_default_button("right", value=True)


@adhesive.task("Validate Middle Button Was Pressed")
def validate_middle_button(context) -> None:
    assert not context.data.left
    assert context.data.middle
    assert not context.data.right


adhesive.build()
Example #3
0
        f"docker run -d -p {context.data.ssh_port}:22 rastasheep/ubuntu-sshd:18.04",
        capture_stdout=True,
    )

    context.data.container_id = container_id
    print("[OK] started server")


@adhesive.task("Task", lane="ssh", loop="items")
def run_ls_in_ssh(context):
    print(context.workspace)
    context.workspace.run(f"""
        whoami
        ls -la
    """)


@adhesive.task("Shutdown Server")
def shutdown_server(context):
    print("shutting down server...")
    context.workspace.run(f"docker rm -f {context.data.container_id}")
    print("[OK] server was shutdown")


# We need to create more than the number of available channels, to see if we leak
# channels with executions. Another limit is the amount of parallel connections.
# For that we configure the pool_size in the `.adhesive/config.yml` in this folder.
adhesive.build(initial_data={
    "items": range(40),
})
Example #4
0
import uuid
import adhesive


@adhesive.task("Basic loop", loop="data.loop_items")
def basic_loop(context):
    if not context.data.executions:
        context.data.executions = set()

    context.data.executions.add(str(uuid.uuid4()))


@adhesive.task("Not a loop")
def not_a_loop(context):
    if not context.data.executions:
        context.data.executions = set()

    context.data.executions.add(str(uuid.uuid4()))


result = adhesive.build(initial_data={"loop_items": []})

# the task after the loop should still execute
assert len(result.executions) == 1
Example #5
0
import unittest
import uuid

test = unittest.TestCase()


@adhesive.lane('custom')
def lane_custom(context):
    with noop.inside(context.workspace) as w:
        context.data.lane_executions.add(str(uuid.uuid4()))
        yield w


@adhesive.task('Task', lane="custom", loop="items")
def simple_task(context):
    context.data.task_executions.add(str(uuid.uuid4()))
    test.assertTrue(isinstance(context.workspace, noop.NoopWorkspace),
                    "The workspace should be the workspace from the lane")


data = adhesive.build(initial_data={
    "items": range(3),
    "task_executions": set(),
    "lane_executions": set(),
})

test.assertEqual(1, len(data.lane_executions),
                 "The lane should have only executed once")
test.assertEqual(3, len(data.task_executions),
                 "The tasks should have executed three times")
Example #6
0
import adhesive
import uuid


@adhesive.task("Basic loop", loop="data.loop_items")
def basic_loop(context):
    print(f"Running loop iteration {context.loop.index}")
    if not context.data.executions:
        context.data.executions = set()

    context.data.executions.add(str(uuid.uuid4()))


result = adhesive.build(initial_data={"loop_items": [1, 2, 3, 4, 5]})

assert len(result.executions) == 5