From 062afc9dded5d8f6459a079d16b1db19dcf56ad4 Mon Sep 17 00:00:00 2001 From: Joel Koch Date: Mon, 6 Jul 2026 11:04:30 +0200 Subject: [PATCH 1/5] Add CI --- .github/workflows/ci.yml | 62 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..099d2ab --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,62 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + +env: + MIX_ENV: test + +jobs: + check: + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + with: + persist-credentials: false + + - uses: erlef/setup-beam@54075bcc5e249e4758d363f27d099f55d843f124 # v1 + with: + otp-version: "28.4" + elixir-version: "1.20.2" + + - name: Restore deps cache + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 + with: + path: | + deps + _build + key: deps-${{ runner.os }}-${{ hashFiles('mix.lock') }} + restore-keys: deps-${{ runner.os }}- + + - name: Restore PLT cache + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 + with: + path: priv/plts + key: plts-${{ runner.os }}-${{ hashFiles('mix.lock') }} + restore-keys: plts-${{ runner.os }}- + + - name: Install deps + run: mix deps.get + + - name: "Hex Audit" + run: mix hex.audit + + - name: Compile + run: mix compile --warnings-as-errors + + - name: Check formatting + run: mix format --check-formatted + + - name: Credo + run: mix credo --all --strict + + - name: Dialyzer + run: mix dialyzer + + - name: Run tests + run: mix test From 17f73f81e124f2156242058c0a401289ac540953 Mon Sep 17 00:00:00 2001 From: Joel Koch Date: Mon, 6 Jul 2026 11:17:07 +0200 Subject: [PATCH 2/5] Update precomit task --- mix.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mix.exs b/mix.exs index 557bab6..627fd58 100644 --- a/mix.exs +++ b/mix.exs @@ -81,7 +81,7 @@ defmodule DataplaneEx.MixProject do "compile --warnings-as-errors", "dialyzer", "deps.unlock --unused", - "format", + "format --check-formatted", "credo --all", "test" ] From 477c5d7600e9e524d3f4940006bcf805b9b24573 Mon Sep 17 00:00:00 2001 From: Joel Koch Date: Mon, 6 Jul 2026 14:39:22 +0200 Subject: [PATCH 3/5] Update hpax library --- mix.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mix.lock b/mix.lock index f35f0cf..9e98551 100644 --- a/mix.lock +++ b/mix.lock @@ -14,7 +14,7 @@ "ex_slop": {:hex, :ex_slop, "0.4.2", "142aba9a82eddfb258e39c45d59392ab3cdb6b5a3ad401b09b362b7134fc54eb", [:mix], [{:credo, "~> 1.7", [hex: :credo, repo: "hexpm", optional: false]}], "hexpm", "c7f5316f755f83566e7a0a049f6fedfcd5ff916fce83c6ebfdf806be62fd7a69"}, "file_system": {:hex, :file_system, "1.1.1", "31864f4685b0148f25bd3fbef2b1228457c0c89024ad67f7a81a3ffbc0bbad3a", [:mix], [], "hexpm", "7a15ff97dfe526aeefb090a7a9d3d03aa907e100e262a0f8f7746b78f8f87a5d"}, "fine": {:hex, :fine, "0.1.6", "4bf7151493443c454aac9f2fa2f34f5fefd0346a83fb5586a016c4a135c63247", [:mix], [], "hexpm", "5638eb4495488e885ebec167fa57973e5c35e1a50c344eb7666c90ec1c4e3b12"}, - "hpax": {:hex, :hpax, "1.0.3", "ed67ef51ad4df91e75cc6a1494f851850c0bd98ebc0be6e81b026e765ee535aa", [:mix], [], "hexpm", "8eab6e1cfa8d5918c2ce4ba43588e894af35dbd8e91e6e55c817bca5847df34a"}, + "hpax": {:hex, :hpax, "1.0.4", "777de5d433b0fbdc7c418159c8055910faa8047ffdb3d6b31098d2a46cd7685c", [:mix], [], "hexpm", "afc7cb142ebcc2d01ce7816190b98ce5dd49e799111b24249f3443d730f377ca"}, "jason": {:hex, :jason, "1.4.5", "2e3a008590b0b8d7388c20293e9dcc9cf3e5d642fd2a114e4cbbb52e595d940a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0 or ~> 3.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "b0c823996102bcd0239b3c2444eb00409b72f6a140c1950bc8b457d836b30684"}, "lazy_html": {:hex, :lazy_html, "0.1.11", "136c8e9cd616b4f4e9c1562daa683880891120b759606dc4c3b6b18058ba5d79", [:make, :mix], [{:cc_precompiler, "~> 0.1", [hex: :cc_precompiler, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.9.0", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:fine, "~> 0.1.0", [hex: :fine, repo: "hexpm", optional: false]}], "hexpm", "3b1be592929c31eca1a21673d25696e5c14cddfe922d9d1a3e3b48be4163883b"}, "mime": {:hex, :mime, "2.0.7", "b8d739037be7cd402aee1ba0306edfdef982687ee7e9859bee6198c1e7e2f128", [:mix], [], "hexpm", "6171188e399ee16023ffc5b76ce445eb6d9672e2e241d2df6050f3c771e80ccd"}, From 1f1909c64b090e67a50025591bc86f7347e1a159 Mon Sep 17 00:00:00 2001 From: Joel Koch Date: Mon, 6 Jul 2026 15:07:04 +0200 Subject: [PATCH 4/5] Apply credo fixes --- lib/dataplane_ex/car.ex | 5 +++-- lib/dataplane_ex/indexer.ex | 3 ++- mix.exs | 2 +- test/dataplane_ex/atproto/commit_test.exs | 3 ++- test/dataplane_ex/car_test.exs | 11 ++++++----- test/dataplane_ex/server_test.exs | 2 +- .../controllers/error_html_test.exs | 15 --------------- test/support/conn_case.ex | 16 +--------------- 8 files changed, 16 insertions(+), 41 deletions(-) delete mode 100644 test/dataplane_ex_web/controllers/error_html_test.exs diff --git a/lib/dataplane_ex/car.ex b/lib/dataplane_ex/car.ex index a2d7ba1..21c39e1 100644 --- a/lib/dataplane_ex/car.ex +++ b/lib/dataplane_ex/car.ex @@ -2,17 +2,18 @@ defmodule DataplaneEx.CAR do @moduledoc false use Ecto.Type + alias DASL.CAR.DRISL def type, do: :map - def cast(%DASL.CAR.DRISL{} = car), do: {:ok, car} + def cast(%DRISL{} = car), do: {:ok, car} def cast(%CBOR.Tag{tag: :bytes, value: bytes}) do cast(bytes) end def cast(bytes) do - case DASL.CAR.DRISL.decode(bytes) do + case DRISL.decode(bytes) do {:ok, car} -> {:ok, car} {:error, _section, _reason} -> :error end diff --git a/lib/dataplane_ex/indexer.ex b/lib/dataplane_ex/indexer.ex index e572b70..6f923ce 100644 --- a/lib/dataplane_ex/indexer.ex +++ b/lib/dataplane_ex/indexer.ex @@ -27,6 +27,7 @@ defmodule DataplaneEx.Indexer do and the tables are recreated empty when it restarts. """ use GenServer + alias DataplaneEx.ATProto.Event alias DataplaneEx.Progress require Logger @@ -350,7 +351,7 @@ defmodule DataplaneEx.Indexer do def handle_info({:binary, binary}, state) do events = binary - |> DataplaneEx.ATProto.Event.decode() + |> Event.decode() |> List.wrap() Enum.each(events, &index_event/1) diff --git a/mix.exs b/mix.exs index 627fd58..d26e103 100644 --- a/mix.exs +++ b/mix.exs @@ -82,7 +82,7 @@ defmodule DataplaneEx.MixProject do "dialyzer", "deps.unlock --unused", "format --check-formatted", - "credo --all", + "credo --all --strict", "test" ] ] diff --git a/test/dataplane_ex/atproto/commit_test.exs b/test/dataplane_ex/atproto/commit_test.exs index 3f983ab..1d437f6 100644 --- a/test/dataplane_ex/atproto/commit_test.exs +++ b/test/dataplane_ex/atproto/commit_test.exs @@ -1,5 +1,6 @@ defmodule DataplaneEx.ATProto.CommitTest do use ExUnit.Case, async: true + alias DASL.CAR.DRISL alias DataplaneEx.ATProto.Commit alias DataplaneEx.Op @@ -11,7 +12,7 @@ defmodule DataplaneEx.ATProto.CommitTest do "ignored" => "not included" } - {:ok, {blocks, cid}} = DASL.CAR.DRISL.add_block(%DASL.CAR.DRISL{}, record) + {:ok, {blocks, cid}} = DRISL.add_block(%DRISL{}, record) commit = %Commit{ repo: "did:plc:alice", diff --git a/test/dataplane_ex/car_test.exs b/test/dataplane_ex/car_test.exs index e8d191d..a44c22e 100644 --- a/test/dataplane_ex/car_test.exs +++ b/test/dataplane_ex/car_test.exs @@ -1,21 +1,22 @@ defmodule DataplaneEx.CARTest do use ExUnit.Case, async: true + alias DASL.CAR.DRISL alias DataplaneEx.CAR test "casts CBOR byte payloads into decoded DASL DRISL CARs" do record = %{"$type" => "app.bsky.feed.post", "text" => "hello"} - {:ok, {car, cid}} = DASL.CAR.DRISL.add_block(%DASL.CAR.DRISL{}, record) - {:ok, car} = DASL.CAR.DRISL.add_root(car, cid) - {:ok, bytes} = DASL.CAR.DRISL.encode(car) + {:ok, {car, cid}} = DRISL.add_block(%DRISL{}, record) + {:ok, car} = DRISL.add_root(car, cid) + {:ok, bytes} = DRISL.encode(car) assert {:ok, decoded} = CAR.cast(%CBOR.Tag{tag: :bytes, value: bytes}) - assert %DASL.CAR.DRISL{} = decoded + assert %DRISL{} = decoded assert decoded.roots == [cid] assert decoded.blocks[cid] == record end test "accepts already decoded DASL DRISL CARs" do - car = %DASL.CAR.DRISL{} + car = %DRISL{} assert CAR.cast(car) == {:ok, car} end diff --git a/test/dataplane_ex/server_test.exs b/test/dataplane_ex/server_test.exs index 8af2432..a19b0eb 100644 --- a/test/dataplane_ex/server_test.exs +++ b/test/dataplane_ex/server_test.exs @@ -1,8 +1,8 @@ defmodule DataplaneEx.ServerTest do use ExUnit.Case, async: false import DataplaneEx.CSVFixtures - alias DataplaneEx.Server alias DataplaneEx.Indexer + alias DataplaneEx.Server setup do did1 = "did:plc:firesim1" diff --git a/test/dataplane_ex_web/controllers/error_html_test.exs b/test/dataplane_ex_web/controllers/error_html_test.exs deleted file mode 100644 index 6d281c0..0000000 --- a/test/dataplane_ex_web/controllers/error_html_test.exs +++ /dev/null @@ -1,15 +0,0 @@ -defmodule DataplaneExWeb.ErrorHTMLTest do - use DataplaneExWeb.ConnCase, async: true - - # Bring render_to_string/4 for testing custom views - import Phoenix.Template, only: [render_to_string: 4] - - test "renders 404.html" do - assert render_to_string(DataplaneExWeb.ErrorHTML, "404", "html", []) == "Not Found" - end - - test "renders 500.html" do - assert render_to_string(DataplaneExWeb.ErrorHTML, "500", "html", []) == - "Internal Server Error" - end -end diff --git a/test/support/conn_case.ex b/test/support/conn_case.ex index fa0a296..ae8501f 100644 --- a/test/support/conn_case.ex +++ b/test/support/conn_case.ex @@ -1,19 +1,5 @@ defmodule DataplaneExWeb.ConnCase do - @moduledoc """ - This module defines the test case to be used by - tests that require setting up a connection. - - Such tests rely on `Phoenix.ConnTest` and also - import other functionality to make it easier - to build common data structures and query the data layer. - - Finally, if the test case interacts with the database, - we enable the SQL sandbox, so changes done to the database - are reverted at the end of every test. If you are using - PostgreSQL, you can even run database tests asynchronously - by setting `use DataplaneExWeb.ConnCase, async: true`, although - this option is not recommended for other databases. - """ + @moduledoc false use ExUnit.CaseTemplate From e0580c6212b7a00e7964b60264dc442b2f6109cd Mon Sep 17 00:00:00 2001 From: Joel Koch Date: Tue, 7 Jul 2026 10:19:55 +0200 Subject: [PATCH 5/5] Remove quotes in step name --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 099d2ab..49f767c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,7 +43,7 @@ jobs: - name: Install deps run: mix deps.get - - name: "Hex Audit" + - name: Hex Audit run: mix hex.audit - name: Compile