diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a71bf84..198dbd8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,16 +19,19 @@ jobs: matrix: os: [ubuntu-22.04] elixir_version: [1.15, 1.16, 1.17] - otp_version: [25, 26, 27] + otp_version: [ 25, 26, 27] exclude: - otp_version: 27 elixir_version: 1.15 - otp_version: 27 elixir_version: 1.16 + steps: - uses: actions/checkout@v4 - - uses: erlef/setup-beam@v1 + - name: Set up Elixir + id: beam + uses: erlef/setup-beam@v1 with: otp-version: ${{matrix.otp_version}} elixir-version: ${{matrix.elixir_version}} @@ -44,8 +47,6 @@ jobs: - run: mix deps.get - - run: mix format --check-formatted - - run: mix deps.unlock --check-unused - run: mix deps.compile @@ -55,3 +56,85 @@ jobs: - run: mix credo --strict --format=oneline - run: mix test --warnings-as-errors --cover + + dialyzer: + runs-on: ubuntu-22.04 + env: + MIX_ENV: dev + + steps: + - uses: actions/checkout@v4 + + - name: Set up Elixir + id: beam + uses: erlef/setup-beam@v1 + with: + elixir-version: 1.16 + otp-version: 26 + + - uses: actions/cache@v4 + with: + path: | + deps + _build + key: deps-${{ runner.os }}-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }} + restore-keys: | + deps-${{ runner.os }}-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }} + + - run: mix deps.get + + - name: Restore PLT cache + id: plt_cache_restore + uses: actions/cache/restore@v3 + with: + key: | + plts-${{ runner.os }}-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }} + restore-keys: | + plts-${{ runner.os }}-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}- + path: | + priv/plts + + - name: Create PLTs + if: steps.plt_cache_restore.outputs.cache-hit != 'true' + run: mix dialyzer --plt + + - name: Save PLT cache + id: plt_cache_save + if: steps.plt_cache_restore.outputs.cache-hit != 'true' + uses: actions/cache/save@v3 + with: + key: | + plts-${{ runner.os }}-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }} + path: | + priv/plts + + - name: Run dialyzer + run: mix dialyzer --format github --format dialyxir + + check_format: + runs-on: ubuntu-22.04 + env: + MIX_ENV: dev + + steps: + - uses: actions/checkout@v4 + + - name: Set up Elixir + id: beam + uses: erlef/setup-beam@v1 + with: + elixir-version: 1.16 + otp-version: 26 + + - uses: actions/cache@v4 + with: + path: | + deps + _build + key: deps-${{ runner.os }}-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }} + restore-keys: | + deps-${{ runner.os }}-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }} + + - run: mix deps.get + + - run: mix format --check-formatted diff --git a/CHANGELOG.md b/CHANGELOG.md index 44950ae..4d98856 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # CHANGELOG +## v0.15.1 (2024-12-04) + +### Changed + +* Fix dialyzer errors ## v0.15.0 (2024-10-01) ### Changed diff --git a/lib/uinta/formatter/util.ex b/lib/uinta/formatter/util.ex index 579a016..3fdcebc 100644 --- a/lib/uinta/formatter/util.ex +++ b/lib/uinta/formatter/util.ex @@ -59,7 +59,7 @@ defmodule Uinta.Formatter.Util do @doc """ RFC3339 UTC "Zulu" format. """ - @spec format_timestamp(Logger.Formatter.time()) :: String.t() + @spec format_timestamp(Types.time()) :: String.t() def format_timestamp({date, time}) do IO.iodata_to_binary([format_date(date), ?T, format_time(time), ?Z]) end diff --git a/lib/uinta/plug.ex b/lib/uinta/plug.ex index 13a6700..7895cc4 100644 --- a/lib/uinta/plug.ex +++ b/lib/uinta/plug.ex @@ -98,7 +98,12 @@ if Code.ensure_loaded?(Plug) do @query_name_regex ~r/^\s*(?:query|mutation)\s+(\w+)|{\W+(\w+)\W+?{/m @type format :: :json | :map | :string - @type graphql_info :: %{type: String.t(), operation: String.t(), variables: String.t() | nil} + @type graphql_info :: %{ + type: String.t(), + operation: String.t(), + variables: String.t(), + query: String.t() | nil + } @type opts :: %{ level: Logger.level() | {module(), atom(), list()}, format: format(), @@ -217,7 +222,7 @@ if Code.ensure_loaded?(Plug) do end end - @spec format_line(map(), format()) :: iodata() | map() + @spec format_line(map(), format()) :: iodata() | map() | String.t() defp format_line(info, :map) do format_info(info) end @@ -269,11 +274,11 @@ if Code.ensure_loaded?(Plug) do @spec query(graphql_info(), opts()) :: String.t() | nil defp query(_, %{include_unnamed_queries: false}), do: nil - defp query(%{query: query}, _), do: query + defp query(%{query: query}, _) when not is_nil(query), do: query defp query(_, _), do: nil @spec variables(graphql_info() | nil) :: String.t() | nil - defp variables(%{variables: variables}), do: variables + defp variables(%{variables: variables}) when not is_nil(variables), do: variables defp variables(_), do: nil @spec graphql_info(Plug.Conn.t(), opts()) :: graphql_info() | nil diff --git a/mix.exs b/mix.exs index 332a156..57adecf 100644 --- a/mix.exs +++ b/mix.exs @@ -2,7 +2,7 @@ defmodule Uinta.MixProject do use Mix.Project @project_url "https://github.com/podium/uinta" - @version "0.15.0" + @version "0.15.1" def project do [