diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9b2afb2..574c33a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ on: - main jobs: - mix_test: + tests: runs-on: ubuntu-latest env: MIX_ENV: test @@ -58,13 +58,84 @@ jobs: steps: - uses: actions/checkout@v4 - uses: erlef/setup-beam@v1 + id: beam with: elixir-version: '1.18' otp-version: '27' - - run: rm mix.lock && mix deps.get --only test - - run: mix compile --force --warnings-as-errors - - run: mix format --check-formatted + + - name: Restore deps + id: restore-mix-deps + if: ${{ !contains(github.event.*.labels.*.name, 'no-cache') }} + uses: actions/cache/restore@v4 + env: + cache-version: &cache-version v1 + cache-name: &cache-deps-name cache-deps + with: + path: &cache-deps-paths | + deps + ~/.hex + ~/.mix + key: &cache-deps-key ${{ env.cache-name }}-${{ env.cache-version }}-${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-${{ hashFiles('mix.lock') }}-${{ github.run_id }}-${{ github.run_attempt }} + restore-keys: &cache-deps-restore-keys | + ${{ env.cache-name }}-${{ env.cache-version }}-${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-${{ hashFiles('mix.lock') }}- + + - name: Install deps + id: deps + run: rm mix.lock && mix deps.get --only test + + - name: Cache mix deps + id: cache-deps + uses: actions/cache/save@v4 + env: + cache-version: *cache-version + cache-name: *cache-deps-name + with: + path: *cache-deps-paths + key: *cache-deps-key + + - name: mix compile + id: compile + run: mix compile --force --warnings-as-errors + + - name: mix format + id: format + run: mix format --check-formatted + - run: ECTO_ADAPTER=sqlite mix test --warnings-as-errors - run: ECTO_ADAPTER=pg mix test --warnings-as-errors - run: ECTO_ADAPTER=myxql mix test --warnings-as-errors - run: ECTO_ADAPTER=tds mix test --warnings-as-errors + + - name: Restore PLTs + uses: actions/cache/restore@v4 + id: restore-plts + if: ${{ steps.compile.outcome == 'success' && !contains(github.event.*.labels.*.name, 'no-cache') }} + env: + cache-version: *cache-version + cache-name: plt_cache + with: + path: &cache-plts-paths | + priv/plts + key: &cache-plts-key ${{ env.cache-name }}-${{ env.cache-version }}-${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-${{ hashFiles('mix.lock') }}-${{ hashFiles('**/*.ex') }} + restore-keys: | + ${{ env.cache-name }}-${{ env.cache-version }}-${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-${{ hashFiles('mix.lock') }}- + ${{ env.cache-name }}-${{ env.cache-version }}-${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}- + + - name: Create PLTs + id: create-plts + if: ${{ steps.restore-plts.outputs.cache-hit != 'true' }} + run: mix dialyzer --plt + + - name: Cache PLTs + uses: actions/cache/save@v4 + if: ${{ steps.create-plts.outcome == 'success' }} + env: + cache-version: *cache-version + cache-name: plt_cache + with: + path: *cache-plts-paths + key: *cache-plts-key + + - name: Run Dialyzer + id: dialyzer + run: mix dialyzer diff --git a/.gitignore b/.gitignore index dc0fef3..0d3bb42 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,6 @@ data_migration_live_dashboard-*.tar *.db *.db-* + +# Dialyzer PLTs +priv/plts/ diff --git a/mix.exs b/mix.exs index 258894a..b6a9426 100644 --- a/mix.exs +++ b/mix.exs @@ -28,7 +28,11 @@ defmodule DataMigration.MixProject do ], deps: deps(), preferred_cli_env: ["test.all": :test, "test.adapters": :test], - aliases: aliases() + aliases: aliases(), + dialyzer: [ + plt_add_apps: [:ex_unit, :mix], + plt_file: {:no_warn, "priv/plts/data_migration.plt"} + ] ] end @@ -48,16 +52,17 @@ defmodule DataMigration.MixProject do {:phoenix_pubsub, "~> 2.1"}, # Adapters for testing - {:postgrex, "~> 0.19 or ~> 1.0", optional: true}, - {:myxql, "~> 0.8", optional: true}, {:ecto_sqlite3, "~> 0.17", optional: true}, + {:myxql, "~> 0.8", optional: true}, + {:postgrex, "~> 0.19 or ~> 1.0", optional: true}, {:tds, "~> 2.2", optional: true}, # Dev/Test - {:ex_doc, "~> 0.34", only: :dev, runtime: false, warn_if_outdated: true}, - {:tidewave, "~> 0.4", only: :dev}, + {:bandit, "~> 1.0", only: [:dev]}, + {:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false}, + {:ex_doc, "~> 0.34", only: [:dev], runtime: false, warn_if_outdated: true}, {:lazy_html, "~> 0.1", only: [:test]}, - {:bandit, "~> 1.0", only: :dev} + {:tidewave, "~> 0.4", only: [:dev]} ] end diff --git a/mix.lock b/mix.lock index 8b60823..b461954 100644 --- a/mix.lock +++ b/mix.lock @@ -4,11 +4,13 @@ "circular_buffer": {:hex, :circular_buffer, "1.0.0", "25c004da0cba7bd8bc1bdabded4f9a902d095e20600fd15faf1f2ffbaea18a07", [:mix], [], "hexpm", "c829ec31c13c7bafd1f546677263dff5bfb006e929f25635878ac3cfba8749e5"}, "db_connection": {:hex, :db_connection, "2.8.1", "9abdc1e68c34c6163f6fb96a96532272d13ad7ca45262156ae8b7ec6d9dc4bec", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "a61a3d489b239d76f326e03b98794fb8e45168396c925ef25feb405ed09da8fd"}, "decimal": {:hex, :decimal, "2.3.0", "3ad6255aa77b4a3c4f818171b12d237500e63525c2fd056699967a3e7ea20f62", [:mix], [], "hexpm", "a4d66355cb29cb47c3cf30e71329e58361cfcb37c34235ef3bf1d7bf3773aeac"}, + "dialyxir": {:hex, :dialyxir, "1.4.7", "dda948fcee52962e4b6c5b4b16b2d8fa7d50d8645bbae8b8685c3f9ecb7f5f4d", [:mix], [{:erlex, ">= 0.2.8", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "b34527202e6eb8cee198efec110996c25c5898f43a4094df157f8d28f27d9efe"}, "earmark_parser": {:hex, :earmark_parser, "1.4.44", "f20830dd6b5c77afe2b063777ddbbff09f9759396500cdbe7523efd58d7a339c", [:mix], [], "hexpm", "4778ac752b4701a5599215f7030989c989ffdc4f6df457c5f36938cc2d2a2750"}, "ecto": {:hex, :ecto, "3.13.5", "9d4a69700183f33bf97208294768e561f5c7f1ecf417e0fa1006e4a91713a834", [: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", "df9efebf70cf94142739ba357499661ef5dbb559ef902b68ea1f3c1fabce36de"}, "ecto_sql": {:hex, :ecto_sql, "3.13.2", "a07d2461d84107b3d037097c822ffdd36ed69d1cf7c0f70e12a3d1decf04e2e1", [:mix], [{:db_connection, "~> 2.4.1 or ~> 2.5", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.13.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.7", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.19 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.1 or ~> 2.2", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "539274ab0ecf1a0078a6a72ef3465629e4d6018a3028095dc90f60a19c371717"}, "ecto_sqlite3": {:hex, :ecto_sqlite3, "0.22.0", "edab2d0f701b7dd05dcf7e2d97769c106aff62b5cfddc000d1dd6f46b9cbd8c3", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:ecto, "~> 3.13.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:ecto_sql, "~> 3.13.0", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:exqlite, "~> 0.22", [hex: :exqlite, repo: "hexpm", optional: false]}], "hexpm", "5af9e031bffcc5da0b7bca90c271a7b1e7c04a93fecf7f6cd35bc1b1921a64bd"}, "elixir_make": {:hex, :elixir_make, "0.9.0", "6484b3cd8c0cee58f09f05ecaf1a140a8c97670671a6a0e7ab4dc326c3109726", [:mix], [], "hexpm", "db23d4fd8b757462ad02f8aa73431a426fe6671c80b200d9710caf3d1dd0ffdb"}, + "erlex": {:hex, :erlex, "0.2.8", "cd8116f20f3c0afe376d1e8d1f0ae2452337729f68be016ea544a72f767d9c12", [:mix], [], "hexpm", "9d66ff9fedf69e49dc3fd12831e12a8a37b76f8651dd21cd45fcf5561a8a7590"}, "ex_doc": {:hex, :ex_doc, "0.39.1", "e19d356a1ba1e8f8cfc79ce1c3f83884b6abfcb79329d435d4bbb3e97ccc286e", [: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", "8abf0ed3e3ca87c0847dfc4168ceab5bedfe881692f1b7c45f4a11b232806865"}, "exqlite": {:hex, :exqlite, "0.33.1", "0465fdb997be174edeba6a27496fa27dfe8bc79ef1324a723daa8f0e8579da24", [:make, :mix], [{:cc_precompiler, "~> 0.1", [hex: :cc_precompiler, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.8", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "b3db0c9ae6e5ee7cf84dd0a1b6dc7566b80912eb7746d45370f5666ed66700f9"}, "finch": {:hex, :finch, "0.20.0", "5330aefb6b010f424dcbbc4615d914e9e3deae40095e73ab0c1bb0968933cadf", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.6.2 or ~> 1.7", [hex: :mint, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.4 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:nimble_pool, "~> 1.1", [hex: :nimble_pool, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "2658131a74d051aabfcba936093c903b8e89da9a1b63e430bee62045fa9b2ee2"},