diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4fbfe9a..e05659f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,13 @@ name: Test -on: push - +on: + pull_request: + types: + - opened + - synchronize + - reopened + push: + branches: + - main jobs: unit-test: runs-on: ubuntu-latest @@ -38,6 +45,7 @@ jobs: - run: mix deps.get - run: mix credo dialyzer: + name: Run Dialyzer for type checking runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -47,15 +55,25 @@ jobs: with: path: deps key: ${{ runner.os }}-deps - - name: Cache PLT - id: cache-plt - uses: actions/cache@v2 - with: - path: priv/plts - key: ${{ runner.os }}-plts - uses: erlef/setup-beam@v1 with: otp-version: "22.2" elixir-version: "1.9.4" - - run: mix deps.get - - run: mix dialyzer + - name: Restore PLT cache + uses: actions/cache@v2 + id: plt_cache + with: + key: | + ${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-plt + restore-keys: | + ${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-plt + path: | + priv/plts + # Create PLTs if no cache was found + - name: Create PLTs + if: steps.plt_cache.outputs.cache-hit != 'true' + run: mix dialyzer --plt + - name: Fetch dependencies + run: mix dialyzer + - name: Run dialyzer + run: mix dialyzer diff --git a/mix.exs b/mix.exs index 88b9216..69e2016 100644 --- a/mix.exs +++ b/mix.exs @@ -36,7 +36,7 @@ defmodule Atomex.MixProject do # Dev {:credo, "~> 1.5", only: [:dev, :test], runtime: false}, - {:dialyxir, "~> 1.0", only: :dev, runtime: false}, + {:dialyxir, "~> 1.0", only: [:dev, :test], runtime: false}, {:earmark, "~> 1.4", only: :dev, runtime: false}, {:ex_doc, "~> 0.23", only: :dev, runtime: false}, {:excoveralls, "~> 0.13", only: :test},