From 5d120ddb0e54f3045016011441f18350b739861a Mon Sep 17 00:00:00 2001 From: Rodrigue Geis Date: Wed, 7 Jan 2026 15:56:24 +0100 Subject: [PATCH 1/4] tests: basic support for podman with testcontainers --- test.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/test.sh b/test.sh index 6990141..b4cfccd 100755 --- a/test.sh +++ b/test.sh @@ -1,18 +1,56 @@ #!/usr/bin/env sh +# Run all tests for simpleblob. +# The arguments passed to this script will be passed to the `go test` command. +# +# Note that the tests rely on testcontainers. +# In case no Docker daemon is present, we fallback to Podman. +# Using Podman can be forced by setting the SB_TESTS_FORCE_PODMAN to a non-empty value. +set -e -set -ex +# Default to Docker but use Podman if required. +if [ "$SB_TESTS_FORCE_PODMAN" ] || { [ -z "$DOCKER_HOST" ] && [ ! -e "/var/run/docker.sock" ]; }; then + # See https://podman-desktop.io/tutorial/testcontainers-with-podman#setup-testcontainers-with-podman + if ! command -v podman >/dev/null; then + echo "Neither Podman CLI or a Docker daemon were found." + exit 1 + fi + case "$(uname -s)" in + Linux) + DOCKER_HOST="unix://${XDG_RUNTIME_DIR:-/run/user/$(id --user)}/podman/podman.sock" + ;; + Darwin) + DOCKER_HOST="unix://$(podman machine inspect --format '{{.ConnectionInfo.PodmanSocket.Path}}')" + ;; + *) + echo "$(uname -s) is not supported." + exit 1 + ;; + esac + if [ ! -e "${DOCKER_HOST#unix://}" ]; then + echo "Podman does not seem to be ready to accept connections." + echo "Please ensure you have started a Podman machine or system service." + # On macOS, this is most likely to be `podman machine start`. + # On Linux, you may have a service available, or you can run `podman system service --time=0`. + exit 1 + fi + # TESTCONTAINERS_RYUK_DISABLED improves stability because the Ryuk container, + # used for cleanup, does not always work with Podman. + export TESTCONTAINERS_RYUK_DISABLED=true + export DOCKER_HOST +fi +echo 'Running tests' go test -count=1 "$@" ./... -# Run linters -# Configure linters in .golangci.yml +echo +echo 'Running linters' expected_version=2.4.0 -expected_version_full=v"$expected_version" golangci_lint_bin=./bin/golangci-lint if ! "$golangci_lint_bin" version | grep -wq "version $expected_version"; then # This is the recommended installation process. # The installer downloads to ./bin/ by default. # see https://golangci-lint.run/usage/install/ - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s "$expected_version_full" + echo "Downloading golangci-lint v$expected_version to ./bin/" + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v"$expected_version" fi -"$golangci_lint_bin" run +exec "$golangci_lint_bin" run From 03ba32fc0d6f408525d54dd3d644fb451a942f0e Mon Sep 17 00:00:00 2001 From: Rodrigue Geis Date: Wed, 7 Jan 2026 17:05:33 +0100 Subject: [PATCH 2/4] more robust way to find the docker endpoint if any --- test.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/test.sh b/test.sh index b4cfccd..d07edbe 100755 --- a/test.sh +++ b/test.sh @@ -3,12 +3,19 @@ # The arguments passed to this script will be passed to the `go test` command. # # Note that the tests rely on testcontainers. -# In case no Docker daemon is present, we fallback to Podman. +# In case no Docker daemon is configured, we fallback to Podman. # Using Podman can be forced by setting the SB_TESTS_FORCE_PODMAN to a non-empty value. set -e -# Default to Docker but use Podman if required. -if [ "$SB_TESTS_FORCE_PODMAN" ] || { [ -z "$DOCKER_HOST" ] && [ ! -e "/var/run/docker.sock" ]; }; then +# Default to Docker but use Podman if any of those is true: +# - DOCKER_HOST is not set. +# - the `docker` command does not exist. +# - the Docker daemon is not running. +# - SB_TESTS_FORCE_PODMAN is not empty. +if [ -z "${SB_TESTS_FORCE_PODMAN}${DOCKER_HOST}" ] && command -v docker >/dev/null; then + docker_endpoint="$(docker context ls --format '{{if .Current}}{{.DockerEndpoint}}{{end}}' 2>/dev/null || true)" +fi +if [ "$SB_TESTS_FORCE_PODMAN" ] || [ -z "${DOCKER_HOST}${docker_endpoint}" ]; then # See https://podman-desktop.io/tutorial/testcontainers-with-podman#setup-testcontainers-with-podman if ! command -v podman >/dev/null; then echo "Neither Podman CLI or a Docker daemon were found." From b2ac5ee70c21a5b67bb6b4442b469e86609bd3ee Mon Sep 17 00:00:00 2001 From: Rodrigue Geis Date: Thu, 8 Jan 2026 11:53:06 +0100 Subject: [PATCH 3/4] simplify comment --- test.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/test.sh b/test.sh index d07edbe..1acd067 100755 --- a/test.sh +++ b/test.sh @@ -7,11 +7,7 @@ # Using Podman can be forced by setting the SB_TESTS_FORCE_PODMAN to a non-empty value. set -e -# Default to Docker but use Podman if any of those is true: -# - DOCKER_HOST is not set. -# - the `docker` command does not exist. -# - the Docker daemon is not running. -# - SB_TESTS_FORCE_PODMAN is not empty. +# Use Podman if no Docker endpoint is defined or found, or if SB_TESTS_FORCE_PODMAN is not empty. if [ -z "${SB_TESTS_FORCE_PODMAN}${DOCKER_HOST}" ] && command -v docker >/dev/null; then docker_endpoint="$(docker context ls --format '{{if .Current}}{{.DockerEndpoint}}{{end}}' 2>/dev/null || true)" fi From 0dde6031d53fa53b4f9490b19af2bedf99a689d3 Mon Sep 17 00:00:00 2001 From: Rodrigue Geis Date: Tue, 3 Feb 2026 16:06:30 +0100 Subject: [PATCH 4/4] make podman the default --- test.sh | 49 +++++++++++++++++++------------------------------ 1 file changed, 19 insertions(+), 30 deletions(-) diff --git a/test.sh b/test.sh index 1acd067..d8ef28a 100755 --- a/test.sh +++ b/test.sh @@ -3,43 +3,32 @@ # The arguments passed to this script will be passed to the `go test` command. # # Note that the tests rely on testcontainers. -# In case no Docker daemon is configured, we fallback to Podman. -# Using Podman can be forced by setting the SB_TESTS_FORCE_PODMAN to a non-empty value. -set -e +# In case Podman is available, it is used. +# You can bypass Podman or force the use of a specific backend by setting DOCKER_HOST, +# with a command such as: +# docker context ls --format '{{if .Current}}{{.DockerEndpoint}}{{end}}' +set -eu -# Use Podman if no Docker endpoint is defined or found, or if SB_TESTS_FORCE_PODMAN is not empty. -if [ -z "${SB_TESTS_FORCE_PODMAN}${DOCKER_HOST}" ] && command -v docker >/dev/null; then - docker_endpoint="$(docker context ls --format '{{if .Current}}{{.DockerEndpoint}}{{end}}' 2>/dev/null || true)" -fi -if [ "$SB_TESTS_FORCE_PODMAN" ] || [ -z "${DOCKER_HOST}${docker_endpoint}" ]; then +# Try to use Podman by default. +if [ -n "${DOCKER_HOST:-}" ]; then + printf 'DOCKER_HOST is set in environment, %s will be used.\n' "$DOCKER_HOST" +elif command -v podman >/dev/null; then # See https://podman-desktop.io/tutorial/testcontainers-with-podman#setup-testcontainers-with-podman - if ! command -v podman >/dev/null; then - echo "Neither Podman CLI or a Docker daemon were found." - exit 1 - fi - case "$(uname -s)" in - Linux) - DOCKER_HOST="unix://${XDG_RUNTIME_DIR:-/run/user/$(id --user)}/podman/podman.sock" + kernel_name="$(uname -s)" + case "$kernel_name" in + Linux) socket_path="${XDG_RUNTIME_DIR:-/run/user/$(id --user)}/podman/podman.sock" ;; - Darwin) - DOCKER_HOST="unix://$(podman machine inspect --format '{{.ConnectionInfo.PodmanSocket.Path}}')" + Darwin) socket_path="$(podman machine inspect --format '{{.ConnectionInfo.PodmanSocket.Path}}')" ;; - *) - echo "$(uname -s) is not supported." - exit 1 + *) printf '%s is not supported.\n' "$kernel_name"; exit 1 ;; esac - if [ ! -e "${DOCKER_HOST#unix://}" ]; then - echo "Podman does not seem to be ready to accept connections." - echo "Please ensure you have started a Podman machine or system service." - # On macOS, this is most likely to be `podman machine start`. - # On Linux, you may have a service available, or you can run `podman system service --time=0`. - exit 1 + if [ -e "$socket_path" ]; then + export DOCKER_HOST="unix://${socket_path}" + # TESTCONTAINERS_RYUK_DISABLED improves stability because the Ryuk container, + # used for cleanup, does not always work with Podman. + export TESTCONTAINERS_RYUK_DISABLED=true fi - # TESTCONTAINERS_RYUK_DISABLED improves stability because the Ryuk container, - # used for cleanup, does not always work with Podman. - export TESTCONTAINERS_RYUK_DISABLED=true - export DOCKER_HOST fi echo 'Running tests'