Skip to content

Commit

Permalink
Add dialyzer to CI workflow (#71)
Browse files Browse the repository at this point in the history
* Add mix dialyzer to ci workflow

* Define location for PLTs

* Add PLT caching and cache restore

* Define separate job for dialyzer

* Define separate check_format job in CI

---------

Co-authored-by: Clifton McIntosh <[email protected]>
  • Loading branch information
cliftonmcintosh and Clifton McIntosh authored Dec 3, 2024
1 parent 3075b09 commit e46917c
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 4 deletions.
88 changes: 85 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ jobs:
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}}
Expand All @@ -59,8 +61,6 @@ jobs:
- run: mix deps.get

- run: mix format --check-formatted

- run: mix deps.unlock --check-unused

- run: mix deps.compile
Expand All @@ -70,3 +70,85 @@ jobs:
- run: mix credo --strict --format=oneline

- run: mix test --warnings-as-errors --cover

dialyzer:
runs-on: ubuntu-22.04
env:
MIX_ENV: test

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: test

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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ erl_crash.dump

# Also ignore archive artifacts (built via "mix archive.build").
*.ez

# PLT cache
/priv/plts/*.plt
/priv/plts/*.plt.hash
4 changes: 3 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ defmodule RedisMutex.Mixfile do
dialyzer: [
ignore_warnings: ".dialyzer.ignore-warnings",
list_unused_filters: true,
plt_add_apps: [:mix]
plt_add_apps: [:mix],
plt_file: {:no_warn, "priv/plts/project.plt"},
plt_core_path: "priv/plts/core.plt"
],
package: package(),
test_coverage: [summary: [threshold: 90]]
Expand Down
Empty file added priv/.gitkeep
Empty file.

0 comments on commit e46917c

Please sign in to comment.