From b5f5cac5df939e215ce0de4f86b3aa99da47c165 Mon Sep 17 00:00:00 2001 From: Andrea Leopardi Date: Wed, 13 Dec 2023 10:59:11 +0100 Subject: [PATCH 1/3] Make CI work --- .github/workflows/main.yml | 26 +++++++++----------------- .gitignore | 3 +++ 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bc2792a..54ee9cc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,21 +14,19 @@ 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 + # Oldest supported versions - otp: "25.3" elixir: "1.14.3" coverage: true lint: true version-type: loose - - otp: "23.0" - elixir: "1.11.2" - version-type: loose - env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} MIX_ENV: test @@ -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 From a0cb5fc74f082409056dfc6b073c9004671915da Mon Sep 17 00:00:00 2001 From: Andrea Leopardi Date: Wed, 13 Dec 2023 11:06:15 +0100 Subject: [PATCH 2/3] More --- .github/workflows/main.yml | 4 ++-- mix.exs | 2 +- test/ecto_unix_timestamp_test.exs | 5 +++-- test/test_helper.exs | 14 ++++++++++++++ 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 54ee9cc..6e43dff 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,8 +21,8 @@ jobs: dialyzer: true # Oldest supported versions - - otp: "25.3" - elixir: "1.14.3" + - otp: "21.3" + elixir: "1.11.4" coverage: true lint: true version-type: loose 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 From 567705835a4b656aed4681ef5101e61e650a7fca Mon Sep 17 00:00:00 2001 From: Andrea Leopardi Date: Wed, 13 Dec 2023 11:08:13 +0100 Subject: [PATCH 3/3] Coverage --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6e43dff..7aa1708 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,12 +19,12 @@ jobs: elixir: "1.15" version-type: strict dialyzer: true + coverage: true + lint: true # Oldest supported versions - otp: "21.3" elixir: "1.11.4" - coverage: true - lint: true version-type: loose env: