Skip to content

Commit

Permalink
Add Github Action cache example into README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomas Klohna committed Nov 22, 2021
1 parent 02f0e15 commit 97270a6
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ To use Dialyzer in CI, you must be aware of several things:
2) The PLT should be cached using the CI caching system
3) The PLT will need to be rebuilt whenever adding a new Erlang or Elixir version to build matrix

Using Travis, this would look like:
### Travis

`.travis.yml`
```markdown
Expand All @@ -101,6 +101,43 @@ cache:
- priv/plts
```

### Github Actions

`dialyzer.yml`
```yaml
...
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 usefull when running in matrix)
- name: Restore PLT cache
uses: actions/cache@v2
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

- name: Run dialyzer
run: mix dialyzer

```

`mix.exs`
```elixir
def project do
Expand Down

0 comments on commit 97270a6

Please sign in to comment.