Skip to content

Commit

Permalink
chore: update import matcher to catch failures
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Feb 15, 2024
1 parent 5885c12 commit 9e577cc
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 29 deletions.
61 changes: 35 additions & 26 deletions lib/ash_hq/docs/resources/library/actions/import.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ defmodule AshHq.Docs.Library.Actions.Import do
path_var(),
changeset.arguments.metadata.version
)
|> case do
:ok ->
{:ok, changeset.data}

{:ok, changeset.data}
other ->
other
end
end

defp path_var do
Expand Down Expand Up @@ -68,33 +73,37 @@ defmodule AshHq.Docs.Library.Actions.Import do
File.rm_rf!(file)
end

if result do
Logger.info("Starting import of #{name}: #{version}")
Logger.info("Starting import of #{name}: #{version}")

unless AshHq.Docs.exists?(
Ash.Query.for_read(AshHq.Docs.LibraryVersion, :read)
|> Ash.Query.filter(library_id == ^library.id and version == ^version)
) do
AshHq.Repo.transaction(
fn ->
library_version =
AshHq.Docs.LibraryVersion.build!(
library.id,
version,
%{
timeout: :infinity,
extensions: result[:extensions],
doc: result[:doc],
guides: result[:guides],
modules: result[:modules],
mix_tasks: result[:mix_tasks]
}
)
if AshHq.Docs.exists?(
Ash.Query.for_read(AshHq.Docs.LibraryVersion, :read)
|> Ash.Query.filter(library_id == ^library.id and version == ^version)
) do
:ok
else
AshHq.Repo.transaction(
fn ->
library_version =
AshHq.Docs.LibraryVersion.build!(
library.id,
version,
%{
timeout: :infinity,
extensions: result[:extensions],
doc: result[:doc],
guides: result[:guides],
modules: result[:modules],
mix_tasks: result[:mix_tasks]
}
)

delete_except(library_version.id, library.id)
end,
timeout: :infinity
)
delete_except(library_version.id, library.id)
end,
timeout: :infinity
)
|> case do
{:ok, _} -> :ok
other -> other
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"appsignal": {:hex, :appsignal, "2.7.9", "efc11601a848f153752778356bc86f9af03e925f15a961f714cd702a83cee434", [:make, :mix], [{:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:decorator, "~> 1.2.3 or ~> 1.3", [hex: :decorator, repo: "hexpm", optional: false]}, {:hackney, "~> 1.6", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:poison, ">= 1.3.0", [hex: :poison, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "84fff1dcba3d3fcf542c528ffb0f4eba891da0f68125fcf57e9b30d1a1a4a6e9"},
"appsignal_phoenix": {:hex, :appsignal_phoenix, "2.3.4", "c83a8e15a51456db7d722a21bfe9a45e23618b550219caa8fb6d4853f61b5734", [:mix], [{:appsignal, ">= 2.7.6 and < 3.0.0", [hex: :appsignal, repo: "hexpm", optional: false]}, {:appsignal_plug, ">= 2.0.15 and < 3.0.0", [hex: :appsignal_plug, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.11 or ~> 3.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:phoenix_live_view, "~> 0.9", [hex: :phoenix_live_view, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "1ca040fbfa653bdda25735031d8b89c81ebb50c475bc35d5ac0e13236e5f6600"},
"appsignal_plug": {:hex, :appsignal_plug, "2.0.15", "758a8a78944878e8461bbc77ca86219121a56f4299c6d79940ab083cf9afea00", [:mix], [{:appsignal, ">= 2.7.6 and < 3.0.0", [hex: :appsignal, repo: "hexpm", optional: false]}, {:plug, ">= 1.1.0", [hex: :plug, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "1c6059049e2081e808aaef04e2b9917e06277f61a35a0e103db860d08cbc41f1"},
"ash": {:git, "https://github.com/ash-project/ash.git", "6c5cd551ff16f01a707cbd49c689899b9366aa8b", []},
"ash": {:git, "https://github.com/ash-project/ash.git", "e331e24c7becf9bb7eace83d65cf09c07f741c81", []},
"ash_admin": {:git, "https://github.com/ash-project/ash_admin.git", "3002af9ec69dc475582ef5f445064e4594bf45ac", []},
"ash_appsignal": {:hex, :ash_appsignal, "0.1.2", "a6eb1927a13c11006aad0d9ffaa011143344dd04c9b07ab94f459498b8ddc6d4", [:mix], [{:appsignal, "~> 2.0", [hex: :appsignal, repo: "hexpm", optional: false]}, {:ash, ">= 2.14.14", [hex: :ash, repo: "hexpm", optional: false]}], "hexpm", "dae3158337d2a36b76f04519ebe6d08ef5296823831993cef6069eeb879c5b94"},
"ash_authentication": {:hex, :ash_authentication, "3.11.15", "7834446cdd13bb471bded630aa0e0e4fb8795ffffe0c294dc22448d3778ff035", [:mix], [{:ash, ">= 2.5.11 and < 3.0.0-0", [hex: :ash, repo: "hexpm", optional: false]}, {:assent, "~> 0.2", [hex: :assent, repo: "hexpm", optional: false]}, {:bcrypt_elixir, "~> 3.0", [hex: :bcrypt_elixir, repo: "hexpm", optional: false]}, {:castore, "~> 1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:finch, "~> 0.16.0", [hex: :finch, repo: "hexpm", optional: false]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}, {:joken, "~> 2.5", [hex: :joken, repo: "hexpm", optional: false]}, {:plug, "~> 1.13", [hex: :plug, repo: "hexpm", optional: false]}, {:spark, ">= 1.1.39 and < 2.0.0-0", [hex: :spark, repo: "hexpm", optional: false]}], "hexpm", "931926d8dd3fc5ac54a354d69aad6aed30438977d7971bf3fdfae4c563557d21"},
Expand All @@ -13,9 +13,9 @@
"ash_csv": {:git, "https://github.com/ash-project/ash_csv.git", "7f47b820077619ccb7340fbede0c4fd1b5313a17", []},
"ash_graphql": {:git, "https://github.com/ash-project/ash_graphql.git", "cf57747d79f848608252ab167d74bb59aaef2345", []},
"ash_json_api": {:git, "https://github.com/ash-project/ash_json_api.git", "31ece4fad9920c7e45c600d38ac82218296c4612", []},
"ash_oban": {:git, "https://github.com/ash-project/ash_oban.git", "bfacb4572cda947bf6d5de27a075922b5d2e6c36", []},
"ash_oban": {:git, "https://github.com/ash-project/ash_oban.git", "0dd7f68cf24910f0291e6c9f2fda3d7324c3a675", []},
"ash_phoenix": {:git, "https://github.com/ash-project/ash_phoenix.git", "35e4d2931e1664383c9a085a90f846e58986c8c8", []},
"ash_postgres": {:git, "https://github.com/ash-project/ash_postgres.git", "40c1a13652dc65406692ffbcaf6d78d1d8aa07c4", []},
"ash_postgres": {:git, "https://github.com/ash-project/ash_postgres.git", "b2b05618b50918e98e6e0b57a6422fe531a0e587", []},
"assent": {:hex, :assent, "0.2.7", "aa68f68e577077c091ce722bff8fe1ae56b95b274bb8107f7a5406cc15a65da7", [:mix], [{:certifi, ">= 0.0.0", [hex: :certifi, repo: "hexpm", optional: true]}, {:finch, "~> 0.15", [hex: :finch, repo: "hexpm", optional: true]}, {:jose, "~> 1.8", [hex: :jose, repo: "hexpm", optional: true]}, {:mint, "~> 1.0", [hex: :mint, repo: "hexpm", optional: true]}, {:ssl_verify_fun, ">= 0.0.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: true]}], "hexpm", "08106af439de4f9de114c0334de4c848de7cfbe53a5a52d342a784c4f6bc86f3"},
"bcrypt_elixir": {:hex, :bcrypt_elixir, "3.1.0", "0b110a9a6c619b19a7f73fa3004aa11d6e719a67e672d1633dc36b6b2290a0f7", [:make, :mix], [{:comeonin, "~> 5.3", [hex: :comeonin, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "2ad2acb5a8bc049e8d5aa267802631912bb80d5f4110a178ae7999e69dca1bf7"},
"bunt": {:hex, :bunt, "0.2.1", "e2d4792f7bc0ced7583ab54922808919518d0e57ee162901a16a1b6664ef3b14", [:mix], [], "hexpm", "a330bfb4245239787b15005e66ae6845c9cd524a288f0d141c148b02603777a5"},
Expand Down

0 comments on commit 9e577cc

Please sign in to comment.