Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update caching strategy in CI #809

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading