Skip to content

Commit 86cd560

Browse files
committed
Setup CI
1 parent df514e6 commit 86cd560

File tree

4 files changed

+99
-1
lines changed

4 files changed

+99
-1
lines changed

.github/workflows/pr_and_push.yml

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Push to master and PR CI
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
pull_request:
7+
branches: [ "master" ]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
build:
14+
name: Build and test
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Set up elixir
21+
id: elixir-install
22+
uses: erlef/setup-beam@v1
23+
with:
24+
version-file: .tool-versions
25+
version-type: strict
26+
27+
- name: Restore dependencies/compile cache
28+
uses: actions/cache/restore@v3
29+
id: mix-cache
30+
with:
31+
path: |
32+
deps
33+
_build
34+
key: mix-${{ runner.os }}-${{ steps.elixir-install.outputs.elixir-version }}-${{ steps.elixir-install.outputs.otp-version }}-${{ hashFiles('**/mix.lock') }}
35+
restore-keys: mix-${{ runner.os }}-
36+
37+
- name: Cache status
38+
run: |
39+
[ "${{ steps.mix-cache.outputs.cache-hit }}" == "true" ] \
40+
&& echo "Cache is up-to-date, will skip mix deps tasks" \
41+
|| echo "Cache MISS: looked up ${{ steps.mix-cache.outputs.cache-primary-key }} but found ${{ steps.mix-cache.outputs.cache-matched-key }}. Will run mix tasks."
42+
43+
- name: Install dependencies
44+
if: steps.mix-cache.outputs.cache-hit != 'true'
45+
run: mix deps.get --check-locked
46+
47+
- name: Look out for unused dependencies
48+
if: steps.mix-cache.outputs.cache-hit != 'true'
49+
run: mix deps.unlock --check-unused
50+
51+
- name: Look out for deprecated dependencies
52+
run: mix hex.audit
53+
54+
- name: Look out for security vulnerable dependencies
55+
run: mix deps.audit
56+
57+
# 3 following steps taken from dialyxir's documentation
58+
# https://github.com/jeremyjh/dialyxir/blob/0091928de1ec01e30f82c50856f2dfe0a8f918ce/docs/github_actions.md
59+
60+
- name: Restore PLT cache
61+
id: plt_cache
62+
uses: actions/cache/restore@v3
63+
with:
64+
key: |
65+
plt-${{ runner.os }}-${{ steps.elixir-install.outputs.otp-version }}-${{ steps.elixir-install.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }}
66+
restore-keys: |
67+
plt-${{ runner.os }}-${{ steps.elixir-install.outputs.otp-version }}-${{ steps.elixir-install.outputs.elixir-version }}-
68+
path: |
69+
priv/plts
70+
71+
# Create dialyzer's PLTs if no cache was found
72+
- name: Create PLTs
73+
if: steps.plt_cache.outputs.cache-hit != 'true'
74+
run: mix dialyzer --plt
75+
76+
# By default, the GitHub Cache action will only save the cache if all steps in the job succeed,
77+
# so we separate the cache restore and save steps in case running dialyzer fails.
78+
- name: Save PLT cache
79+
id: plt_cache_save
80+
uses: actions/cache/save@v3
81+
if: steps.plt_cache.outputs.cache-hit != 'true'
82+
with:
83+
key: |
84+
plt-${{ runner.os }}-${{ steps.elixir-install.outputs.otp-version }}-${{ steps.elixir-install.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }}
85+
path: |
86+
priv/plts
87+
88+
- name: Check
89+
run: mix check
90+
91+
- name: Run tests
92+
run: mix test

.tool-versions

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
elixir 1.17.3-otp-27
2+
erlang 27.1.2

mix.exs

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ defmodule Project do
3030
[
3131
{:credo, "~> 1.7", only: [:dev, :test], runtime: false},
3232
{:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false},
33-
{:ex_doc, "~> 0.31", only: :dev, runtime: false}
33+
{:ex_doc, "~> 0.31", only: :dev, runtime: false},
34+
{:mix_audit, "~> 2.1", only: [:dev, :test], runtime: false}
3435
]
3536
end
3637

mix.lock

+3
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,8 @@
1010
"makeup": {:hex, :makeup, "1.1.2", "9ba8837913bdf757787e71c1581c21f9d2455f4dd04cfca785c70bbfff1a76a3", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cce1566b81fbcbd21eca8ffe808f33b221f9eee2cbc7a1706fc3da9ff18e6cac"},
1111
"makeup_elixir": {:hex, :makeup_elixir, "0.16.2", "627e84b8e8bf22e60a2579dad15067c755531fea049ae26ef1020cad58fe9578", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "41193978704763f6bbe6cc2758b84909e62984c7752b3784bd3c218bb341706b"},
1212
"makeup_erlang": {:hex, :makeup_erlang, "1.0.1", "c7f58c120b2b5aa5fd80d540a89fdf866ed42f1f3994e4fe189abebeab610839", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "8a89a1eeccc2d798d6ea15496a6e4870b75e014d1af514b1b71fa33134f57814"},
13+
"mix_audit": {:hex, :mix_audit, "2.1.4", "0a23d5b07350cdd69001c13882a4f5fb9f90fbd4cbf2ebc190a2ee0d187ea3e9", [:make, :mix], [{:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}, {:yaml_elixir, "~> 2.11", [hex: :yaml_elixir, repo: "hexpm", optional: false]}], "hexpm", "fd807653cc8c1cada2911129c7eb9e985e3cc76ebf26f4dd628bb25bbcaa7099"},
1314
"nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"},
15+
"yamerl": {:hex, :yamerl, "0.10.0", "4ff81fee2f1f6a46f1700c0d880b24d193ddb74bd14ef42cb0bcf46e81ef2f8e", [:rebar3], [], "hexpm", "346adb2963f1051dc837a2364e4acf6eb7d80097c0f53cbdc3046ec8ec4b4e6e"},
16+
"yaml_elixir": {:hex, :yaml_elixir, "2.11.0", "9e9ccd134e861c66b84825a3542a1c22ba33f338d82c07282f4f1f52d847bd50", [:mix], [{:yamerl, "~> 0.10", [hex: :yamerl, repo: "hexpm", optional: false]}], "hexpm", "53cc28357ee7eb952344995787f4bb8cc3cecbf189652236e9b163e8ce1bc242"},
1417
}

0 commit comments

Comments
 (0)