Skip to content

Commit 823ad4e

Browse files
authored
Update caching strategy in CI (#809)
1 parent 549d5be commit 823ad4e

File tree

1 file changed

+26
-27
lines changed

1 file changed

+26
-27
lines changed

.github/workflows/main.yml

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
include:
2424
# Newest supported Elixir/Erlang pair.
2525
- elixir: '1.17'
26-
otp: '27.0'
26+
otp: '27.1'
2727
lint: true
2828
dialyzer: true
2929

@@ -45,63 +45,62 @@ jobs:
4545
elixir-version: ${{ matrix.elixir }}
4646
otp-version: ${{ matrix.otp }}
4747

48-
# We need to manually restore and then save, so that we can save the "_build" directory
49-
# *without* the Elixir compiled code in it.
50-
- name: Restore Mix dependencies cache
51-
uses: actions/cache/restore@v4
52-
id: mix-deps-cache
48+
- name: Cache downloaded dependencies
49+
uses: actions/cache@v4
50+
id: mix-downloaded-deps-cache
5351
with:
5452
path: |
55-
_build
5653
deps
57-
test_integrations/phoenix_app/_build
5854
test_integrations/phoenix_app/deps
5955
key: |
60-
${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
61-
restore-keys: |
62-
${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-
56+
${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-deps-${{ hashFiles('**/mix.lock') }}
6357
64-
- name: Install and compile Mix dependencies
65-
if: steps.mix-deps-cache.outputs.cache-hit != 'true'
58+
- name: Download Mix dependencies
59+
if: steps.mix-downloaded-deps-cache.outputs.cache-hit != 'true'
6660
run: |
67-
mix do deps.get --check-locked, deps.compile
61+
mix deps.get --check-locked
6862
cd test_integrations/phoenix_app
69-
mix do deps.get --check-locked, deps.compile
63+
mix deps.get --check-locked
7064
71-
- name: Save Mix dependencies cache
72-
uses: actions/cache/save@v4
73-
if: steps.mix-deps-cache.outputs.cache-hit != 'true'
65+
# We need to manually restore and then save, so that we can save the "_build" directory
66+
# *without* the Elixir compiled code in it.
67+
- name: Cache compiled Elixir code
68+
uses: actions/cache@v4
69+
id: mix-cache
7470
with:
7571
path: |
7672
_build
77-
deps
7873
test_integrations/phoenix_app/_build
79-
test_integrations/phoenix_app/deps
8074
key: |
81-
${{ steps.mix-deps-cache.outputs.cache-primary-key }}
75+
${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ hashFiles('**/mix.lock') }}
76+
restore-keys: |
77+
${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-
8278
83-
- name: Check formatting
79+
- name: Compile Elixir code (with --warnings-as-errors)
8480
if: matrix.lint
85-
run: mix format --check-formatted
81+
run: |
82+
mix compile --warnings-as-errors
83+
cd test_integrations/phoenix_app
84+
mix compile --warnings-as-errors
8685
87-
- name: Check compiler warnings
86+
- name: Check formatting
8887
if: matrix.lint
89-
run: mix compile --warnings-as-errors
88+
run: mix format --check-formatted
9089

9190
- name: Run tests
9291
run: mix test
9392

9493
- name: Run integration tests
9594
run: mix test.integrations
9695

97-
- name: Retrieve PLT Cache
96+
- name: Cache Dialyzer PLT
9897
uses: actions/cache@v4
9998
if: matrix.dialyzer
10099
id: plt-cache
101100
with:
102101
path: plts
103102
key: |
104-
${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-plts-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
103+
${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-plts-${{ hashFiles(format('**/mix.lock')) }}
105104
restore-keys: |
106105
${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-plts-
107106

0 commit comments

Comments
 (0)