diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml new file mode 100644 index 0000000..b568233 --- /dev/null +++ b/.github/workflows/elixir.yml @@ -0,0 +1,54 @@ +name: Elixir CI + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + build: + name: Build and test + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + otp: + - 23.3.4 + - 24.1.1 + elixir: + - 1.11.4 + - 1.12.3 + include: + - otp: 24.1.1 + elixir: 1.12.3 + lint: lint + + steps: + - uses: actions/checkout@v2 + - name: Set up Elixir + uses: erlef/setup-beam@v1 + with: + elixir-version: ${{ matrix.elixir }} + otp-version: ${{ matrix.otp }} + + - name: Restore dependencies cache + uses: actions/cache@v2 + with: + path: deps + key: ${{ runner.os }}-mix-${{ matrix.elixir}}-${{ matrix.otp }}-${{ hashFiles('**/mix.lock') }} + + - name: Install dependencies + run: mix deps.get + + - run: mix format --check-formatted + if: ${{ matrix.lint }} + + - run: mix deps.compile + + - run: mix compile --warnings-as-errors + if: ${{ matrix.lint }} + + - name: Run tests + run: mix test diff --git a/lib/tds_encoding.ex b/lib/tds_encoding.ex index ed0d87f..eda72bf 100644 --- a/lib/tds_encoding.ex +++ b/lib/tds_encoding.ex @@ -37,7 +37,7 @@ defmodule Tds.Encoding do use Rustler, otp_app: :tds_encoding, crate: "tds_encoding", - mode: if Mix.env() == :prod, do: :release, else: :debug + mode: if(Mix.env() == :prod, do: :release, else: :debug) @doc """ Encodes utf-8 string using given codepage. If there are any unknown codes they diff --git a/mix.exs b/mix.exs index 6c88ac6..1264538 100644 --- a/mix.exs +++ b/mix.exs @@ -9,8 +9,9 @@ defmodule Tds.Encoding.MixProject do elixir: "~> 1.9", start_permanent: Mix.env() == :prod, deps: deps(), - description: "String encoding/decoding NIF using rust [encoding](https://crates.io/crates/encoding) library", - package: package(), + description: + "String encoding/decoding NIF using rust [encoding](https://crates.io/crates/encoding) library", + package: package() ] end @@ -25,7 +26,7 @@ defmodule Tds.Encoding.MixProject do defp deps do [ {:rustler, "~> 0.22.0"}, - {:ex_doc, ">= 0.0.0", only: :dev, runtime: false}, + {:ex_doc, ">= 0.0.0", only: :dev, runtime: false} ] end @@ -35,8 +36,7 @@ defmodule Tds.Encoding.MixProject do maintainers: ["Milan Jarić"], licenses: ["MIT"], links: %{"GitHub" => "https://github.com/mjaric/tds-encoding"}, - files: - ~w(.formatter.exs mix.exs README.md lib native) + files: ~w(.formatter.exs mix.exs README.md lib native) ] end end diff --git a/mix.lock b/mix.lock index 63353d7..7edb73b 100644 --- a/mix.lock +++ b/mix.lock @@ -2,10 +2,11 @@ "earmark": {:hex, :earmark, "1.4.3", "364ca2e9710f6bff494117dbbd53880d84bebb692dafc3a78eb50aa3183f2bfd", [:mix], [], "hexpm", "8cf8a291ebf1c7b9539e3cddb19e9cef066c2441b1640f13c34c1d3cfc825fec"}, "earmark_parser": {:hex, :earmark_parser, "1.4.15", "b29e8e729f4aa4a00436580dcc2c9c5c51890613457c193cc8525c388ccb2f06", [:mix], [], "hexpm", "044523d6438ea19c1b8ec877ec221b008661d3c27e3b848f4c879f500421ca5c"}, "ex_doc": {:hex, :ex_doc, "0.25.3", "3edf6a0d70a39d2eafde030b8895501b1c93692effcbd21347296c18e47618ce", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "9ebebc2169ec732a38e9e779fd0418c9189b3ca93f4a676c961be6c1527913f5"}, + "jason": {:hex, :jason, "1.2.2", "ba43e3f2709fd1aa1dce90aaabfd039d000469c05c56f0b8e31978e03fa39052", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "18a228f5f0058ee183f29f9eae0805c6e59d61c3b006760668d8d18ff0d12179"}, "makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"}, "makeup_elixir": {:hex, :makeup_elixir, "0.15.1", "b5888c880d17d1cc3e598f05cdb5b5a91b7b17ac4eaf5f297cb697663a1094dd", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "db68c173234b07ab2a07f645a5acdc117b9f99d69ebf521821d89690ae6c6ec8"}, "makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"}, "nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"}, - "rustler": {:hex, :rustler, "0.22.0", "e2930f9d6933e910f87526bb0a7f904e32b62a7e838a3ca4a884ee7fdfb957ed", [:mix], [{:toml, "~> 0.5.2", [hex: :toml, repo: "hexpm", optional: false]}], "hexpm", "01f5989dd511ebec09be481e07d3c59773d5373c5061e09d3ebc3ef61811b49d"}, + "rustler": {:hex, :rustler, "0.22.2", "f92d6dba71bef6fe5f0d955649cb071127adc92f32a78890e8fa9939e59a1b41", [:mix], [{:jason, "~> 1.2", [hex: :jason, repo: "hexpm", optional: false]}, {:toml, "~> 0.5.2", [hex: :toml, repo: "hexpm", optional: false]}], "hexpm", "56b129141e86d60a2d670af9a2b55a9071e10933ef593034565af77e84655118"}, "toml": {:hex, :toml, "0.5.2", "e471388a8726d1ce51a6b32f864b8228a1eb8edc907a0edf2bb50eab9321b526", [:mix], [], "hexpm", "f1e3dabef71fb510d015fad18c0e05e7c57281001141504c6b69d94e99750a07"}, } diff --git a/test/tds_encoding_test.exs b/test/tds_encoding_test.exs index 4a94774..96af996 100644 --- a/test/tds_encoding_test.exs +++ b/test/tds_encoding_test.exs @@ -16,6 +16,7 @@ defmodule TdsEncodingTest do test "should decode broken string and replace unkinwn with `�` code" do assert "\u{c6b0}\u{c640}\u{fffd}\u{c559}" == decode(<<0xBF, 0xEC, 0xBF, 0xCD, 0xFF, 0xBE, 0xD3>>, "windows-949") + # same encoding/decoding as above but ecoding name is different assert "\u{c6b0}\u{c640}\u{fffd}\u{c559}" == decode(<<0xBF, 0xEC, 0xBF, 0xCD, 0xFF, 0xBE, 0xD3>>, "euc-kr")