-
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
1 parent
e21db2c
commit 09f4c15
Showing
1 changed file
with
79 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,79 @@ | ||
# Inspired by a combination of: | ||
# - https://github.com/rrrene/credo/blob/master/.github/workflows/ci-workflow.yml | ||
# - https://elixirforum.com/t/using-github-action-cache/37922/2 | ||
name: "Lint and test" | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-22.04 | ||
env: | ||
ImageOS: ubuntu22 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: erlef/setup-beam@v1 | ||
id: beam | ||
with: | ||
otp-version: '25' | ||
elixir-version: '1.15' | ||
|
||
# Dependencies. | ||
- name: Restore dependencies cache | ||
uses: actions/cache@v2 | ||
id: deps_cache | ||
with: | ||
key: | | ||
${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-deps-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} | ||
restore-keys: | | ||
${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-deps | ||
path: | | ||
deps | ||
- name: Download dependencies | ||
run: mix deps.get | ||
- name: Compile dependencies | ||
run: mix deps.compile | ||
|
||
# Build. | ||
- name: Restore build cache | ||
uses: actions/cache@v2 | ||
id: build_cache | ||
with: | ||
key: | | ||
${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-build-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} | ||
restore-keys: | | ||
${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-build | ||
path: | | ||
_build | ||
- name: Compile project | ||
run: mix compile --warnings-as-errors | ||
|
||
# Formatting, linting, and type checking. | ||
- name: Check formatting | ||
run: mix format --check-formatted | ||
- name: Check lint | ||
run: mix credo --strict | ||
- name: Restore PLT cache | ||
uses: actions/cache@v2 | ||
id: plt_cache | ||
with: | ||
key: | | ||
${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-plt | ||
restore-keys: | | ||
${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-plt | ||
path: | | ||
priv/plts | ||
- name: Create PLTs | ||
if: steps.plt_cache.outputs.cache-hit != 'true' | ||
run: mix dialyzer --plt | ||
- name: Check typespecs | ||
run: mix dialyzer --format github | ||
|
||
# Tests. | ||
- name: Check tests | ||
run: mix test |