Skip to content

Commit 96e55f4

Browse files
committed
Run bin/audit in CI
1 parent 6d244cb commit 96e55f4

File tree

4 files changed

+42
-4
lines changed

4 files changed

+42
-4
lines changed

.github/workflows/ci-cd.yml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ jobs:
1616
version:
1717
runs-on: ubuntu-latest
1818
outputs:
19+
elixir-version: ${{ steps.parse.outputs.elixir-version }}
20+
otp-version: ${{ steps.parse.outputs.otp-version }}
1921
previous-release-tag: ${{ steps.parse.outputs.previous-release-tag }}
2022
releasable: ${{ steps.parse.outputs.releasable }}
2123
semver: ${{ steps.parse.outputs.semver }}
@@ -38,13 +40,37 @@ jobs:
3840
- run: mix test
3941

4042
audit:
43+
needs: [ version ]
4144
runs-on: ubuntu-latest
4245
steps:
4346
- uses: actions/checkout@v3
4447
- uses: pkgxdev/dev@v0
4548
- run: mix deps.get
46-
- run: mix e2e.update_examples_workflow --check
47-
- run: bin/format --check
49+
- name: Restore PLT cache
50+
id: plt_cache
51+
uses: actions/cache/restore@v3
52+
with:
53+
key: |
54+
plt-${{ runner.os }}-${{ needs.version.outputs.otp-version }}-${{ needs.version.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }}
55+
restore-keys: |
56+
plt-${{ runner.os }}-${{ needs.version.outputs.otp-version }}-${{ needs.version.outputs.elixir-version }}-
57+
path: |
58+
priv/plts
59+
- name: Create PLTs
60+
if: steps.plt_cache.outputs.cache-hit != 'true'
61+
run: mix dialyzer --plt
62+
# By default, the GitHub Cache action will only save the cache if all steps in the job succeed,
63+
# so we separate the cache restore and save steps in case running dialyzer fails.
64+
- name: Save PLT cache
65+
id: plt_cache_save
66+
uses: actions/cache/save@v3
67+
if: steps.plt_cache.outputs.cache-hit != 'true'
68+
with:
69+
key: |
70+
plt-${{ runner.os }}-${{ needs.version.outputs.otp-version }}-${{ needs.version.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }}
71+
path: |
72+
priv/plts
73+
- run: bin/audit
4874

4975
build:
5076
runs-on: ubuntu-latest

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,7 @@ elixir_script-*.tar
3030

3131
# The compiled artifact
3232
elixir_script
33+
34+
# Dialyzer
35+
/priv/plts/*.plt
36+
/priv/plts/*.plt.hash

bin/audit

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ echo "Checking code formatting..."
1010
bin/format --check
1111

1212
echo "Running static code analysis with dialyzer..."
13-
mix dialyzer
13+
if [ "${CI:-}" == "true" ]; then
14+
mix dialyzer --format github
15+
else
16+
mix dialyzer
17+
fi
1418

1519
echo "Checking code style with Credo..."
1620
mix credo --strict

mix.exs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ defmodule ElixirScript.MixProject do
88
elixir: "~> 1.15",
99
escript: escript(),
1010
deps: deps(),
11-
dialyzer: [plt_add_apps: [:mix]]
11+
dialyzer: [
12+
plt_add_apps: [:mix],
13+
plt_core_path: "priv/plts/core.plt",
14+
plt_local_path: "priv/plts/project.plt"
15+
]
1216
]
1317
end
1418

0 commit comments

Comments
 (0)