Add common Checks to Github actions CI
ADD
.github/workflows/checks.yml
+name: Elixir Checks
+
+on: [push, pull_request]
+ # push:
+ # branches: [ master ]
+ # pull_request:
+ # branches: [ master ]
+
+
+jobs:
+ setup:
+ name: runner / cache dependencies
+ runs-on: ubuntu-latest
+ env:
+ MIX_ENV: dev
+ ACTIONS_ALLOW_UNSECURE_COMMANDS: true
+
+ strategy:
+ matrix:
+ include:
+ - elixir: 1.10.2
+ erlang: 22.3
+ steps:
+ - uses: actions/checkout@v2
+ - uses: actions/setup-elixir@v1
+ with:
+ elixir-version: ${{matrix.elixir}} # Define the elixir version [required]
+ otp-version: ${{matrix.erlang}} # Define the OTP version [required]
+
+ - name: Retrieve Mix Dependencies Cache
+ uses: actions/cache@v2
+ id: mix-cache # id to use in retrieve action
+ with:
+ path: deps
+ key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
+
+ - name: Retrieve Mix Dependencies Compilation Cache
+ uses: actions/cache@v2
+ id: mix-deps-compile-cache # id to use in retrieve action
+ with:
+ path: _build
+ key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-deps-compile-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
+ - name: Install Mix Dependencies
+ if: steps.mix-cache.outputs.cache-hit != 'true'
+ run: |
+ mix local.rebar --force
+ mix local.hex --force
+ mix deps.get
+
+ - name: Compile Mix Dependencies
+ if: steps.mix-deps-compile-cache.outputs.cache-hit != 'true'
+ run: mix deps.compile
+
+
+
+ compile:
+ name: runner / Compiler warnings as errors
+ runs-on: ubuntu-latest
+ needs: [setup]
+ env:
+ MIX_ENV: dev
+
+ strategy:
+ matrix:
+ include:
+ - elixir: 1.10.2
+ erlang: 22.3
+
+ steps:
+ - uses: actions/checkout@v2
+ - uses: actions/setup-elixir@v1
+ with:
+ elixir-version: ${{matrix.elixir}} # Define the elixir version [required]
+ otp-version: ${{matrix.erlang}} # Define the OTP version [required]
+
+ - name: Retrieve Mix Dependencies Cache
+ uses: actions/cache@v2
+ id: mix-cache # id to use in retrieve action
+ with:
+ path: deps
+ key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
+
+ - name: Retrieve Mix Dependencies Compilation Cache
+ uses: actions/cache@v2
+ id: mix-deps-compile-cache # id to use in retrieve action
+ with:
+ path: _build
+ key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-deps-compile-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
+
+ - name: Compile
+ run: mix compile --warnings-as-errors --force
+
+ credo:
+ name: check / credo
+ runs-on: ubuntu-latest
+ needs: [setup]
+ env:
+ MIX_ENV: dev
+
+ strategy:
+ matrix:
+ include:
+ - elixir: 1.10.2
+ erlang: 22.3
+
+ steps:
+ - uses: actions/checkout@v2
+ - uses: actions/setup-elixir@v1
+ with:
+ elixir-version: ${{matrix.elixir}} # Define the elixir version [required]
+ otp-version: ${{matrix.erlang}} # Define the OTP version [required]
+
+ - name: Retrieve Mix Dependencies Cache
+ uses: actions/cache@v2
+ id: mix-cache # id to use in retrieve action
+ with:
+ path: deps
+ key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
+
+ - name: Retrieve Mix Dependencies Compilation Cache
+ uses: actions/cache@v2
+ id: mix-deps-compile-cache # id to use in retrieve action
+ with:
+ path: _build
+ key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-deps-compile-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
+
+ - name: Credo
+ run: mix credo --strict
+
+ formatter:
+ name: check / formatter
+ runs-on: ubuntu-latest
+ needs: [setup]
+ env:
+ MIX_ENV: dev
+
+ strategy:
+ matrix:
+ include:
+ - elixir: 1.10.2
+ erlang: 22.3
+
+ steps:
+ - uses: actions/checkout@v2
+ - uses: actions/setup-elixir@v1
+ with:
+ elixir-version: ${{matrix.elixir}} # Define the elixir version [required]
+ otp-version: ${{matrix.erlang}} # Define the OTP version [required]
+
+ - name: Retrieve Mix Dependencies Cache
+ uses: actions/cache@v2
+ id: mix-cache # id to use in retrieve action
+ with:
+ path: deps
+ key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
+
+ - name: Retrieve Mix Dependencies Compilation Cache
+ uses: actions/cache@v2
+ id: mix-deps-compile-cache # id to use in retrieve action
+ with:
+ path: _build
+ key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-deps-compile-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
+
+ - name: Check Formatting
+ run: mix format --check-formatted
+
+ dialyzer:
+ name: check / dialyzer
+ needs: [setup]
+ runs-on: ubuntu-latest
+ env:
+ MIX_ENV: dev
+
+ strategy:
+ matrix:
+ include:
+ - elixir: 1.10.2
+ erlang: 22.3
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: Setup elixir
+ uses: actions/setup-elixir@v1
+ with:
+ elixir-version: ${{matrix.elixir}} # Define the elixir version [required]
+ otp-version: ${{matrix.erlang}} # Define the OTP version [required]
+ - name: Retrieve Mix Dependencies Cache
+ uses: actions/cache@v2
+ id: mix-cache # id to use in retrieve action
+ with:
+ path: deps
+ key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
+
+ - name: Retrieve Mix Dependencies Compilation Cache
+ uses: actions/cache@v2
+ id: mix-deps-compile-cache # id to use in retrieve action
+ with:
+ path: _build
+ key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-deps-compile-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
+
+ - name: Retrieve PLT Cache
+ uses: actions/cache@v1
+ id: plt-cache
+ with:
+ path: priv/plts
+ key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-plts-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
+
+ - name: Create PLTs
+ if: steps.plt-cache.outputs.cache-hit != 'true'
+ run: |
+ mkdir -p priv/plts
+ mix dialyzer --plt
+
+ - name: Run dialyzer
+ run: mix dialyzer --no-check --halt-exit-status
+
+
+
+
+
\ No newline at end of file

MODIFY
mix.exs
mix.exs
@@ -18,6 +18,7 @@ defmodule KafkaEx.Mixfile do
description: description(),
package: package(),
deps: deps(),
+ dialyzer: dialyzer(),
docs: [
main: "readme",
extras: [
@@ -68,4 +69,11 @@ defmodule KafkaEx.Mixfile do
links: %{"Github" => "https://github.com/kafkaex/kafka_ex"}
]
end
+
+ defp dialyzer do
+ [
+ plt_core_path: "priv/plts",
+ plt_file: {:no_warn, "priv/plts/dialyzer.plt"}
+ ]
+ end
end

Add common Checks to Github actions CI