Clean up board implementation. #23
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
# 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 | |
services: | |
postgres: | |
image: postgres | |
env: | |
POSTGRES_PASSWORD: postgres | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 5432:5432 | |
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 | |
- 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 | |
- name: Run tests | |
run: mix test |