diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml index 0d688382a..5655b33b1 100644 --- a/.github/workflows/elixir.yml +++ b/.github/workflows/elixir.yml @@ -109,6 +109,8 @@ jobs: if: env.MIX_ENV == 'test' - run: mix test --include slow --include minio --max-failures 1 --warnings-as-errors if: env.MIX_ENV == 'test' + env: + MINIO_HOST_FOR_CLICKHOUSE: "172.17.0.1" - run: mix test --include slow --max-failures 1 --warnings-as-errors if: env.MIX_ENV == 'small_test' diff --git a/lib/plausible/s3.ex b/lib/plausible/s3.ex index 3cd6878bc..3db53297b 100644 --- a/lib/plausible/s3.ex +++ b/lib/plausible/s3.ex @@ -43,12 +43,9 @@ defmodule Plausible.S3 do Example: - # in tests we "swindle" the host in s3_url with something that would - # make MinIO visible to ClickHouse, both assumed to be running in containers - iex> %{ - ...> s3_url: "http://host.docker.internal:10000/test-imports/123/imported_browsers.csv", - ...> presigned_url: "http://localhost:10000/test-imports/123/imported_browsers.csv?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=minioadmin" <> _ - ...> } = import_presign_upload(_site_id = 123, _filename = "imported_browsers.csv") + iex> upload = import_presign_upload(_site_id = 123, _filename = "imported_browsers.csv") + iex> true = String.ends_with?(upload.s3_url, "/test-imports/123/imported_browsers.csv") + iex> true = String.contains?(upload.presigned_url, "/test-imports/123/imported_browsers.csv?X-Amz-Algorithm=AWS4-HMAC-SHA256&") """ def import_presign_upload(site_id, filename) do @@ -64,7 +61,8 @@ defmodule Plausible.S3 do if Mix.env() in [:dev, :test, :small_dev, :small_test] do defp extract_s3_url(presigned_url) do [s3_url, _] = String.split(presigned_url, "?") - ch_host = System.get_env("MINIO_HOST_FOR_CLICKHOUSE", "host.docker.internal") + default_ch_host = unless System.get_env("CI"), do: "host.docker.internal" + ch_host = System.get_env("MINIO_HOST_FOR_CLICKHOUSE", default_ch_host) URI.to_string(%URI{URI.parse(s3_url) | host: ch_host}) end else