feat(ebook-search): add containerized test environment
treefmt / nix fmt (pull_request) Successful in 5s
pytest / pytest (pull_request) Successful in 26s
build_systems / build-brain (pull_request) Successful in 45s
build_systems / build-bob (pull_request) Successful in 45s
build_systems / build-rhapsody-in-green (pull_request) Successful in 57s
build_systems / build-jeeves (pull_request) Successful in 2m17s
test ebook search / test-ebook-search (pull_request) Failing after 4s
treefmt / nix fmt (pull_request) Successful in 5s
pytest / pytest (pull_request) Successful in 26s
build_systems / build-brain (pull_request) Successful in 45s
build_systems / build-bob (pull_request) Successful in 45s
build_systems / build-rhapsody-in-green (pull_request) Successful in 57s
build_systems / build-jeeves (pull_request) Successful in 2m17s
test ebook search / test-ebook-search (pull_request) Failing after 4s
This commit is contained in:
@@ -73,6 +73,23 @@ def build_image() -> None:
|
||||
raise RuntimeError(msg)
|
||||
|
||||
|
||||
def build_test_image() -> None:
|
||||
"""Build the ebook search test Docker image."""
|
||||
dockerfile = Path(__file__).resolve().with_name("Dockerfile")
|
||||
result = docker_run(["build", "--file", str(dockerfile), "--target", "test", "--tag", "ebook-search:test", "."])
|
||||
if result.returncode != 0:
|
||||
msg = "Failed to build ebook search test image"
|
||||
raise RuntimeError(msg)
|
||||
|
||||
|
||||
def run_test_image() -> None:
|
||||
"""Run the ebook search test suite inside Docker."""
|
||||
result = docker_run(["run", "--rm", "ebook-search:test"])
|
||||
if result.returncode != 0:
|
||||
msg = f"Ebook search tests failed with code {result.returncode}"
|
||||
raise RuntimeError(msg)
|
||||
|
||||
|
||||
def start_stack(
|
||||
*,
|
||||
library_path: Path | None = None,
|
||||
@@ -210,6 +227,19 @@ def logs(
|
||||
typer.echo(output)
|
||||
|
||||
|
||||
@app.command("test")
|
||||
def run_tests(
|
||||
*,
|
||||
build: Annotated[bool, typer.Option("--build/--no-build", help="Build the test image before running.")] = True,
|
||||
log_level: Annotated[str, typer.Option(help="Log level.")] = "INFO",
|
||||
) -> None:
|
||||
"""Run ebook search tests inside the Docker test image."""
|
||||
configure_logger(log_level)
|
||||
if build:
|
||||
build_test_image()
|
||||
run_test_image()
|
||||
|
||||
|
||||
@app.command("ps")
|
||||
def ps() -> None:
|
||||
"""Show ebook search container status."""
|
||||
|
||||
Reference in New Issue
Block a user