Skip to content
Merged
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
30 changes: 11 additions & 19 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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()
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ ecto_unix_timestamp-*.tar

# SQLite3 databases.
*.sqlite3

# Dialyzer stuff
/plts
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
5 changes: 3 additions & 2 deletions test/ecto_unix_timestamp_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ defmodule EctoUnixTimestampTest do
use ExUnit.Case, async: true

import Ecto.Changeset
import EctoUnixTimestamp.TestHelpers

defmodule Repo do
use Ecto.Repo,
Expand Down Expand Up @@ -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))}

Expand All @@ -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 = %{
Expand Down
14 changes: 14 additions & 0 deletions test/test_helper.exs
Original file line number Diff line number Diff line change
@@ -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