Skip to content

Commit

Permalink
build(CI/CD): Added elixir_ci.yml 'Build and test' job for Github Act…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
Gabrielparizet committed Jun 5, 2024
1 parent 77f89e6 commit 45b92d5
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 1 deletion.
73 changes: 73 additions & 0 deletions .github/workflows/elixir_ci.yml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 9 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ defmodule BookMyGigs.MixProject do
"coveralls.post": :test,
"coveralls.html": :test,
"coveralls.cobertura": :test
]
],
dialyzer: dialyzer()
]
end

Expand Down Expand Up @@ -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

0 comments on commit 45b92d5

Please sign in to comment.