Skip to content

Commit

Permalink
CI updates (#566)
Browse files Browse the repository at this point in the history
update ci elixir/otp version, use github action for unit test, fix test for elixir 1.15
  • Loading branch information
greg-rychlewski authored Oct 7, 2023
1 parent 0419d4e commit dd95050
Show file tree
Hide file tree
Showing 6 changed files with 663 additions and 651 deletions.
45 changes: 38 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,47 @@ jobs:
test:
name: unittest
runs-on: ubuntu-latest
env:
MIX_ENV: test
strategy:
fail-fast: false
matrix:
elixirbase:
- image: "1.13.4-erlang-24.3.4.2-alpine-3.16.0"
include:
- elixir: 1.15.6
otp: 24.3.4.13
- elixir: 1.15.6
otp: 25.3.2.6
lint: lint
- image: "1.13.4-erlang-22.3.4.20-alpine-3.14.0"
steps:
- uses: earthly/actions-setup@v1
- uses: actions/checkout@v3
- name: test ecto_sql
run: earthly -P --ci --build-arg LINT=${{matrix.elixirbase.lint}} --build-arg ELIXIR_BASE=${{matrix.elixirbase.image}} +test
- name: Checkout
uses: actions/checkout@v4
- name: Install Elixir and Erlang
uses: erlef/setup-beam@v1
with:
elixir-version: ${{ matrix.elixir }}
otp-version: ${{ matrix.otp }}
- name: Restore deps and _build cache
uses: actions/cache@v3
with:
path: |
deps
_build
key: ${{ runner.os }}-${{ matrix.elixir }}-${{ matrix.otp }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.elixir }}-${{ matrix.otp }}-
- name: Install dependencies
run: mix deps.get
- name: Check unused dependencies
run: mix deps.unlock --check-unused
if: ${{ matrix.lint }}
- name: Check formatting
run: mix format --check-formatted
if: ${{ matrix.lint }}
- name: Compile
run: mix compile
- name: Run tests
run: mix test

test-postgres:
name: postgres integration test
runs-on: ubuntu-latest
Expand All @@ -34,6 +63,7 @@ jobs:
- uses: actions/checkout@v3
- name: test ecto_sql
run: earthly -P --ci --build-arg ELIXIR_BASE=${{matrix.elixirbase}} --build-arg POSTGRES=${{matrix.postgres}} +integration-test-postgres

test-mysql:
name: mysql integration test
runs-on: ubuntu-latest
Expand All @@ -50,6 +80,7 @@ jobs:
- uses: actions/checkout@v3
- name: test ecto_sql
run: earthly -P --ci --build-arg ELIXIR_BASE=${{matrix.elixirbase}} --build-arg MYSQL=${{matrix.mysql}} +integration-test-mysql

test-mssql:
name: mssql integration test
runs-on: ubuntu-latest
Expand Down
73 changes: 15 additions & 58 deletions Earthfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,7 @@
VERSION 0.5

all:
BUILD +test-all
BUILD +integration-test-all


test-all:
BUILD \
--build-arg ELIXIR_BASE=1.13.4-erlang-24.3.4.2-alpine-3.16.0 \
--build-arg ELIXIR_BASE=1.13.4-erlang-22.3.4.20-alpine-3.14.0 \
+test


test:
FROM +test-setup
RUN MIX_ENV=test mix deps.compile
COPY --dir bench integration_test lib test ./

ARG LINT
RUN if [ "$LINT" == "lint" ]; then mix format --check-formatted; fi
RUN mix deps.get && mix deps.unlock --check-unused
RUN mix deps.compile
RUN mix compile #--warnings-as-errors
RUN mix test


integration-test-all:
ARG ELIXIR_BASE=1.13.4-erlang-24.3.4.2-alpine-3.16.0
ARG ELIXIR_BASE=1.15.6-erlang-25.3.2.6-alpine-3.17.4
BUILD \
--build-arg POSTGRES=15.0 \
--build-arg POSTGRES=11.11 \
Expand All @@ -36,33 +11,34 @@ integration-test-all:

BUILD \
--build-arg MYSQL=5.7 \
--build-arg MYSQL=8.0 \
+integration-test-mysql

BUILD \
--build-arg MSSQL=2017 \
--build-arg MSSQL=2019 \
+integration-test-mssql


integration-test-base:
FROM +setup-base
setup-base:
ARG ELIXIR_BASE=1.15.6-erlang-25.3.2.6-alpine-3.17.4
FROM hexpm/elixir:$ELIXIR_BASE
RUN apk add --no-progress --update git build-base
ENV ELIXIR_ASSERT_TIMEOUT=10000
WORKDIR /src/ecto_sql
RUN apk add --no-progress --update docker docker-compose

RUN mix local.rebar --force
RUN mix local.hex --force


COMMON_INTEGRATION_SETUP_AND_MIX:
COMMON_SETUP_AND_MIX:
COMMAND
COPY mix.exs mix.lock .formatter.exs .
COPY --dir bench integration_test lib test ./
RUN mix deps.get
RUN mix deps.compile
RUN mix compile #--warnings-as-errors


integration-test-postgres:
FROM +integration-test-base
FROM +setup-base
ARG POSTGRES="11.11"

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

DO +COMMON_INTEGRATION_SETUP_AND_MIX
DO +COMMON_SETUP_AND_MIX

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


integration-test-mysql:
FROM +integration-test-base
FROM +setup-base
RUN apk add mysql-client

DO +COMMON_INTEGRATION_SETUP_AND_MIX
DO +COMMON_SETUP_AND_MIX

ARG MYSQL="5.7"
WITH DOCKER \
Expand All @@ -128,7 +103,7 @@ integration-test-mysql:


integration-test-mssql:
FROM +integration-test-base
FROM +setup-base

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

DO +COMMON_INTEGRATION_SETUP_AND_MIX
DO +COMMON_SETUP_AND_MIX

ARG MSSQL="2017"
WITH DOCKER \
Expand All @@ -154,21 +129,3 @@ integration-test-mssql:
# run tests
ECTO_ADAPTER=tds mix test;
END


setup-base:
ARG ELIXIR_BASE=1.13.4-erlang-24.3.4.2-alpine-3.17.0
FROM hexpm/elixir:$ELIXIR_BASE
RUN apk add --no-progress --update git build-base
ENV ELIXIR_ASSERT_TIMEOUT=10000
WORKDIR /src/ecto_sql


test-setup:
FROM +setup-base
COPY mix.exs .
COPY mix.lock .
COPY .formatter.exs .
RUN mix local.rebar --force
RUN mix local.hex --force
RUN mix deps.get
2 changes: 1 addition & 1 deletion lib/ecto/adapter/migration.ex
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ defmodule Ecto.Adapter.Migration do
"""
@callback lock_for_migrations(adapter_meta, options :: Keyword.t(), fun) ::
result
when fun: (() -> result), result: var
when fun: (-> result), result: var
end
4 changes: 2 additions & 2 deletions lib/ecto/adapters/myxql/connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ if Code.ensure_loaded?(MyXQL) do

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

@impl true
def update(prefix, table, fields, filters, _returning) do
Expand Down Expand Up @@ -628,7 +628,7 @@ if Code.ensure_loaded?(MyXQL) do
end

defp expr({:^, [], [_ix]}, _sources, _query) do
'?'
~c"?"
end

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

0 comments on commit dd95050

Please sign in to comment.