diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..54c804d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,38 @@ +name: Elixir CI + +on: + pull_request: + branches: + - main + - dev + +jobs: + test: + name: Test (Elixir ${{ matrix.elixir }}, OTP ${{ matrix.otp }}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - elixir: '1.18.4' + otp: '28.0' + version-type: 'strict' + - elixir: '1.12.0' + otp: '24.x' + version-type: 'loose' + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Setup Elixir + uses: erlef/setup-beam@v1 + with: + elixir-version: ${{ matrix.elixir }} + otp-version: ${{ matrix.otp }} + version-type: ${{ matrix.version-type }} + + - name: Install Dependencies + run: mix deps.get + + - name: Run Tests + run: mix test diff --git a/CHANGELOG.md b/CHANGELOG.md index 4be9a25..d3b32ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Added + +- Added CI workflow to run tests against supported Elixir versions + +### Changed + +- Updated minimum supported Elixir version to v1.12 + - While the library may work with older versions, StreamData supports a + minimum of v1.12, so it would be missing the property tests + +### Fixed + +- Updated timestamp decoding to be backwards-compatible with Elixir v1.12 + ## [v1.0.2] - 2025-08-06 ### Fixed diff --git a/README.md b/README.md index 0d7bbdf..617bf21 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,10 @@ This section explains how to setup the project locally for development. ### Dependencies -- Elixir `~> 1.7` (OTP 21+) +- Elixir `~> 1.12` (OTP 24+) + - See [Compatibility and + deprecations](https://hexdocs.pm/elixir/1.18.4/compatibility-and-deprecations.html) + for more information ### Get the Source diff --git a/lib/msgpack/decoder.ex b/lib/msgpack/decoder.ex index cf71b7a..c76e037 100644 --- a/lib/msgpack/decoder.ex +++ b/lib/msgpack/decoder.ex @@ -233,7 +233,8 @@ defmodule Msgpack.Decoder do base_datetime = NaiveDateTime.from_erl!(erlang_datetime) if nanoseconds > 0 do - NaiveDateTime.add(base_datetime, nanoseconds, :nanosecond) + microseconds = div(nanoseconds, 1000) + %{base_datetime | microsecond: {microseconds, 6}} else base_datetime end @@ -250,7 +251,8 @@ defmodule Msgpack.Decoder do base_datetime = NaiveDateTime.from_erl!(erlang_datetime) if nanoseconds > 0 do - NaiveDateTime.add(base_datetime, nanoseconds, :nanosecond) + microseconds = div(nanoseconds, 1000) + %{base_datetime | microsecond: {microseconds, 6}} else base_datetime end diff --git a/mix.exs b/mix.exs index 161d5f8..acb56b7 100644 --- a/mix.exs +++ b/mix.exs @@ -8,7 +8,7 @@ defmodule MsgpackElixir.MixProject do [ app: :msgpack_elixir, version: @version, - elixir: "~> 1.7", + elixir: "~> 1.12", start_permanent: Mix.env() == :prod, deps: deps(), aliases: aliases(),