Skip to content

Commit

Permalink
Update caching strategy in CI (#809)
Browse files Browse the repository at this point in the history
  • Loading branch information
whatyouhide authored Oct 21, 2024
1 parent 549d5be commit 823ad4e
Showing 1 changed file with 26 additions and 27 deletions.
53 changes: 26 additions & 27 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
include:
# Newest supported Elixir/Erlang pair.
- elixir: '1.17'
otp: '27.0'
otp: '27.1'
lint: true
dialyzer: true

Expand All @@ -45,63 +45,62 @@ jobs:
elixir-version: ${{ matrix.elixir }}
otp-version: ${{ matrix.otp }}

# We need to manually restore and then save, so that we can save the "_build" directory
# *without* the Elixir compiled code in it.
- name: Restore Mix dependencies cache
uses: actions/cache/restore@v4
id: mix-deps-cache
- name: Cache downloaded dependencies
uses: actions/cache@v4
id: mix-downloaded-deps-cache
with:
path: |
_build
deps
test_integrations/phoenix_app/_build
test_integrations/phoenix_app/deps
key: |
${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
restore-keys: |
${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-
${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-deps-${{ hashFiles('**/mix.lock') }}
- name: Install and compile Mix dependencies
if: steps.mix-deps-cache.outputs.cache-hit != 'true'
- name: Download Mix dependencies
if: steps.mix-downloaded-deps-cache.outputs.cache-hit != 'true'
run: |
mix do deps.get --check-locked, deps.compile
mix deps.get --check-locked
cd test_integrations/phoenix_app
mix do deps.get --check-locked, deps.compile
mix deps.get --check-locked
- name: Save Mix dependencies cache
uses: actions/cache/save@v4
if: steps.mix-deps-cache.outputs.cache-hit != 'true'
# We need to manually restore and then save, so that we can save the "_build" directory
# *without* the Elixir compiled code in it.
- name: Cache compiled Elixir code
uses: actions/cache@v4
id: mix-cache
with:
path: |
_build
deps
test_integrations/phoenix_app/_build
test_integrations/phoenix_app/deps
key: |
${{ steps.mix-deps-cache.outputs.cache-primary-key }}
${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-
- name: Check formatting
- name: Compile Elixir code (with --warnings-as-errors)
if: matrix.lint
run: mix format --check-formatted
run: |
mix compile --warnings-as-errors
cd test_integrations/phoenix_app
mix compile --warnings-as-errors
- name: Check compiler warnings
- name: Check formatting
if: matrix.lint
run: mix compile --warnings-as-errors
run: mix format --check-formatted

- name: Run tests
run: mix test

- name: Run integration tests
run: mix test.integrations

- name: Retrieve PLT Cache
- name: Cache Dialyzer PLT
uses: actions/cache@v4
if: matrix.dialyzer
id: plt-cache
with:
path: plts
key: |
${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-plts-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-plts-${{ hashFiles(format('**/mix.lock')) }}
restore-keys: |
${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-plts-
Expand Down

0 comments on commit 823ad4e

Please sign in to comment.