diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5264d75..d477062 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,6 +71,15 @@ jobs: restore-keys: | ${{ runner.os }}-mix- + - name: Fetch PLT Cache + uses: actions/cache@v4 + with: + key: ${{ runner.os }}-plt-${{ hashFiles('mix.lock') }} + restore-keys: | + ${{ runner.os }}-plt- + path: | + priv/plts + - name: Install run: | mix local.hex --force @@ -88,3 +97,10 @@ jobs: - name: Check Credo run: mix credo if: always() + + - name: Run Dialyzer + # Two formats are included for ease of debugging and it is lightly recommended to use both, see https://github.com/jeremyjh/dialyxir/issues/530 for reasoning + # --format github is helpful to print the warnings in a way that GitHub understands and can place on the /files page of a PR + # --format dialyxir allows the raw GitHub actions logs to be useful because they have the full warning printed + run: mix dialyzer --format github --format dialyxir + if: always() diff --git a/.gitignore b/.gitignore index 6821265..74ea63e 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,7 @@ together-*.tar # Temporary files, for example, from tests. /tmp/ + +# Dialyzer plt files +/priv/plts/*.plt +/priv/plts/*.plt.hash diff --git a/mix.exs b/mix.exs index 1002040..fbe6e37 100644 --- a/mix.exs +++ b/mix.exs @@ -13,7 +13,14 @@ defmodule Together.MixProject do docs: docs(), name: "Together Elixir Common", source_url: "https://github.com/togethercomputer/elixir-common", - homepage_url: "https://github.com/togethercomputer/elixir-common" + homepage_url: "https://github.com/togethercomputer/elixir-common", + + # Dialyzer + dialyzer: [ + # Put the project-level PLT in the priv/ directory (instead of the default _build/ location) + plt_file: {:no_warn, "priv/plts/project.plt"}, + plt_add_apps: [:ex_unit, :mix] + ] ] end @@ -26,6 +33,7 @@ defmodule Together.MixProject do defp deps do [ {:credo, "~> 1.7", only: [:dev, :test], runtime: false}, + {:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false}, {:ecto, "~> 3.5", optional: true}, {:ex_doc, "~> 0.38", only: [:dev], runtime: false} ] diff --git a/mix.lock b/mix.lock index d6680df..ab0d603 100644 --- a/mix.lock +++ b/mix.lock @@ -2,8 +2,10 @@ "bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"}, "credo": {:hex, :credo, "1.7.12", "9e3c20463de4b5f3f23721527fcaf16722ec815e70ff6c60b86412c695d426c1", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "8493d45c656c5427d9c729235b99d498bd133421f3e0a683e5c1b561471291e5"}, "decimal": {:hex, :decimal, "2.3.0", "3ad6255aa77b4a3c4f818171b12d237500e63525c2fd056699967a3e7ea20f62", [:mix], [], "hexpm", "a4d66355cb29cb47c3cf30e71329e58361cfcb37c34235ef3bf1d7bf3773aeac"}, + "dialyxir": {:hex, :dialyxir, "1.4.5", "ca1571ac18e0f88d4ab245f0b60fa31ff1b12cbae2b11bd25d207f865e8ae78a", [:mix], [{:erlex, ">= 0.2.7", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "b0fb08bb8107c750db5c0b324fa2df5ceaa0f9307690ee3c1f6ba5b9eb5d35c3"}, "earmark_parser": {:hex, :earmark_parser, "1.4.44", "f20830dd6b5c77afe2b063777ddbbff09f9759396500cdbe7523efd58d7a339c", [:mix], [], "hexpm", "4778ac752b4701a5599215f7030989c989ffdc4f6df457c5f36938cc2d2a2750"}, "ecto": {:hex, :ecto, "3.13.0", "7528ef4f3a4cdcfebeb7eb6545806c8109529b385a69f701fc3d77b5b8bde6e7", [:mix], [{:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "061f095f1cc097f71f743b500affc792d6869df22b1946a73ab5495eb9b4a280"}, + "erlex": {:hex, :erlex, "0.2.7", "810e8725f96ab74d17aac676e748627a07bc87eb950d2b83acd29dc047a30595", [:mix], [], "hexpm", "3ed95f79d1a844c3f6bf0cea61e0d5612a42ce56da9c03f01df538685365efb0"}, "ex_doc": {:hex, :ex_doc, "0.38.2", "504d25eef296b4dec3b8e33e810bc8b5344d565998cd83914ffe1b8503737c02", [:mix], [{:earmark_parser, "~> 1.4.44", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "732f2d972e42c116a70802f9898c51b54916e542cc50968ac6980512ec90f42b"}, "file_system": {:hex, :file_system, "1.1.0", "08d232062284546c6c34426997dd7ef6ec9f8bbd090eb91780283c9016840e8f", [:mix], [], "hexpm", "bfcf81244f416871f2a2e15c1b515287faa5db9c6bcf290222206d120b3d43f6"}, "jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"},