-
-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #490 from Nezteb/master
Add GitLab CI example with dialyzer cache, refactor sample CI configs into new docs directory
- Loading branch information
Showing
3 changed files
with
127 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Github Actions | ||
|
||
```yaml | ||
steps: | ||
- name: Check out source | ||
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 | ||
id: plt_cache | ||
uses: actions/cache/restore@v3 | ||
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 | ||
id: plt_cache_save | ||
uses: actions/cache/save@v3 | ||
if: steps.plt_cache.outputs.cache-hit != 'true' | ||
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 | ||
|
||
# ... | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# GitLab CI | ||
|
||
```yaml | ||
# Some of the duplication can be reduced with YAML anchors: | ||
# https://docs.gitlab.com/ee/ci/yaml/yaml_optimization.html | ||
|
||
image: elixir:1.14 | ||
|
||
stages: | ||
- compile | ||
- check-elixir-types | ||
|
||
# You'll want to cache based on your Erlang/Elixir version. | ||
|
||
# The example jobs below uses asdf's config file as the cache key: | ||
# https://asdf-vm.com/manage/configuration.html | ||
|
||
# An example build job with cache, to prevent dialyzer from needing to compile your project first | ||
build-dev: | ||
stage: compile | ||
cache: | ||
- key: | ||
files: | ||
- mix.lock | ||
- .tool-versions | ||
paths: | ||
- deps/ | ||
- _build/dev | ||
policy: pull-push | ||
script: | ||
- mix do deps.get, compile | ||
|
||
# The main difference between the following jobs is their cache policy: | ||
# https://docs.gitlab.com/ee/ci/yaml/index.html#cachepolicy | ||
|
||
dialyzer-plt: | ||
stage: check-elixir-types | ||
needs: | ||
- build-dev | ||
cache: | ||
- key: | ||
files: | ||
- .tool-versions | ||
paths: | ||
- priv/plts | ||
# Pull cache at start, push updated cache after completion | ||
policy: pull-push | ||
script: | ||
- mix dialyzer --plt | ||
|
||
dialyzer-check: | ||
stage: check-elixir-types | ||
needs: | ||
- dialyzer-plt | ||
cache: | ||
- key: | ||
files: | ||
- .tool-versions | ||
paths: | ||
- priv/plts | ||
# Pull cache at start, don't push cache after completion | ||
policy: pull | ||
script: | ||
- mix dialyzer --format short | ||
|
||
# ... | ||
``` |