Skip to content

Commit 87c1b28

Browse files
committed
Add GitHub Actions CI, update deps
1 parent 5b050d4 commit 87c1b28

4 files changed

Lines changed: 88 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
elixir: ['1.15', '1.16', '1.17']
16+
otp: ['25', '26', '27']
17+
exclude:
18+
- elixir: '1.15'
19+
otp: '27'
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- uses: erlef/setup-beam@v1
25+
with:
26+
elixir-version: ${{ matrix.elixir }}
27+
otp-version: ${{ matrix.otp }}
28+
29+
- name: Restore dependencies cache
30+
uses: actions/cache@v4
31+
with:
32+
path: deps
33+
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
34+
restore-keys: ${{ runner.os }}-mix-
35+
36+
- name: Install dependencies
37+
run: mix deps.get
38+
39+
- name: Run tests
40+
run: mix test
41+
42+
lint:
43+
runs-on: ubuntu-latest
44+
45+
steps:
46+
- uses: actions/checkout@v4
47+
48+
- uses: erlef/setup-beam@v1
49+
with:
50+
elixir-version: '1.17'
51+
otp-version: '27'
52+
53+
- name: Restore dependencies cache
54+
uses: actions/cache@v4
55+
with:
56+
path: deps
57+
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
58+
restore-keys: ${{ runner.os }}-mix-
59+
60+
- name: Install dependencies
61+
run: mix deps.get
62+
63+
- name: Check formatting
64+
run: mix format --check-formatted
65+
66+
- name: Compile with warnings as errors
67+
run: mix compile --warnings-as-errors

lib/phoenix_iconify.ex

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ defmodule PhoenixIconify do
9696
<.icon name="hero-user-solid" />
9797
9898
"""
99-
attr :name, :string, required: true, doc: "Icon name (e.g., \"heroicons:user\")"
100-
attr :class, :string, default: nil, doc: "CSS classes"
101-
attr :rest, :global, doc: "Additional SVG attributes"
99+
attr(:name, :string, required: true, doc: "Icon name (e.g., \"heroicons:user\")")
100+
attr(:class, :string, default: nil, doc: "CSS classes")
101+
attr(:rest, :global, doc: "Additional SVG attributes")
102102

103103
def icon(assigns) do
104104
icon_data = get_icon(assigns.name)
@@ -184,7 +184,10 @@ defmodule PhoenixIconify do
184184
# Private functions
185185

186186
defp handle_missing_icon(normalized, original) do
187-
maybe_warn("Icon not found: #{normalized}" <> if(normalized != original, do: " (from #{original})", else: ""))
187+
maybe_warn(
188+
"Icon not found: #{normalized}" <>
189+
if(normalized != original, do: " (from #{original})", else: "")
190+
)
188191

189192
if runtime_fetch_enabled?() do
190193
fetch_icon_at_runtime(normalized)

lib/phoenix_iconify/collector.ex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ defmodule PhoenixIconify.Collector do
6262

6363
defp extract_name_from_props(_), do: []
6464

65-
defp extract_string_value({:string, value, _meta}) when is_binary(value), do: [normalize_name(value)]
65+
defp extract_string_value({:string, value, _meta}) when is_binary(value),
66+
do: [normalize_name(value)]
67+
6668
defp extract_string_value(value) when is_binary(value), do: [normalize_name(value)]
6769
defp extract_string_value(_), do: []
6870

mix.exs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ defmodule PhoenixIconify.MixProject do
22
use Mix.Project
33

44
@version "0.1.0"
5-
@source_url "https://github.com/TODO/phoenix_iconify"
5+
@source_url "https://github.com/dannote/phoenix_iconify"
66

77
def project do
88
[
@@ -26,13 +26,22 @@ defmodule PhoenixIconify.MixProject do
2626

2727
defp deps do
2828
[
29-
{:iconify, path: "../iconify"},
29+
{:iconify, iconify_dep()},
3030
{:phoenix_live_view, "~> 0.20 or ~> 1.0"},
3131
{:req, "~> 0.5"},
3232
{:ex_doc, "~> 0.31", only: :dev, runtime: false}
3333
]
3434
end
3535

36+
# Use path dependency for local dev, Hex for published version
37+
defp iconify_dep do
38+
if path = System.get_env("ICONIFY_PATH") do
39+
[path: path]
40+
else
41+
"~> 0.1.0"
42+
end
43+
end
44+
3645
defp package do
3746
[
3847
licenses: ["MIT"],

0 commit comments

Comments
 (0)