Skip to content

Instantly share code, notes, and snippets.

@cdegroot
Created April 14, 2023 15:09
Show Gist options
  • Save cdegroot/00a0a3e62261221f5ae722fabc6a51ac to your computer and use it in GitHub Desktop.
Save cdegroot/00a0a3e62261221f5ae722fabc6a51ac to your computer and use it in GitHub Desktop.
Caching preamble for Elixir workflows in GitHub Actions
steps:
- uses: actions/checkout@v3
- name: asdf setup
uses: asdf-vm/actions/setup@v1
- name: Restore asdf cache
id: asdf-cache
uses: actions/cache@v3
with:
path: ~/.asdf/
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
- name: asdf install
if: steps.asdf-cache.outputs.cache-hit != 'true'
uses: asdf-vm/actions/install@v1
- name: Restore dependencies cache
uses: actions/cache@v3
with:
path: |
deps
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}-${{ hashFiles('**/.tool-versions') }}
restore-keys: ${{ runner.os }}-mix-
- name: Restore build cache
uses: actions/cache@v3
with:
path: |
_build
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}-cfg-${{ hashFiles('**/config/*.exs') }}-${{ hashFiles('**/.to
ol-versions') }}
restore-keys: ${{ runner.os }}-mix-
- name: Install dependencies
run: |
mix local.hex --force
mix local.rebar --force
mix deps.get
- name: Retrieve Dialyzer PLT cache
uses: actions/cache@v3
id: plt-cache
with:
path: priv/plts
key: ${{ runner.os }}-plts-${{ hashFiles('**/mix.lock') }}-${{ hashFiles('**/.tool-versions') }}
- name: Create Dialyzer PLTs
if: steps.plt-cache.outputs.cache-hit != 'true'
run: |
mkdir -p priv/plts
mix dialyzer --plt
- name: Run Dialyzer
run: MIX_ENV=test mix dialyzer --no-check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment