diff --git a/rcds/cli/__main__.py b/rcds/cli/__main__.py index 24f1fbf..4849be4 100644 --- a/rcds/cli/__main__.py +++ b/rcds/cli/__main__.py @@ -1,6 +1,6 @@ import click -from .deploy import deploy +from .deploy import deploy, test @click.group() @@ -9,7 +9,7 @@ def cli(): cli.add_command(deploy) - +cli.add_command(test) if __name__ == "__main__": cli() diff --git a/rcds/cli/deploy.py b/rcds/cli/deploy.py index cea6d07..c456ce2 100644 --- a/rcds/cli/deploy.py +++ b/rcds/cli/deploy.py @@ -43,3 +43,29 @@ def deploy() -> None: project.scoreboard_backend.commit() else: click.echo("WARN: no scoreboard backend, skipping...") + +@click.command() +def test() -> None: + try: + project_config = find_files(["rcds"], SUPPORTED_EXTENSIONS, recurse=True)[ + "rcds" + ].parent + except KeyError: + click.echo("Could not find project root!") + exit(1) + click.echo(f"Loading project at {project_config}") + project = rcds.Project(project_config) + click.echo("Initializing backends") + project.load_backends() + click.echo("Loading challenges") + project.load_all_challenges() + for challenge in project.challenges.values(): + cm = rcds.challenge.docker.ContainerManager(challenge) + for container_name, container in cm.containers.items(): + click.echo(f"{challenge.config['id']}: checking container {container_name}") + if not container.is_built(): + click.echo( + f"{challenge.config['id']}: building container {container_name}" + f" ({container.get_full_tag()})" + ) + container.build() \ No newline at end of file