Configure CI/CD on main branch #150
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: push | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} | |
jobs: | |
elixir: | |
name: Elixir ${{ matrix.elixir }} (OTP ${{ matrix.otp }}) | |
runs-on: ubuntu-latest | |
env: | |
MIX_ENV: test | |
services: | |
db: | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_DB: postgres | |
image: postgres:14-alpine | |
ports: ['5432:5432'] | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
strategy: | |
matrix: | |
include: | |
- elixir: '1.15.4' | |
otp: '26' | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Elixir | |
uses: erlef/setup-beam@v1 | |
with: | |
elixir-version: ${{ matrix.elixir }} | |
otp-version: ${{ matrix.otp }} | |
version-type: strict | |
- name: Restore Mix Dependencies Cache | |
uses: actions/cache@v3 | |
id: mix-deps | |
with: | |
path: deps | |
key: mix-deps-${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }} | |
restore-keys: | | |
mix-deps-${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ env.cache-name }}- | |
mix-deps-${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}- | |
- name: Restore Mix Build Cache | |
uses: actions/cache@v3 | |
id: mix-build | |
with: | |
path: _build | |
key: mix-build-${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }} | |
restore-keys: | | |
mix-build-${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ env.cache-name }}- | |
mix-build-${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}- | |
- name: Restore PLT cache | |
uses: actions/cache@v3 | |
id: plt-cache | |
with: | |
path: priv/plts | |
key: plt-${{ runner.os }}-${{ matrix.elixir }}-${{ matrix.otp }}-${{ hashFiles('**/mix.lock') }} | |
restore-keys: plt-${{ runner.os }}-${{ matrix.elixir }}-${{ matrix.otp }}-${{ hashFiles('**/mix.lock') }} | |
- name: Install Mix Dependencies | |
if: steps.mix-deps.outputs.cache-hit != 'true' | |
run: | | |
mix local.rebar --force | |
mix local.hex --force | |
mix deps.get | |
- name: Compile Project | |
run: | | |
MIX_ENV=test mix compile --warnings-as-errors | |
MIX_ENV=dev mix compile --warnings-as-errors | |
- name: Check Unused Dependencies | |
run: mix deps.unlock --check-unused | |
- name: Check Code Formatting | |
run: mix format --check-formatted | |
- name: Run Tests | |
run: mix test --trace --slowest 10 | |
- name: Run Credo | |
run: mix credo --strict | |
- name: Create PLT | |
if: steps.plt-cache.outputs.cache-hit != 'true' | |
run: MIX_ENV=dev mix dialyzer --plt | |
- name: Run Dialyzer | |
run: MIX_ENV=dev mix dialyzer --no-check --halt-exit-status --format github |