Skip to content

Commit 3c8a814

Browse files
build: add basic CI and dialyzer (#19)
* Add basic CI and dialyzer. * Remove credo for now. * Separate Build and Test jobs. * Rename job. * Fix test job. * Use tool versions in CI. * Add version type scrict. * Add ci for every branch. --------- Co-authored-by: Tomás <47506558+MegaRedHand@users.noreply.github.com>
1 parent 433a75e commit 3c8a814

File tree

5 files changed

+91
-3
lines changed

5 files changed

+91
-3
lines changed

.github/workflows/ci.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ '*' ]
8+
9+
env:
10+
MIX_ENV: test
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
build:
17+
name: Build
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v3
21+
- name: Set up Elixir
22+
uses: erlef/setup-beam@v1
23+
with:
24+
version-type: strict
25+
version-file: .tool-versions
26+
env:
27+
ImageOS: ubuntu20
28+
- name: Restore dependencies cache
29+
uses: actions/cache@v3
30+
with:
31+
path: deps
32+
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
33+
restore-keys: ${{ runner.os }}-mix-
34+
- name: Install dependencies
35+
run: mix deps.get
36+
- name: Retrieve PLT Cache
37+
uses: actions/cache@v1
38+
id: plt-cache
39+
with:
40+
path: priv/plts
41+
key: ${{ runner.os }}-plts-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
42+
- name: Create PLTs
43+
if: steps.plt-cache.outputs.cache-hit != 'true'
44+
run: |
45+
mkdir -p priv/plts
46+
mix dialyzer --plt
47+
- name: Run dialyzer
48+
run: mix dialyzer --no-check
49+
test:
50+
name: Test
51+
runs-on: ubuntu-latest
52+
steps:
53+
- uses: actions/checkout@v3
54+
- name: Set up Elixir
55+
uses: erlef/setup-beam@v1
56+
with:
57+
version-type: strict
58+
version-file: .tool-versions
59+
env:
60+
ImageOS: ubuntu20
61+
- name: Restore dependencies cache
62+
uses: actions/cache@v3
63+
with:
64+
path: deps
65+
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
66+
restore-keys: ${{ runner.os }}-mix-
67+
- name: Install dependencies
68+
run: mix deps.get
69+
- name: Run tests
70+
run: mix test

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
# If you run "mix test --cover", coverage assets end up here.
55
/cover/
66

7+
# mix dialyzer artifacts
8+
/priv/plts/*.plt
9+
/priv/plts/*.plt.hash
10+
711
# The directory Mix downloads your dependencies sources to.
812
/deps/
913

lib/lambda_ethereum_consensus.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ defmodule LambdaEthereumConsensus do
1212
:world
1313
1414
"""
15+
@spec hello() :: :world
1516
def hello do
1617
:world
1718
end

mix.exs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ defmodule LambdaEthereumConsensus.MixProject do
77
version: "0.1.0",
88
elixir: "~> 1.15",
99
start_permanent: Mix.env() == :prod,
10-
deps: deps()
10+
deps: deps(),
11+
dialyzer: dialyzer(),
12+
preferred_cli_env: [
13+
dialyzer: :test
14+
],
1115
]
1216
end
1317

@@ -22,8 +26,13 @@ defmodule LambdaEthereumConsensus.MixProject do
2226
# Run "mix help deps" to learn about dependencies.
2327
defp deps do
2428
[
25-
# {:dep_from_hexpm, "~> 0.3.0"},
26-
# {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"}
29+
{:dialyxir, "~> 1.1", only: [:dev, :test], runtime: false},
30+
]
31+
end
32+
33+
defp dialyzer() do
34+
[
35+
plt_file: {:no_warn, "priv/plts/project.plt"}
2736
]
2837
end
2938
end

mix.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
%{
2+
"dialyxir": {:hex, :dialyxir, "1.3.0", "fd1672f0922b7648ff9ce7b1b26fcf0ef56dda964a459892ad15f6b4410b5284", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "00b2a4bcd6aa8db9dcb0b38c1225b7277dca9bc370b6438715667071a304696f"},
3+
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
4+
}

0 commit comments

Comments
 (0)