-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
136 additions
and
0 deletions.
There are no files selected for viewing
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
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 |