From e6a3fa32489247229c5da39e11b470027c26c2d5 Mon Sep 17 00:00:00 2001 From: Oleg Nenashev Date: Tue, 6 Oct 2026 07:08:27 +0000 Subject: [PATCH] Streamline Dev Container, allow running Docker tests from there --- .devcontainer/Dockerfile | 2 +- .devcontainer/devcontainer-lock.json | 9 +++++++++ .devcontainer/devcontainer.json | 8 +++++++- docs/CONTRIBUTING.md | 13 +++++++++++++ run_tests.sh | 9 ++++++++- 5 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 .devcontainer/devcontainer-lock.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 6f26ecc..5658293 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -12,4 +12,4 @@ RUN apt-get update \ WORKDIR /workspaces/python-wiremock COPY pyproject.toml uv.lock ./ ENV UV_PROJECT_ENVIRONMENT=/usr/local -RUN uv sync --frozen \ No newline at end of file +RUN uv sync --frozen --extra testing diff --git a/.devcontainer/devcontainer-lock.json b/.devcontainer/devcontainer-lock.json new file mode 100644 index 0000000..c0667e2 --- /dev/null +++ b/.devcontainer/devcontainer-lock.json @@ -0,0 +1,9 @@ +{ + "features": { + "ghcr.io/devcontainers/features/docker-in-docker:4.1.2": { + "version": "4.1.2", + "resolved": "ghcr.io/devcontainers/features/docker-in-docker@sha256:ad3d6d36d95ee7f880f61f98862257f3e70253d3faef09f86af42fb87ee60429", + "integrity": "sha256:ad3d6d36d95ee7f880f61f98862257f3e70253d3faef09f86af42fb87ee60429" + } + } +} diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 270fb99..8579e0e 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -4,6 +4,12 @@ "dockerfile": "Dockerfile", "context": ".." }, + "features": { + "ghcr.io/devcontainers/features/docker-in-docker:4.1.2": { + "version": "latest", + "moby": false + } + }, "overrideCommand": true, "customizations": { "vscode": { @@ -13,4 +19,4 @@ ] } } -} +} \ No newline at end of file diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 6687e32..a760836 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -46,6 +46,18 @@ file in the directory. When adding new examples, make sure to update the [documentation site page](./examples.md) too. +## Testing + +To run tests in the Dev Container, just invoke the test scripts in the root directory: + +```shell +sh run_tests.sh +``` + +For local developer environments, you may also need to run `uv sync --extra testing` +to get all the test modules installed. + + ## Working on Documentation The documentation is powered by [MkDocs](https://www.mkdocs.org/) and [ReadTheDocs](https://readthedocs.org/). @@ -53,6 +65,7 @@ All the necessary dependencies are included into the pyproject definition. To build the docs locally: ```bash +cd docs uv run mkdocs build --site-dir=html ``` diff --git a/run_tests.sh b/run_tests.sh index 6c47a6c..b56d870 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -1,4 +1,11 @@ #!/bin/sh rm -Rf build/ dist/ wiremock.egg-info coverage/ wiremock/tests/coverage/ html/ || true -uv run pytest --cov=wiremock --tb=short +# Container tests need a Docker daemon. +if docker info >/dev/null 2>&1; then + set -- +else + echo "Docker not available, skipping tests/test_containers.py" + set -- --ignore=tests/test_containers.py +fi +uv run pytest tests/ --cov=wiremock --tb=short "$@"