Skip to content
This repository has been archived by the owner on Dec 15, 2023. It is now read-only.

Commit

Permalink
Add CI config
Browse files Browse the repository at this point in the history
  • Loading branch information
dkarter committed Sep 23, 2021
1 parent 1e4029b commit 35c2055
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 1 deletion.
79 changes: 79 additions & 0 deletions .github/workflows/elixir.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Elixir CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

env:
MIX_ENV: test

jobs:
test:
runs-on: ubuntu-latest

services:
postgres:
image: postgres
ports:
- 5432:5432
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres

strategy:
matrix:
elixir: [1.12.2]
otp: [23.3.4.5]

steps:
- uses: actions/checkout@v2

- name: Setup Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: ${{ matrix.elixir }} # Define the elixir version [required]
otp-version: ${{ matrix.otp }} # Define the OTP version [required]

- name: Retrieve Mix Dependencies Cache
uses: actions/cache@v1
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: 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: Run Tests
run: mix test
env:
DATABASE_HOST: postgres
DATABASE_PORT: ${{ job.services.postgres.ports[5432] }}

- 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
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ defmodule Snagg.MixProject do
# Type `mix help deps` for examples and options.
defp deps do
[
{:credo, "~> 1.5", only: :dev, runtime: false},
{:credo, "~> 1.5", only: [:dev, :test], runtime: false},
{:dialyxir, "~> 1.1", only: [:dev, :test], runtime: false},
{:ecto_sql, "~> 3.6"},
{:esbuild, "~> 0.2", runtime: Mix.env() == :dev},
Expand Down

0 comments on commit 35c2055

Please sign in to comment.