Skip to content

Instantly share code, notes, and snippets.

@georgiybykov
Created November 24, 2021 21:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save georgiybykov/069dcb8718d89a1151b9eea302b9a8df to your computer and use it in GitHub Desktop.
Save georgiybykov/069dcb8718d89a1151b9eea302b9a8df to your computer and use it in GitHub Desktop.
GitHub Actions for Elixir (extended version with shared dependencies)
# .github/workflows/elixir.yml
---
name: build
on: [push, pull_request]
jobs:
dependencies:
runs-on: ubuntu-latest
strategy:
matrix:
elixir: ['1.12']
otp: ['24']
steps:
- name: Cancel previous runs
uses: styfle/cancel-workflow-action@0.9.0
with:
access_token: ${{ github.token }}
- name: Checkout Github repo
uses: actions/checkout@v2
- name: Sets up an Erlang/OTP environment
uses: erlef/setup-beam@v1
with:
elixir-version: ${{ matrix.elixir }}
otp-version: ${{ matrix.otp }}
- name: Retrieve cached dependencies
uses: actions/cache@v2
id: mix-cache
with:
path: |
deps
_build
priv/plts
key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ 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
mix compile
mix dialyzer --plt
static-code-analysis:
needs: dependencies
runs-on: ubuntu-latest
strategy:
matrix:
elixir: ['1.12']
otp: ['24']
steps:
- name: Cancel previous runs
uses: styfle/cancel-workflow-action@0.9.0
with:
access_token: ${{ github.token }}
- name: Checkout Github repo
uses: actions/checkout@v2
- name: Sets up an Erlang/OTP environment
uses: erlef/setup-beam@v1
with:
elixir-version: ${{ matrix.elixir }}
otp-version: ${{ matrix.otp }}
- name: Retrieve cached dependencies
uses: actions/cache@v2
id: mix-cache
with:
path: |
deps
_build
priv/plts
key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles('mix.lock') }}
- run: mix format --check-formatted
- run: mix credo --strict
- run: mix dialyzer --no-check --ignore-exit-status
tests:
runs-on: ubuntu-latest
needs: dependencies
strategy:
matrix:
elixir: ['1.12']
otp: ['24']
steps:
- name: Cancel previous runs
uses: styfle/cancel-workflow-action@0.9.0
with:
access_token: ${{ github.token }}
- name: Checkout Github repo
uses: actions/checkout@v2
- name: Sets up an Erlang/OTP environment
uses: erlef/setup-beam@v1
with:
elixir-version: ${{ matrix.elixir }}
otp-version: ${{ matrix.otp }}
- name: Retrieve cached dependencies
uses: actions/cache@v2
id: mix-cache
with:
path: |
deps
_build
priv/plts
key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles('mix.lock') }}
# - run: mix test --trace --slowest 10
- run: mix coveralls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment