Skip to content

Commit

Permalink
Add ci
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziosestito committed Jul 18, 2022
1 parent 130312b commit 818abb7
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 2 deletions.
122 changes: 122 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: CI

on:
push:
branches: [main]
pull_request:
release:
types: [published]
workflow_dispatch:
repository_dispatch:
types: [start-ci]

env:
ELIXIR_VERSION: 1.13.4
OTP_VERSION: 24
MIX_ENV: test

jobs:
elixir-deps:
name: Elixir dependencies
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup
uses: erlef/setup-beam@v1
with:
elixir-version: ${{ env.ELIXIR_VERSION }}
otp-version: ${{ env.OTP_VERSION }}
env:
ImageOS: ubuntu20

- name: Retrieve Cached Dependencies
uses: actions/cache@v3
id: mix-cache
with:
path: |
deps
_build/test
priv/plts
key: ${{ runner.os }}-${{ env.OTP_VERSION }}-${{ env.ELIXIR_VERSION }}-${{ hashFiles('mix.lock') }}

- name: Install Dependencies
if: steps.mix-cache.outputs.cache-hit != 'true'
run: |
mkdir -p priv/plts
mix local.rebar --force
mix local.hex --force
mix deps.get
mix deps.compile --warnings-as-errors
mix dialyzer --plt
static-code-analysis:
name: Static Code Analysis
needs: elixir-deps
runs-on: ubuntu-20.04

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup
uses: erlef/setup-beam@v1
with:
elixir-version: ${{ env.ELIXIR_VERSION }}
otp-version: ${{ env.OTP_VERSION }}
env:
ImageOS: ubuntu20

- name: Retrieve Elixir Cached Dependencies
uses: actions/cache@v3
id: mix-cache
with:
path: |
deps
_build/test
priv/plts
key: ${{ runner.os }}-${{ env.OTP_VERSION }}-${{ env.ELIXIR_VERSION }}-${{ hashFiles('mix.lock') }}

- name: Check Code Format
run: mix format --check-formatted

- name: Run Credo
run: mix credo --strict

- name: Run Dialyzer
run: mix dialyzer

test:
name: Test
needs: elixir-deps
runs-on: ubuntu-20.04

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup
uses: erlef/setup-beam@v1
with:
elixir-version: ${{ env.ELIXIR_VERSION }}
otp-version: ${{ env.OTP_VERSION }}

- name: Retrieve Cached Dependencies
uses: actions/cache@v3
id: mix-cache
with:
path: |
deps
_build/test
priv/plts
key: ${{ runner.os }}-${{ env.OTP_VERSION }}-${{ env.ELIXIR_VERSION }}-${{ hashFiles('mix.lock') }}

- name: Run test
run: mix test --color --trace --slowest 10
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ services:
- 15672:15672
environment:
RABBITMQ_DEFAULT_USER: wanda
RABBITMQ_DEFAULT_PASS: wanda
RABBITMQ_DEFAULT_PASS: wanda
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ defmodule Wanda.MixProject do
{:yaml_elixir, "~> 2.9"},
# test deps
{:credo, "~> 1.6", only: [:dev, :test], runtime: false},
{:dialyxir, "~> 1.0", only: [:dev], runtime: false},
{:dialyxir, "~> 1.0", only: [:dev, :test], runtime: false},
{:mox, "~> 1.0", only: :test},
{:ex_machina, "~> 2.7.0"},
{:faker, "~> 0.17", only: :test}
Expand Down

0 comments on commit 818abb7

Please sign in to comment.