Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@ jobs:
fail-fast: false
matrix:
include:
- elixir: "1.18.1"
otp: "27.2"
- elixir: "1.18.4"
otp: "28.0"
lint: lint
- elixir: "1.17.3"
otp: "27.1"
otp: "27.3"
- elixir: "1.17.3"
otp: "25.0.4"
otp: "26.2"
- elixir: "1.17.3"
otp: "25.3"
- elixir: "1.14.5"
otp: "24.3.4.17"
otp: "24.3"

steps:
- name: Checkout
Expand Down Expand Up @@ -68,11 +70,13 @@ jobs:
fail-fast: false
matrix:
elixirbase:
- "1.17.3-erlang-27.1-alpine-3.17.9"
- "1.17.3-erlang-25.0.4-alpine-3.17.9"
- "1.14.5-erlang-23.3.4.20-alpine-3.16.9"
- "1.18.4-erlang-28.0.2-alpine-3.22.1"
- "1.17.3-erlang-27.3.4.2-alpine-3.22.1"
- "1.17.3-erlang-26.2.5.14-alpine-3.22.1"
- "1.17.3-erlang-25.3.2.21-alpine-3.22.1"
- "1.14.5-erlang-24.3.4.17-alpine-3.22.1"
steps:
- uses: earthly/actions-setup@v1
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: ecto integration-test under ${{matrix.elixirbase}}
run: earthly -P --ci --build-arg ELIXIR_BASE=${{matrix.elixirbase}} +integration-test
62 changes: 32 additions & 30 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

all:
BUILD \
--build-arg ELIXIR_BASE=1.15.6-erlang-25.3.2.6-alpine-3.18.4 \
--build-arg ELIXIR_BASE=1.15.6-erlang-24.3.4.14-alpine-3.18.4 \
--build-arg ELIXIR_BASE=1.18.4-erlang-28.0.2-alpine-3.22.1 \
--build-arg ELIXIR_BASE=1.17.3-erlang-27.3.4.2-alpine-3.22.1 \
--build-arg ELIXIR_BASE=1.17.3-erlang-26.2.5.14-alpine-3.22.1 \
--build-arg ELIXIR_BASE=1.14.5-erlang-24.3.4.17-alpine-3.22.1 \
+integration-test

integration-test-base:
ARG ELIXIR_BASE=1.15.6-erlang-25.3.2.6-alpine-3.18.4
ARG ELIXIR_BASE=1.18.4-erlang-28.0.2-alpine-3.22.1
ARG TARGETARCH
FROM hexpm/elixir:$ELIXIR_BASE
RUN apk add --no-progress --update git build-base
Expand Down Expand Up @@ -44,37 +46,37 @@
ARG MCR_IMG="mcr.microsoft.com/mssql/server:2019-latest"
ARG MYSQL_IMG="mysql:5.7"

# then run the tests
# then run the tests
WITH DOCKER --pull "$PG_IMG" --pull "$MCR_IMG" --pull "$MYSQL_IMG" --platform linux/amd64
RUN set -e; \
timeout=$(expr $(date +%s) + 60); \
RUN set -e; \

Check failure on line 51 in Earthfile

View workflow job for this annotation

GitHub Actions / integration test (1.17.3-erlang-27.3.4.2-alpine-3.22.1)

Error

The command WITH DOCKER RUN --privileged set -e; timeout=$(expr $(date +%!s(MISSING)) + 60); docker run --name mssql --network=host -d -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=some!Password' "$MCR_IMG"; docker run --name pg --network=host -d -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=postgres "$PG_IMG"; docker run --name mysql --network=host -d -e MYSQL_ROOT_PASSWORD=root "$MYSQL_IMG"; while ! sqlcmd -C -S tcp:127.0.0.1,1433 -U sa -P 'some!Password' -Q "SELECT 1" >/dev/null 2>&1; do test "$(date +%!s(MISSING))" -le "$timeout" || (echo "timed out waiting for mssql"; exit 1); echo "waiting for mssql"; sleep 1; done; while ! pg_isready --host=127.0.0.1 --port=5432 --quiet; do test "$(date +%!s(MISSING))" -le "$timeout" || (echo "timed out waiting for postgres"; exit 1); echo "waiting for postgres"; sleep 1; done; while ! mysqladmin ping --host=127.0.0.1 --port=3306 --protocol=TCP --silent; do test "$(date +%!s(MISSING))" -le "$timeout" || (echo "timed out waiting for mysql"; exit 1); echo "waiting for mysql"; sleep 1; done; MSSQL_URL='sa:[email protected]' MYSQL_URL='root:[email protected]' PG_URL='postgres:[email protected]' ECTO_PATH='/src/ecto' mix test.all; did not complete successfully. Exit code 1

Check failure on line 51 in Earthfile

View workflow job for this annotation

GitHub Actions / integration test (1.17.3-erlang-26.2.5.14-alpine-3.22.1)

Error

The command WITH DOCKER RUN --privileged set -e; timeout=$(expr $(date +%!s(MISSING)) + 60); docker run --name mssql --network=host -d -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=some!Password' "$MCR_IMG"; docker run --name pg --network=host -d -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=postgres "$PG_IMG"; docker run --name mysql --network=host -d -e MYSQL_ROOT_PASSWORD=root "$MYSQL_IMG"; while ! sqlcmd -C -S tcp:127.0.0.1,1433 -U sa -P 'some!Password' -Q "SELECT 1" >/dev/null 2>&1; do test "$(date +%!s(MISSING))" -le "$timeout" || (echo "timed out waiting for mssql"; exit 1); echo "waiting for mssql"; sleep 1; done; while ! pg_isready --host=127.0.0.1 --port=5432 --quiet; do test "$(date +%!s(MISSING))" -le "$timeout" || (echo "timed out waiting for postgres"; exit 1); echo "waiting for postgres"; sleep 1; done; while ! mysqladmin ping --host=127.0.0.1 --port=3306 --protocol=TCP --silent; do test "$(date +%!s(MISSING))" -le "$timeout" || (echo "timed out waiting for mysql"; exit 1); echo "waiting for mysql"; sleep 1; done; MSSQL_URL='sa:[email protected]' MYSQL_URL='root:[email protected]' PG_URL='postgres:[email protected]' ECTO_PATH='/src/ecto' mix test.all; did not complete successfully. Exit code 1

Check failure on line 51 in Earthfile

View workflow job for this annotation

GitHub Actions / integration test (1.18.4-erlang-28.0.2-alpine-3.22.1)

Error

The command WITH DOCKER RUN --privileged set -e; timeout=$(expr $(date +%!s(MISSING)) + 60); docker run --name mssql --network=host -d -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=some!Password' "$MCR_IMG"; docker run --name pg --network=host -d -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=postgres "$PG_IMG"; docker run --name mysql --network=host -d -e MYSQL_ROOT_PASSWORD=root "$MYSQL_IMG"; while ! sqlcmd -C -S tcp:127.0.0.1,1433 -U sa -P 'some!Password' -Q "SELECT 1" >/dev/null 2>&1; do test "$(date +%!s(MISSING))" -le "$timeout" || (echo "timed out waiting for mssql"; exit 1); echo "waiting for mssql"; sleep 1; done; while ! pg_isready --host=127.0.0.1 --port=5432 --quiet; do test "$(date +%!s(MISSING))" -le "$timeout" || (echo "timed out waiting for postgres"; exit 1); echo "waiting for postgres"; sleep 1; done; while ! mysqladmin ping --host=127.0.0.1 --port=3306 --protocol=TCP --silent; do test "$(date +%!s(MISSING))" -le "$timeout" || (echo "timed out waiting for mysql"; exit 1); echo "waiting for mysql"; sleep 1; done; MSSQL_URL='sa:[email protected]' MYSQL_URL='root:[email protected]' PG_URL='postgres:[email protected]' ECTO_PATH='/src/ecto' mix test.all; did not complete successfully. Exit code 1

Check failure on line 51 in Earthfile

View workflow job for this annotation

GitHub Actions / integration test (1.17.3-erlang-25.3.2.21-alpine-3.22.1)

Error

The command WITH DOCKER RUN --privileged set -e; timeout=$(expr $(date +%!s(MISSING)) + 60); docker run --name mssql --network=host -d -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=some!Password' "$MCR_IMG"; docker run --name pg --network=host -d -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=postgres "$PG_IMG"; docker run --name mysql --network=host -d -e MYSQL_ROOT_PASSWORD=root "$MYSQL_IMG"; while ! sqlcmd -C -S tcp:127.0.0.1,1433 -U sa -P 'some!Password' -Q "SELECT 1" >/dev/null 2>&1; do test "$(date +%!s(MISSING))" -le "$timeout" || (echo "timed out waiting for mssql"; exit 1); echo "waiting for mssql"; sleep 1; done; while ! pg_isready --host=127.0.0.1 --port=5432 --quiet; do test "$(date +%!s(MISSING))" -le "$timeout" || (echo "timed out waiting for postgres"; exit 1); echo "waiting for postgres"; sleep 1; done; while ! mysqladmin ping --host=127.0.0.1 --port=3306 --protocol=TCP --silent; do test "$(date +%!s(MISSING))" -le "$timeout" || (echo "timed out waiting for mysql"; exit 1); echo "waiting for mysql"; sleep 1; done; MSSQL_URL='sa:[email protected]' MYSQL_URL='root:[email protected]' PG_URL='postgres:[email protected]' ECTO_PATH='/src/ecto' mix test.all; did not complete successfully. Exit code 1

Check failure on line 51 in Earthfile

View workflow job for this annotation

GitHub Actions / integration test (1.14.5-erlang-24.3.4.17-alpine-3.22.1)

Error

The command WITH DOCKER RUN --privileged set -e; timeout=$(expr $(date +%!s(MISSING)) + 60); docker run --name mssql --network=host -d -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=some!Password' "$MCR_IMG"; docker run --name pg --network=host -d -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=postgres "$PG_IMG"; docker run --name mysql --network=host -d -e MYSQL_ROOT_PASSWORD=root "$MYSQL_IMG"; while ! sqlcmd -C -S tcp:127.0.0.1,1433 -U sa -P 'some!Password' -Q "SELECT 1" >/dev/null 2>&1; do test "$(date +%!s(MISSING))" -le "$timeout" || (echo "timed out waiting for mssql"; exit 1); echo "waiting for mssql"; sleep 1; done; while ! pg_isready --host=127.0.0.1 --port=5432 --quiet; do test "$(date +%!s(MISSING))" -le "$timeout" || (echo "timed out waiting for postgres"; exit 1); echo "waiting for postgres"; sleep 1; done; while ! mysqladmin ping --host=127.0.0.1 --port=3306 --protocol=TCP --silent; do test "$(date +%!s(MISSING))" -le "$timeout" || (echo "timed out waiting for mysql"; exit 1); echo "waiting for mysql"; sleep 1; done; MSSQL_URL='sa:[email protected]' MYSQL_URL='root:[email protected]' PG_URL='postgres:[email protected]' ECTO_PATH='/src/ecto' mix test.all; did not complete successfully. Exit code 1
timeout=$(expr $(date +%s) + 60); \

# start databases
docker run --name mssql --network=host -d -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=some!Password' "$MCR_IMG"; \
docker run --name pg --network=host -d -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=postgres "$PG_IMG"; \
docker run --name mysql --network=host -d -e MYSQL_ROOT_PASSWORD=root "$MYSQL_IMG"; \
# start databases
docker run --name mssql --network=host -d -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=some!Password' "$MCR_IMG"; \
docker run --name pg --network=host -d -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=postgres "$PG_IMG"; \
docker run --name mysql --network=host -d -e MYSQL_ROOT_PASSWORD=root "$MYSQL_IMG"; \

# wait for mssql to start
while ! sqlcmd -C -S tcp:127.0.0.1,1433 -U sa -P 'some!Password' -Q "SELECT 1" >/dev/null 2>&1; do \
test "$(date +%s)" -le "$timeout" || (echo "timed out waiting for mssql"; exit 1); \
echo "waiting for mssql"; \
sleep 1; \
done; \
# wait for mssql to start
while ! sqlcmd -C -S tcp:127.0.0.1,1433 -U sa -P 'some!Password' -Q "SELECT 1" >/dev/null 2>&1; do \
test "$(date +%s)" -le "$timeout" || (echo "timed out waiting for mssql"; exit 1); \
echo "waiting for mssql"; \
sleep 1; \
done; \

# wait for postgres to start
while ! pg_isready --host=127.0.0.1 --port=5432 --quiet; do \
test "$(date +%s)" -le "$timeout" || (echo "timed out waiting for postgres"; exit 1); \
echo "waiting for postgres"; \
sleep 1; \
done; \
# wait for postgres to start
while ! pg_isready --host=127.0.0.1 --port=5432 --quiet; do \
test "$(date +%s)" -le "$timeout" || (echo "timed out waiting for postgres"; exit 1); \
echo "waiting for postgres"; \
sleep 1; \
done; \

# wait for mysql to start
while ! mysqladmin ping --host=127.0.0.1 --port=3306 --protocol=TCP --silent; do \
test "$(date +%s)" -le "$timeout" || (echo "timed out waiting for mysql"; exit 1); \
echo "waiting for mysql"; \
sleep 1; \
done; \
# wait for mysql to start
while ! mysqladmin ping --host=127.0.0.1 --port=3306 --protocol=TCP --silent; do \
test "$(date +%s)" -le "$timeout" || (echo "timed out waiting for mysql"; exit 1); \
echo "waiting for mysql"; \
sleep 1; \
done; \

# run test
MSSQL_URL='sa:[email protected]' MYSQL_URL='root:[email protected]' PG_URL='postgres:[email protected]' ECTO_PATH='/src/ecto' mix test.all;
# run test
MSSQL_URL='sa:[email protected]' MYSQL_URL='root:[email protected]' PG_URL='postgres:[email protected]' ECTO_PATH='/src/ecto' mix test.all;
END
60 changes: 37 additions & 23 deletions test/ecto/changeset_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -1317,15 +1317,15 @@ defmodule Ecto.ChangesetTest do

assert changeset.valid?
assert changeset.errors == []
assert validations(changeset) == [title: {:format, ~r/@/}]
assert match?([title: {:format, %Regex{source: "@"}}], validations(changeset))

changeset =
changeset(%{"title" => "foobar"})
|> validate_format(:title, ~r/@/)

refute changeset.valid?
assert changeset.errors == [title: {"has invalid format", [validation: :format]}]
assert validations(changeset) == [title: {:format, ~r/@/}]
assert match?([title: {:format, %Regex{source: "@"}}], validations(changeset))

changeset =
changeset(%{"title" => "foobar"})
Expand Down Expand Up @@ -2681,17 +2681,19 @@ defmodule Ecto.ChangesetTest do
message: "cannot be more than 15 characters"
)

assert constraints(changeset) ==
assert match?(
[
%{
type: :check,
field: :title,
constraint: ~r/title_must_be_short\d+/,
constraint: %Regex{source: "title_must_be_short\\d+"},
match: :exact,
error_message: "cannot be more than 15 characters",
error_type: :check
}
]
],
constraints(changeset)
)

assert_raise ArgumentError, ~r/invalid match type: :invalid/, fn ->
change(%Post{})
Expand Down Expand Up @@ -2769,17 +2771,19 @@ defmodule Ecto.ChangesetTest do
changeset =
change(%Post{}) |> unique_constraint(:title, name: ~r/whatever\d+/, message: "is taken")

assert constraints(changeset) ==
assert match?(
[
%{
type: :unique,
field: :title,
constraint: ~r/whatever\d+/,
constraint: %Regex{source: "whatever\\d+"},
match: :exact,
error_message: "is taken",
error_type: :unique
}
]
],
constraints(changeset)
)

assert_raise ArgumentError, ~r/invalid match type: :invalid/, fn ->
change(%Post{})
Expand Down Expand Up @@ -2836,17 +2840,19 @@ defmodule Ecto.ChangesetTest do
changeset =
change(%Post{}) |> unique_constraint(:permalink, name: ~r/whatever\d+/, message: "is taken")

assert constraints(changeset) ==
assert match?(
[
%{
type: :unique,
field: :permalink,
constraint: ~r/whatever\d+/,
constraint: %Regex{source: "whatever\\d+"},
match: :exact,
error_message: "is taken",
error_type: :unique
}
]
],
constraints(changeset)
)

assert_raise ArgumentError, ~r/invalid match type: :invalid/, fn ->
change(%Post{})
Expand Down Expand Up @@ -2979,17 +2985,19 @@ defmodule Ecto.ChangesetTest do
change(%Comment{})
|> foreign_key_constraint(:post, name: ~r/whatever\d+/, message: "is not available")

assert constraints(changeset) ==
assert match?(
[
%{
type: :foreign_key,
field: :post,
constraint: ~r/whatever\d+/,
constraint: %Regex{source: "whatever\\d+"},
match: :exact,
error_message: "is not available",
error_type: :foreign
}
]
],
constraints(changeset)
)

assert_raise ArgumentError, ~r/invalid match type: :invalid/, fn ->
change(%Comment{})
Expand Down Expand Up @@ -3100,17 +3108,19 @@ defmodule Ecto.ChangesetTest do
change(%Comment{})
|> assoc_constraint(:post, name: ~r/whatever\d+/, message: "is not available")

assert constraints(changeset) ==
assert match?(
[
%{
type: :foreign_key,
field: :post,
constraint: ~r/whatever\d+/,
constraint: %Regex{source: "whatever\\d+"},
match: :exact,
error_message: "is not available",
error_type: :assoc
}
]
],
constraints(changeset)
)

assert_raise ArgumentError, ~r/invalid match type: :invalid/, fn ->
change(%Comment{})
Expand Down Expand Up @@ -3229,17 +3239,19 @@ defmodule Ecto.ChangesetTest do
change(%Post{})
|> no_assoc_constraint(:comments, name: ~r/comments_post_id_fkey\d+/, message: "exists")

assert constraints(changeset) ==
assert match?(
[
%{
type: :foreign_key,
field: :comments,
constraint: ~r/comments_post_id_fkey\d+/,
constraint: %Regex{source: "comments_post_id_fkey\\d+"},
match: :exact,
error_message: "exists",
error_type: :no_assoc
}
]
],
constraints(changeset)
)

assert_raise ArgumentError, ~r/invalid match type: :invalid/, fn ->
change(%Post{})
Expand Down Expand Up @@ -3409,17 +3421,19 @@ defmodule Ecto.ChangesetTest do
change(%Post{})
|> exclusion_constraint(:title, name: ~r/whatever\d+/, message: "is invalid")

assert constraints(changeset) ==
assert match?(
[
%{
type: :exclusion,
field: :title,
constraint: ~r/whatever\d+/,
constraint: %Regex{source: "whatever\\d+"},
match: :exact,
error_message: "is invalid",
error_type: :exclusion
}
]
],
constraints(changeset)
)

assert_raise ArgumentError, ~r/invalid match type: :invalid/, fn ->
change(%Post{})
Expand Down
Loading