diff --git a/.github/workflows/elixir_ci.yml b/.github/workflows/elixir_ci.yml new file mode 100644 index 0000000..490aa73 --- /dev/null +++ b/.github/workflows/elixir_ci.yml @@ -0,0 +1,73 @@ +# book_my_gigs_test/.github/workflows/elixir_ci.yml +name: Elixir CI + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + +env: + MIX_ENV: test + +permissions: + contents: read + +jobs: + build: + name: Build and test + runs-on: ubuntu-latest + + strategy: + matrix: + elixir: [1.15.2] + otp: [22.2.8] + + steps: + - uses: actions/checkout@v4 + + - name: Set up Elixir + uses: erlef/setup-beam@61e01a43a562a89bfc54c7f9a378ff67b03e4a21 + with: + elixir-version: ${{ matrix.elixir }} + otp-version: ${{ matrix.otp }} + + - name: Retrieve mix dependencies + uses: actions/cache@v3 + id: mix-cache + with: + path: deps + key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} + restore-keys: ${{ runner.os }}-mix- + + - 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: Check formatting + run: mix format --check-formatted + + - name: Run Credo + run: mix credo + + - name: Retrieve PLT Cache + uses: actions/cache@v3 + 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 prv/plts + mix dialyzer --plt + + - name: Run Dialyzer + run: mix dialyzer --no-check --halt-exit-status + + - name: Run tests + run: mix test diff --git a/mix.exs b/mix.exs index 4189bfd..4f3c3c2 100644 --- a/mix.exs +++ b/mix.exs @@ -17,7 +17,8 @@ defmodule BookMyGigs.MixProject do "coveralls.post": :test, "coveralls.html": :test, "coveralls.cobertura": :test - ] + ], + dialyzer: dialyzer() ] end @@ -94,4 +95,11 @@ defmodule BookMyGigs.MixProject do ] ] end + + defp dialyzer do + [ + plt_core_path: "priv/plts", + plt_file: {:no_warn, "priv/plts/dialyzer.plt"} + ] + end end