Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: CI

on:
pull_request:
push:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- elixir: "1.15.5"
otp: "26"
- elixir: "1.16.0"
otp: "26"
- elixir: "1.18.3"
otp: "27"
- elixir: "1.19.2"
otp: "27"
steps:
- uses: actions/checkout@v3

- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: "1.19"
otp-version: "27"
github-token: "${{ secrets.GITHUB_TOKEN }}"

- name: Install dependencies
run: mix deps.get

- name: Cache dependencies
uses: actions/cache@v4
with:
path: deps
key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ hashFiles('**/mix.lock') }}

- name: Check formatting
run: mix format --check-formatted
if: matrix.check_formatted

- name: Run tests
run: mix test


34 changes: 34 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Release

on:
push:
tags:
- "*"

jobs:
release:
runs-on: ubuntu-24.04
name: Release
strategy:
matrix:
otp: ["27"]
elixir: ["1.19.2"]
env:
HEX_API_KEY: ${{ secrets.HEX_API_KEY }}
steps:
- uses: actions/checkout@v2
- uses: erlef/setup-beam@v1
with:
otp-version: ${{matrix.otp}}
elixir-version: ${{matrix.elixir}}
- name: Restore dependencies cache
uses: actions/cache@v4
with:
path: deps
key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-release-deps-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-release-deps-${{ hashFiles('**/mix.lock') }}
${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-release-deps
- run: mix deps.get
- run: mix hex.publish --yes

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Helpers to organize and route messages in complex Phoenix channels.
Add the following to your mix.exs dependencies:

```elixir
{:channel_handler, "~> 0.6"}
{:channel_handler, "~> 1.0"}
```

## Usage
Expand Down
11 changes: 8 additions & 3 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ defmodule ChannelHandler.MixProject do
use Mix.Project

@repo_url "https://github.com/doorgan/channel_handler"
@version "0.6.3"
@version "1.0.0"

def project do
[
Expand All @@ -12,7 +12,8 @@ defmodule ChannelHandler.MixProject do
start_permanent: Mix.env() == :prod,
deps: deps(),
docs: docs(),
package: package()
package: package(),
elixirc_paths: elixirc_paths(Mix.env())
]
end

Expand All @@ -28,7 +29,7 @@ defmodule ChannelHandler.MixProject do
[
{:ex_doc, ">= 0.0.0", only: :dev},
{:phoenix, ">= 1.6.0", optional: true, only: :test},
{:spark, "~> 2.2.0"}
{:spark, "~> 2.3.0"}
]
end

Expand All @@ -42,6 +43,10 @@ defmodule ChannelHandler.MixProject do
]
end

defp elixirc_paths(:dev), do: ["lib"]
defp elixirc_paths(:test), do: ["lib", "test/support"]
defp elixirc_paths(_), do: ["lib"]

defp docs do
[
extras: [
Expand Down
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"plug_crypto": {:hex, :plug_crypto, "1.2.3", "8f77d13aeb32bfd9e654cb68f0af517b371fb34c56c9f2b58fe3df1235c1251a", [:mix], [], "hexpm", "b5672099c6ad5c202c45f5a403f21a3411247f164e4a8fab056e5cd8a290f4a2"},
"rewrite": {:hex, :rewrite, "1.1.0", "69f869fd6460cde30ae90b09895e42d1840cbdb903802650a28a6959c4777971", [:mix], [{:glob_ex, "~> 0.1", [hex: :glob_ex, repo: "hexpm", optional: false]}, {:sourceror, "~> 1.0", [hex: :sourceror, repo: "hexpm", optional: false]}, {:text_diff, "~> 0.1", [hex: :text_diff, repo: "hexpm", optional: false]}], "hexpm", "adcdd3623a055703c8ecfe4dd24f695ff9d9e1ec6b09c023080999808ff4096e"},
"sourceror": {:hex, :sourceror, "1.7.1", "599d78f4cc2be7d55c9c4fd0a8d772fd0478e3a50e726697c20d13d02aa056d4", [:mix], [], "hexpm", "cd6f268fe29fa00afbc535e215158680a0662b357dc784646d7dff28ac65a0fc"},
"spark": {:hex, :spark, "2.2.35", "1c0bb30f340151eca24164885935de39e6ada4010555f444c813d0488990f8f3", [:mix], [{:igniter, ">= 0.3.64 and < 1.0.0-0", [hex: :igniter, repo: "hexpm", optional: false]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}, {:sourceror, "~> 1.2", [hex: :sourceror, repo: "hexpm", optional: false]}], "hexpm", "f242d6385c287389034a0e146d8f025b5c9ab777f1ae5cf0fdfc9209db6ae748"},
"spark": {:hex, :spark, "2.3.13", "129c2f7ecabd0c27e53daea7aa8b1de4dd068fdafb8d7d5ee49e1f2e8d87ba64", [:mix], [{:igniter, ">= 0.3.64 and < 1.0.0-0", [hex: :igniter, repo: "hexpm", optional: true]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: true]}, {:sourceror, "~> 1.2", [hex: :sourceror, repo: "hexpm", optional: true]}], "hexpm", "d06de23b5e8961d98c9c81d798dbafb9ac64694da19b0e9ca4ba4a8a54b75e31"},
"spitfire": {:hex, :spitfire, "0.1.3", "7ea0f544005dfbe48e615ed90250c9a271bfe126914012023fd5e4b6b82b7ec7", [:mix], [], "hexpm", "d53b5107bcff526a05c5bb54c95e77b36834550affd5830c9f58760e8c543657"},
"telemetry": {:hex, :telemetry, "1.2.1", "68fdfe8d8f05a8428483a97d7aab2f268aaff24b49e0f599faa091f1d4e7f61c", [:rebar3], [], "hexpm", "dad9ce9d8effc621708f99eac538ef1cbe05d6a874dd741de2e689c47feafed5"},
"text_diff": {:hex, :text_diff, "0.1.0", "1caf3175e11a53a9a139bc9339bd607c47b9e376b073d4571c031913317fecaa", [:mix], [], "hexpm", "d1ffaaecab338e49357b6daa82e435f877e0649041ace7755583a0ea3362dbd7"},
Expand Down
20 changes: 20 additions & 0 deletions test/readme_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
defmodule ChannelHandlerTest.ReadmeTest do
use ExUnit.Case, async: true

alias ChannelHandlerTest.Support.Parser
require Parser

@project ChannelHandler.MixProject.project()

readme_path = Parser.resource("README.md")
readme = Parser.code_blocks(readme_path)

@readme readme

test "the version numbers match" do
[_, version] = Regex.run(~r/\{:channel_handler, "~> (.*)"\}/, @readme |> hd |> elem(0))
assert @project[:version] =~ version
end

@external_resource readme_path
end
41 changes: 41 additions & 0 deletions test/support/parser.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
defmodule ChannelHandlerTest.Support.Parser do
@moduledoc false

defstruct in_docstring?: false,
docstrings: []

@type t :: %__MODULE__{
in_docstring?: boolean,
docstrings: [{String.t(), non_neg_integer}]
}

def resource(file_path) do
__DIR__
|> Path.join("../..")
|> Path.join(file_path)
|> Path.expand()
end

def code_blocks(file_path) do
file_path
|> File.read!()
|> String.split("\n")
|> Enum.map(&String.trim/1)
|> Enum.with_index(1)
|> Enum.reduce(%__MODULE__{}, fn
{"```elixir", line}, state = %{in_docstring?: false, docstrings: docstrings} ->
%{state | in_docstring?: true, docstrings: [{"", line} | docstrings]}

{"```", _}, state = %{in_docstring?: true} ->
%{state | in_docstring?: false}

{docline, _}, state = %{in_docstring?: true, docstrings: [{head, line} | rest]} ->
%{state | docstrings: [{head <> "\n" <> docline, line} | rest]}

_, state ->
state
end)
|> Map.get(:docstrings)
|> Enum.reverse()
end
end
Loading