Skip to content

Commit dd95050

Browse files
CI updates (#566)
update ci elixir/otp version, use github action for unit test, fix test for elixir 1.15
1 parent 0419d4e commit dd95050

6 files changed

Lines changed: 663 additions & 651 deletions

File tree

.github/workflows/ci.yml

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,47 @@ jobs:
44
test:
55
name: unittest
66
runs-on: ubuntu-latest
7+
env:
8+
MIX_ENV: test
79
strategy:
810
fail-fast: false
911
matrix:
10-
elixirbase:
11-
- image: "1.13.4-erlang-24.3.4.2-alpine-3.16.0"
12+
include:
13+
- elixir: 1.15.6
14+
otp: 24.3.4.13
15+
- elixir: 1.15.6
16+
otp: 25.3.2.6
1217
lint: lint
13-
- image: "1.13.4-erlang-22.3.4.20-alpine-3.14.0"
1418
steps:
15-
- uses: earthly/actions-setup@v1
16-
- uses: actions/checkout@v3
17-
- name: test ecto_sql
18-
run: earthly -P --ci --build-arg LINT=${{matrix.elixirbase.lint}} --build-arg ELIXIR_BASE=${{matrix.elixirbase.image}} +test
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
- name: Install Elixir and Erlang
22+
uses: erlef/setup-beam@v1
23+
with:
24+
elixir-version: ${{ matrix.elixir }}
25+
otp-version: ${{ matrix.otp }}
26+
- name: Restore deps and _build cache
27+
uses: actions/cache@v3
28+
with:
29+
path: |
30+
deps
31+
_build
32+
key: ${{ runner.os }}-${{ matrix.elixir }}-${{ matrix.otp }}-${{ hashFiles('**/mix.lock') }}
33+
restore-keys: |
34+
${{ runner.os }}-${{ matrix.elixir }}-${{ matrix.otp }}-
35+
- name: Install dependencies
36+
run: mix deps.get
37+
- name: Check unused dependencies
38+
run: mix deps.unlock --check-unused
39+
if: ${{ matrix.lint }}
40+
- name: Check formatting
41+
run: mix format --check-formatted
42+
if: ${{ matrix.lint }}
43+
- name: Compile
44+
run: mix compile
45+
- name: Run tests
46+
run: mix test
47+
1948
test-postgres:
2049
name: postgres integration test
2150
runs-on: ubuntu-latest
@@ -34,6 +63,7 @@ jobs:
3463
- uses: actions/checkout@v3
3564
- name: test ecto_sql
3665
run: earthly -P --ci --build-arg ELIXIR_BASE=${{matrix.elixirbase}} --build-arg POSTGRES=${{matrix.postgres}} +integration-test-postgres
66+
3767
test-mysql:
3868
name: mysql integration test
3969
runs-on: ubuntu-latest
@@ -50,6 +80,7 @@ jobs:
5080
- uses: actions/checkout@v3
5181
- name: test ecto_sql
5282
run: earthly -P --ci --build-arg ELIXIR_BASE=${{matrix.elixirbase}} --build-arg MYSQL=${{matrix.mysql}} +integration-test-mysql
83+
5384
test-mssql:
5485
name: mssql integration test
5586
runs-on: ubuntu-latest

Earthfile

Lines changed: 15 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,7 @@
11
VERSION 0.5
22

33
all:
4-
BUILD +test-all
5-
BUILD +integration-test-all
6-
7-
8-
test-all:
9-
BUILD \
10-
--build-arg ELIXIR_BASE=1.13.4-erlang-24.3.4.2-alpine-3.16.0 \
11-
--build-arg ELIXIR_BASE=1.13.4-erlang-22.3.4.20-alpine-3.14.0 \
12-
+test
13-
14-
15-
test:
16-
FROM +test-setup
17-
RUN MIX_ENV=test mix deps.compile
18-
COPY --dir bench integration_test lib test ./
19-
20-
ARG LINT
21-
RUN if [ "$LINT" == "lint" ]; then mix format --check-formatted; fi
22-
RUN mix deps.get && mix deps.unlock --check-unused
23-
RUN mix deps.compile
24-
RUN mix compile #--warnings-as-errors
25-
RUN mix test
26-
27-
28-
integration-test-all:
29-
ARG ELIXIR_BASE=1.13.4-erlang-24.3.4.2-alpine-3.16.0
4+
ARG ELIXIR_BASE=1.15.6-erlang-25.3.2.6-alpine-3.17.4
305
BUILD \
316
--build-arg POSTGRES=15.0 \
327
--build-arg POSTGRES=11.11 \
@@ -36,33 +11,34 @@ integration-test-all:
3611

3712
BUILD \
3813
--build-arg MYSQL=5.7 \
14+
--build-arg MYSQL=8.0 \
3915
+integration-test-mysql
4016

4117
BUILD \
4218
--build-arg MSSQL=2017 \
4319
--build-arg MSSQL=2019 \
4420
+integration-test-mssql
4521

46-
47-
integration-test-base:
48-
FROM +setup-base
22+
setup-base:
23+
ARG ELIXIR_BASE=1.15.6-erlang-25.3.2.6-alpine-3.17.4
24+
FROM hexpm/elixir:$ELIXIR_BASE
25+
RUN apk add --no-progress --update git build-base
26+
ENV ELIXIR_ASSERT_TIMEOUT=10000
27+
WORKDIR /src/ecto_sql
4928
RUN apk add --no-progress --update docker docker-compose
50-
5129
RUN mix local.rebar --force
5230
RUN mix local.hex --force
5331

54-
55-
COMMON_INTEGRATION_SETUP_AND_MIX:
32+
COMMON_SETUP_AND_MIX:
5633
COMMAND
5734
COPY mix.exs mix.lock .formatter.exs .
5835
COPY --dir bench integration_test lib test ./
5936
RUN mix deps.get
6037
RUN mix deps.compile
6138
RUN mix compile #--warnings-as-errors
6239

63-
6440
integration-test-postgres:
65-
FROM +integration-test-base
41+
FROM +setup-base
6642
ARG POSTGRES="11.11"
6743

6844
IF [ "$POSTGRES" = "9.5" ]
@@ -82,7 +58,7 @@ integration-test-postgres:
8258
RUN apk add postgresql-client
8359
END
8460

85-
DO +COMMON_INTEGRATION_SETUP_AND_MIX
61+
DO +COMMON_SETUP_AND_MIX
8662

8763
# then run the tests
8864
WITH DOCKER \
@@ -100,12 +76,11 @@ integration-test-postgres:
10076
PG_URL=postgres:postgres@127.0.0.1 ECTO_ADAPTER=pg mix test;
10177
END
10278

103-
10479
integration-test-mysql:
105-
FROM +integration-test-base
80+
FROM +setup-base
10681
RUN apk add mysql-client
10782

108-
DO +COMMON_INTEGRATION_SETUP_AND_MIX
83+
DO +COMMON_SETUP_AND_MIX
10984

11085
ARG MYSQL="5.7"
11186
WITH DOCKER \
@@ -128,7 +103,7 @@ integration-test-mysql:
128103

129104

130105
integration-test-mssql:
131-
FROM +integration-test-base
106+
FROM +setup-base
132107

133108
RUN apk add --no-cache curl gnupg --virtual .build-dependencies -- && \
134109
curl -O https://download.microsoft.com/download/e/4/e/e4e67866-dffd-428c-aac7-8d28ddafb39b/msodbcsql17_17.5.2.1-1_amd64.apk && \
@@ -137,7 +112,7 @@ integration-test-mssql:
137112
apk del .build-dependencies && rm -f msodbcsql*.sig mssql-tools*.apk
138113
ENV PATH="/opt/mssql-tools/bin:${PATH}"
139114

140-
DO +COMMON_INTEGRATION_SETUP_AND_MIX
115+
DO +COMMON_SETUP_AND_MIX
141116

142117
ARG MSSQL="2017"
143118
WITH DOCKER \
@@ -154,21 +129,3 @@ integration-test-mssql:
154129
# run tests
155130
ECTO_ADAPTER=tds mix test;
156131
END
157-
158-
159-
setup-base:
160-
ARG ELIXIR_BASE=1.13.4-erlang-24.3.4.2-alpine-3.17.0
161-
FROM hexpm/elixir:$ELIXIR_BASE
162-
RUN apk add --no-progress --update git build-base
163-
ENV ELIXIR_ASSERT_TIMEOUT=10000
164-
WORKDIR /src/ecto_sql
165-
166-
167-
test-setup:
168-
FROM +setup-base
169-
COPY mix.exs .
170-
COPY mix.lock .
171-
COPY .formatter.exs .
172-
RUN mix local.rebar --force
173-
RUN mix local.hex --force
174-
RUN mix deps.get

lib/ecto/adapter/migration.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,5 @@ defmodule Ecto.Adapter.Migration do
6767
"""
6868
@callback lock_for_migrations(adapter_meta, options :: Keyword.t(), fun) ::
6969
result
70-
when fun: (() -> result), result: var
70+
when fun: (-> result), result: var
7171
end

lib/ecto/adapters/myxql/connection.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ if Code.ensure_loaded?(MyXQL) do
225225

226226
defp insert_all_value(nil), do: "DEFAULT"
227227
defp insert_all_value({%Ecto.Query{} = query, _params_counter}), do: [?(, all(query), ?)]
228-
defp insert_all_value(_), do: '?'
228+
defp insert_all_value(_), do: ~c"?"
229229

230230
@impl true
231231
def update(prefix, table, fields, filters, _returning) do
@@ -628,7 +628,7 @@ if Code.ensure_loaded?(MyXQL) do
628628
end
629629

630630
defp expr({:^, [], [_ix]}, _sources, _query) do
631-
'?'
631+
~c"?"
632632
end
633633

634634
defp expr({{:., _, [{:parent_as, _, [as]}, field]}, _, []}, _sources, query)

0 commit comments

Comments
 (0)