Skip to content

Commit

Permalink
Add CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpearce committed Oct 25, 2023
1 parent e21db2c commit 09f4c15
Showing 1 changed file with 79 additions and 0 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/ci.yaml
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

0 comments on commit 09f4c15

Please sign in to comment.