diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bc2792a..7aa1708 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,19 +14,17 @@ jobs: fail-fast: false matrix: include: - - otp: "26.0.1" - elixir: "1.15.0" + # Latest supported versions + - otp: "26.2" + elixir: "1.15" version-type: strict dialyzer: true - - - otp: "25.3" - elixir: "1.14.3" coverage: true lint: true - version-type: loose - - otp: "23.0" - elixir: "1.11.2" + # Oldest supported versions + - otp: "21.3" + elixir: "1.11.4" version-type: loose env: @@ -37,9 +35,6 @@ jobs: - name: Clone the repository uses: actions/checkout@v3 - - name: Start Docker - run: docker-compose up --detach - - name: Install OTP and Elixir uses: erlef/setup-beam@v1 with: @@ -54,14 +49,15 @@ jobs: path: | deps _build - key: ${{ runner.os }}-mix-otp${{ matrix.otp }}-elixir${{ matrix.elixir }}-${{ hashFiles('**/mix.lock') }} + key: | + ${{ runner.os }}-mix-otp${{ matrix.otp }}-elixir${{ matrix.elixir }}-${{ hashFiles('**/mix.lock') }} + restore-keys: | + ${{ runner.os }}-mix-otp${{ matrix.otp }}-elixir${{ matrix.elixir }}- - name: Fetch dependencies and verify mix.lock - if: steps.cache-deps.outputs.cache-hit != 'true' run: mix deps.get --check-locked - name: Compile dependencies - if: steps.cache-deps.outputs.cache-hit != 'true' run: mix deps.compile # Don't cache PLTs based on mix.lock hash, as Dialyzer can incrementally update even old ones @@ -97,7 +93,7 @@ jobs: if: ${{ matrix.lint }} - name: Run tests - run: mix test --trace --exclude propcheck + run: mix test --trace if: ${{ !matrix.coverage }} - name: Run tests with coverage @@ -107,7 +103,3 @@ jobs: - name: Run dialyzer run: mix dialyzer --format github if: ${{ matrix.dialyzer }} - - - name: Dump Docker logs on failure - uses: jwalton/gh-docker-logs@v1 - if: failure() diff --git a/.gitignore b/.gitignore index 5215165..407abdd 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,6 @@ ecto_unix_timestamp-*.tar # SQLite3 databases. *.sqlite3 + +# Dialyzer stuff +/plts diff --git a/mix.exs b/mix.exs index 7b22df5..8596471 100644 --- a/mix.exs +++ b/mix.exs @@ -9,7 +9,7 @@ defmodule EctoUnixTimestamp.MixProject do [ app: :ecto_unix_timestamp, version: @version, - elixir: "~> 1.14", + elixir: "~> 1.11", start_permanent: Mix.env() == :prod, deps: deps(), preferred_cli_env: [ diff --git a/test/ecto_unix_timestamp_test.exs b/test/ecto_unix_timestamp_test.exs index 1991f12..c62147d 100644 --- a/test/ecto_unix_timestamp_test.exs +++ b/test/ecto_unix_timestamp_test.exs @@ -2,6 +2,7 @@ defmodule EctoUnixTimestampTest do use ExUnit.Case, async: true import Ecto.Changeset + import EctoUnixTimestamp.TestHelpers defmodule Repo do use Ecto.Repo, @@ -52,7 +53,7 @@ defmodule EctoUnixTimestampTest do for unit <- [:second, :millisecond, :microsecond] do test "timestamps are casted correctly with unit #{inspect(unit)} (utc)" do - now = DateTime.utc_now(unquote(unit)) + now = datetime_utc_now(unquote(unit)) field = :"timestamp_#{unquote(unit)}_utc" params = %{field => DateTime.to_unix(now, unquote(unit))} @@ -64,7 +65,7 @@ defmodule EctoUnixTimestampTest do end test "timestamps are casted correctly with unit #{inspect(unit)} (naive)" do - now = NaiveDateTime.utc_now(unquote(unit)) + now = naive_datetime_utc_now(unquote(unit)) field = :"timestamp_#{unquote(unit)}_naive" params = %{ diff --git a/test/test_helper.exs b/test/test_helper.exs index 869559e..340a20e 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -1 +1,15 @@ ExUnit.start() + +defmodule EctoUnixTimestamp.TestHelpers do + # TODO: remove this once we require Elixir 1.15+, which has DateTime.utc_now/2 + # which supports built-in truncation. + def datetime_utc_now(precision) do + DateTime.truncate(DateTime.utc_now(), precision) + end + + # TODO: remove this once we require Elixir 1.15+, which has NaiveDateTime.utc_now/2 + # which supports built-in truncation. + def naive_datetime_utc_now(precision) do + NaiveDateTime.truncate(NaiveDateTime.utc_now(), precision) + end +end