# Create initial workflow based on GitHub's suggestion for Elixir. | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
branches: ["main"] | |
env: | |
MIX_ENV: test | |
jobs: | |
lint: | |
name: Lint codebase | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Elixir | |
uses: erlef/setup-beam@v1 | |
with: | |
elixir-version: '1.16.0' | |
otp-version: '26.0' | |
- name: Cache dependencies | |
id: cache-deps | |
uses: actions/cache@v4 | |
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 }}- | |
- name: Cache compiled build | |
id: cache-build | |
uses: actions/cache@v4 | |
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: Clean dependencies to rule out incremental build as source of failures | |
if: github.run_attempt != '1' | |
run: | | |
mix deps.clean --all | |
mix clean | |
shell: sh | |
- name: Install dependencies | |
run: mix deps.get | |
- name: Compile | |
run: mix compile | |
- name: Check formatting | |
run: mix format --check-formatted | |
- name: Check code style | |
run: mix credo --all-priorities | |