Created
November 29, 2022 09:42
-
-
Save cr0t/38880e3db2421722db415fb4253d2ac1 to your computer and use it in GitHub Desktop.
GitHub Actions Elixir Workflow Example
This file contains hidden or 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
name: Elixir CI | |
on: | |
push: | |
branches: ["master"] | |
pull_request: | |
branches: ["master"] | |
env: | |
MIX_ENV: test | |
permissions: | |
contents: read | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
name: Test on Elixir ${{matrix.elixir}} / OTP ${{matrix.otp}} | |
strategy: | |
matrix: | |
elixir: [1.14.1] | |
otp: [25.1.2] | |
steps: | |
- name: Setup Elixir | |
uses: erlef/setup-beam@v1 | |
with: | |
elixir-version: ${{matrix.elixir}} | |
otp-version: ${{matrix.otp}} | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Cache deps | |
uses: actions/cache@v3 | |
env: | |
cache-name: deps-cache | |
with: | |
path: deps | |
key: ${{ runner.os }}-mix-${{ env.cache-name }}-${{hashFiles('**/mix.lock') }} | |
restore-keys: ${{ runner.os }}-mix-${{ env.cache-name }}- | |
- name: Cache build | |
uses: actions/cache@v3 | |
env: | |
cache-name: compiled-build-cache | |
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: Install deps | |
run: mix deps.get | |
- name: Compile with warnings as errors | |
run: mix compile --warnings-as-errors | |
- name: Check code formatting | |
run: mix format --check-formatted | |
- name: Check for unused dependencies | |
run: mix deps.unlock --check-unused | |
- name: Analyze code | |
run: mix credo suggest --ignore todo | |
- name: Run tests | |
run: mix test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment