diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index face7d79..ec602b88 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -31,6 +31,11 @@ jobs: "3.9", "3.14", ] + include: + - os: "macos-latest" + python-version: "3.14" + - os: "windows-latest" + python-version: "3.14" env: OS: ${{ matrix.os }} @@ -52,6 +57,15 @@ jobs: - name: Acquire sources uses: actions/checkout@v6 + - name: Set up Docker + uses: docker-practice/actions-setup-docker@master + timeout-minutes: 12 + + - name: Probe Docker + run: | + docker version + docker run --rm hello-world + - name: Install uv uses: astral-sh/setup-uv@v7 with: diff --git a/cratedb_toolkit/testing/testcontainers/cratedb.py b/cratedb_toolkit/testing/testcontainers/cratedb.py index b78eea3a..fc3debcf 100644 --- a/cratedb_toolkit/testing/testcontainers/cratedb.py +++ b/cratedb_toolkit/testing/testcontainers/cratedb.py @@ -20,6 +20,7 @@ from typing import Optional from testcontainers.core.config import MAX_TRIES +from testcontainers.core.docker_client import DockerClient from testcontainers.core.generic import DbContainer from testcontainers.core.wait_strategies import LogMessageWaitStrategy from testcontainers.core.waiting_utils import wait_for_logs @@ -133,6 +134,12 @@ def _configure(self) -> None: self._configure_credentials() self._configure_wait_condition() + """ + if "CI" in os.environ: + docker_host = get_docker_host() + self.with_env("DOCKER_HOST", docker_host).with_env("DOCKER_CERT_PATH", "").with_env("DOCKER_TLS_VERIFY", "") + """ + def get_connection_url(self, dialect: str = "crate", host: Optional[str] = None) -> str: """ Return a connection URL to the DB @@ -220,3 +227,27 @@ def http_url(self): Used to stay backward compatible with the downstream code. """ return self.get_http_url() + + +def get_docker_host(): + """ + https://github.com/testcontainers/testcontainers-python/blob/main/core/tests/test_docker_in_docker.py + """ + # real dind isn't possible (AFAIK) in CI + # forwarding the socket to a container port is at least somewhat the same + client = DockerClient() + not_really_dind = client.run( + image="alpine/socat", + command="tcp-listen:2375,fork,reuseaddr unix-connect:/var/run/docker.sock", + volumes={"/var/run/docker.sock": {"bind": "/var/run/docker.sock"}}, + detach=True, + ) + + not_really_dind.start() + + # get ip address for DOCKER_HOST + # avoiding DockerContainer class here to prevent code changes affecting the test + specs = client.get_container(not_really_dind.id) + docker_host_ip = specs["NetworkSettings"]["Networks"]["bridge"]["IPAddress"] + docker_host = f"tcp://{docker_host_ip}:2375" + return docker_host