Skip to content

Commit

Permalink
Adds CI
Browse files Browse the repository at this point in the history
  • Loading branch information
dkln committed Apr 30, 2024
1 parent 9d23117 commit 437012b
Showing 1 changed file with 136 additions and 0 deletions.
136 changes: 136 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
name: Test and build

on:
pull_request:
branches:
- master

jobs:
test:
name: "Run tests"
runs-on: ubuntu-latest
env:
MIX_ENV: test

steps:
- uses: actions/[email protected]

- name: Read .tool-versions
uses: marocchino/[email protected]
id: versions

- name: Set up Elixir ${{steps.versions.outputs.elixir}}
uses: erlef/setup-beam@v1
with:
elixir-version: ${{steps.versions.outputs.elixir}}
otp-version: ${{steps.versions.outputs.erlang}}

- name: Restore dependencies cache
uses: actions/[email protected]
with:
path: |
deps
_build
key: ${{ runner.os }}-mixv2-${{ hashFiles('**/mix.lock', 'config/*.exs') }}
restore-keys: ${{ runner.os }}-mixv2-

- name: Setup deps
run: |
mix deps.get
mix deps.unlock --check-unused
- name: Compile
run: mix compile --warnings-as-errors

- name: Check formatter
run: mix format --check-formatted

- name: Run tests
run: mix test --warnings-as-errors

- name: Cleanup
run: mix clean


dialyzer:
name: "Run Dialyzer"
runs-on: ubuntu-latest

steps:
- uses: actions/[email protected]

- name: Read .tool-versions
uses: marocchino/[email protected]
id: versions

- name: Set up Elixir ${{steps.versions.outputs.elixir}}
uses: erlef/setup-beam@v1
with:
elixir-version: ${{steps.versions.outputs.elixir}}
otp-version: ${{steps.versions.outputs.erlang}}

# Step: Define how to cache deps. Restores existing cache if present.
- name: Cache deps
id: cache-deps
uses: actions/cache@v3
env:
cache-name: cache-elixir-deps
with:
path: deps
key: ${{ runner.os }}-mix-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-mix-${{ env.cache-name }}-
# Step: Define how to cache the `_build` directory. After the first run,
# this speeds up tests runs a lot. This includes not re-compiling our
# project's downloaded deps every run.
- name: Cache compiled build
id: cache-build
uses: actions/cache@v3
env:
cache-name: cache-compiled-build
with:
path: _build
key: ${{ runner.os }}-mix-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-mix-${{ env.cache-name }}-
${{ runner.os }}-mix-
- name: Restore PLT cache
id: plt_cache
uses: actions/cache/restore@v3
with:
key: |
plt-${{ runner.os }}-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
plt-${{ runner.os }}-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}-
path: |
priv/plts
- name: Setup deps
run: |
mix deps.get
mix deps.unlock --check-unused
- name: Compile
run: mix compile --warnings-as-errors

- name: Create PLTs
if: steps.plt_cache.outputs.cache-hit != 'true'
run: mix dialyzer --plt

- name: Save PLT cache
id: plt_cache_save
uses: actions/cache/save@v3
if: steps.plt_cache.outputs.cache-hit != 'true'
with:
key: |
plt-${{ runner.os }}-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }}
path: |
priv/plts
- name: Run dialyzer
run: mix dialyzer --format github

- name: Cleanup
run: mix clean

0 comments on commit 437012b

Please sign in to comment.