Below is a sample GitHub Action config, pulled from GitHub - jeremyjh/dialyxir: Mix tasks to simplify use of Dialyzer in Elixir projects., but it’s very close to what I’m also using.
I’m trying to figure out an equivalent GitLab CI setup. It seems that GitLab CI’s cache operates similar to GitHub actions/cache@v2
Action in that it will not save the cache if any step of a given job fails. I’d like to split that up in GitLab CI into two separate steps like so:
1. Restore cache of static analysis artifacts if it exists
2. Incrementally generate updated static analysis artifacts based on cached ones
3. Cache updated static analysis artifacts
4. Perform static analysis check
Is there a way I could accomplish that? Any and all tips are appreciated!
The GitHub Action config:
# github-actions-dialyzer.yml
# ...
steps:
- uses: actions/checkout@v2
- name: Set up Elixir
id: beam
uses: erlef/setup-beam@v1
with:
elixir-version: "1.12.3" # Define the elixir version
otp-version: "24.1" # Define the OTP version
# Don't cache PLTs based on mix.lock hash, as Dialyzer can incrementally update even old ones
# Cache key based on Elixir & Erlang version (also useful when running in matrix)
- name: Restore PLT cache
uses: actions/cache/restore@v3
id: plt_cache
with:
key: |
${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-plt
restore-keys: |
${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-plt
path: |
priv/plts
# Create PLTs if no cache was found
- name: Create PLTs
if: steps.plt_cache.outputs.cache-hit != 'true'
run: mix dialyzer --plt
# By default, the GitHub Cache action will only save the cache if all steps in the job succeed,
# so we separate the cache restore and save steps in case running dialyzer fails.
- name: Save PLT cache
uses: actions/cache/save@v3
if: steps.plt_cache.outputs.cache-hit != 'true'
id: plt_cache_save
with:
key: |
${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-plt
path: |
priv/plts
- name: Run dialyzer
run: mix dialyzer --format github
# ...