Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run Dialyzer in CI #3

Merged
merged 5 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 57 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
otp-version: ${{ env.OTP_VERSION }}
elixir-version: ${{ env.ELIXIR_VERSION}}

- name: Cache /_build and /deps
- name: Cache Mix compiled stuff
uses: actions/cache@v3
id: cache-mix
with:
Expand All @@ -48,6 +48,62 @@ jobs:
- name: Check for formatted code
run: mix format --check-formatted

dialyzer:
name: Dialyze
runs-on: ubuntu-20.04

env:
ELIXIR_VERSION: "1.15"
OTP_VERSION: "26.1"

steps:
- name: Check out this repository
uses: actions/checkout@v4

- name: Install Erlang and Elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{ env.OTP_VERSION }}
elixir-version: ${{ env.ELIXIR_VERSION}}

- name: Cache Mix compiled stuff
uses: actions/cache@v3
id: cache-mix
with:
path: |
_build
deps
key: |
mix-elixir${{ env.ELIXIR_VERSION }}-otp${{ env.OTP_VERSION }}-${{ hashFiles('mix.lock') }}-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: |
mix-elixir${{ env.ELIXIR_VERSION }}-otp${{ env.OTP_VERSION }}-${{ hashFiles('mix.lock') }}-${{ github.run_id }}-
mix-elixir${{ env.ELIXIR_VERSION }}-otp${{ env.OTP_VERSION }}-${{ hashFiles('mix.lock') }}-

# Don't cache PLTs based on mix.lock hash, as Dialyzer can incrementally update even old
# ones. Cache key based on Elixir and Erlang version (also useful when running in matrix).
- name: Cache Dialyzer's PLT
uses: actions/cache@v3
id: cache-plt
with:
path: priv/plts
key: |
plt-otp${{ env.OTP_VERSION }}-elixir${{ env.ELIXIR_VERSION }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
plt-otp${{ env.OTP_VERSION }}-elixir${{ env.ELIXIR_VERSION }}-

# Create PLTs if no cache was found
- name: Create PLTs
if: steps.cache-plt.outputs.cache-hit != 'true'
run: |
mkdir -p priv/plts
mix dialyzer --plt

- name: Install dependencies
run: mix deps.get

- name: Run Dialyzer
run: mix dialyzer --format github

test:
name: Test (Erlang ${{ matrix.otp }}, Elixir ${{ matrix.elixir }}, Toxiproxy ${{ matrix.toxiproxy }})

Expand Down
17 changes: 14 additions & 3 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ defmodule ToxiproxyEx.MixProject do
start_permanent: Mix.env() == :prod,
deps: deps(),

# Dialyzer
dialyzer: [
plt_local_path: "priv/plts",
plt_core_path: "priv/plts",
plt_add_apps: [:ssl, :crypto, :mix, :ex_unit, :erts, :kernel, :stdlib]
],

# Hex
description: "Elixir Client for Toxiproxy",
package: package(),
Expand All @@ -34,9 +41,13 @@ defmodule ToxiproxyEx.MixProject do
{:jason, ">= 1.0.0"},
{:castore, "~> 1.0.3"},
{:mint, "~> 1.0"},
{:ex_doc, "~> 0.23", only: :dev, runtime: false},
{:dialyxir, "~> 1.4", only: [:dev], runtime: false}
]
{:ex_doc, "~> 0.23", only: :dev, runtime: false}
] ++
if Version.match?(System.version(), "~> 1.12") do
[{:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false}]
else
[]
end
end

defp package do
Expand Down